Class XmlSchemaGenerator

java.lang.Object
dev.metaschema.schemagen.AbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>,dev.metaschema.schemagen.xml.impl.XmlDatatypeManager,dev.metaschema.schemagen.xml.impl.XmlGenerationState>
dev.metaschema.schemagen.xml.XmlSchemaGenerator
All Implemented Interfaces:
ISchemaGenerator

public class XmlSchemaGenerator extends AbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>,dev.metaschema.schemagen.xml.impl.XmlDatatypeManager,dev.metaschema.schemagen.xml.impl.XmlGenerationState>
Generates XML Schema (XSD) documents from Metaschema modules.

This generator produces W3C XML Schema documents that validate XML instances conforming to the Metaschema module definitions.

  • Field Details

    • PREFIX_XML_SCHEMA

      @NonNull public static final String PREFIX_XML_SCHEMA
      The namespace prefix for XML Schema elements.
      See Also:
    • NS_XML_SCHEMA

      @NonNull public static final String NS_XML_SCHEMA
      The XML Schema namespace URI.
      See Also:
    • NS_XHTML

      @NonNull public static final String NS_XHTML
      The XHTML namespace URI used for documentation content.
      See Also:
  • Constructor Details

    • XmlSchemaGenerator

      public XmlSchemaGenerator()
      Constructs a new XML schema generator using the default XML output factory.
    • XmlSchemaGenerator

      public XmlSchemaGenerator(@NonNull org.codehaus.stax2.XMLOutputFactory2 xmlOutputFactory)
      Constructs a new XML schema generator using the specified XML output factory.
      Parameters:
      xmlOutputFactory - the XML output factory to use for creating XML writers
  • Method Details

    • getXmlOutputFactory

      protected org.codehaus.stax2.XMLOutputFactory2 getXmlOutputFactory()
      Retrieves the XML output factory used by this generator.
      Returns:
      the XML output factory
    • newWriter

      @Owning protected @Owning AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException> newWriter(Writer out)
      Description copied from class: AbstractSchemaGenerator
      Create a new writer to use to write the schema.

      The caller owns the returned writer and is responsible for closing it.

      Specified by:
      newWriter in class AbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>,dev.metaschema.schemagen.xml.impl.XmlDatatypeManager,dev.metaschema.schemagen.xml.impl.XmlGenerationState>
      Parameters:
      out - the Writer to write the schema content to
      Returns:
      the schema writer
    • newGenerationState

      protected dev.metaschema.schemagen.xml.impl.XmlGenerationState newGenerationState(IModule module, AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException> schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration)
      Description copied from class: AbstractSchemaGenerator
      Create a new schema generation state object.
      Specified by:
      newGenerationState in class AbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>,dev.metaschema.schemagen.xml.impl.XmlDatatypeManager,dev.metaschema.schemagen.xml.impl.XmlGenerationState>
      Parameters:
      module - the Metaschema module to generate the schema for
      schemaWriter - the writer to use to write the schema
      configuration - the generation configuration
      Returns:
      the schema generation state used for context and writing
    • generateSchema

      protected void generateSchema(dev.metaschema.schemagen.xml.impl.XmlGenerationState state)
      Description copied from class: AbstractSchemaGenerator
      Called to generate the actual schema content.
      Specified by:
      generateSchema in class AbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>,dev.metaschema.schemagen.xml.impl.XmlDatatypeManager,dev.metaschema.schemagen.xml.impl.XmlGenerationState>
      Parameters:
      state - the generation state object
    • generateSchemaMetadata

      protected static void generateSchemaMetadata(@NonNull IModule module, @NonNull dev.metaschema.schemagen.xml.impl.XmlGenerationState state) throws XMLStreamException
      Generates the schema metadata annotation containing module information.

      This includes the schema name, version, short name, and optional remarks.

      Parameters:
      module - the Metaschema module to extract metadata from
      state - the XML generation state for writing output
      Throws:
      XMLStreamException - if an error occurs while writing XML content