Class XmlSchemaReader

java.lang.Object
network.ike.plugin.schema.XmlSchemaReader

public final class XmlSchemaReader extends Object
Reads XML Schema files into a SchemaSignature with the JDK's own XML support and nothing else (IKE-Network/ike-issues#1104). It reads what a signature is: named complex types, their extension base, their documentation, their element and attribute positions, and named simple types that enumerate values. Schema features a signature does not need, choices, groups, and attribute groups, are refused rather than silently dropped, so that a schema outside the reader's reach fails loudly.

The reader is namespace-aware and matches schema elements by the XML Schema namespace, so the prefix a file uses, xs or xsd, does not matter. A type is identified by its namespace and its name: a bare reference resolves to the file's default namespace, or its target namespace when it declares none, and a prefixed reference through the file's own namespace declarations, so xs:string is a schema primitive and a:CqlToElmBase a type of another schema.

  • Constructor Details

    • XmlSchemaReader

      public XmlSchemaReader()
      Creates a reader with a secure, namespace-aware document builder.
      Throws:
      IllegalStateException - when the JDK cannot provide a document builder
  • Method Details

    • read

      public SchemaSignature read(List<Path> schemas) throws IOException
      Reads one or more schema files into a single signature, in the order given. Types are collected across all files, so a base declared in one file and extended in another resolves.
      Parameters:
      schemas - the schema files
      Returns:
      the signature the files declare
      Throws:
      IOException - when a file cannot be read or is not well-formed XML
      IllegalArgumentException - when a file uses a schema feature the reader refuses