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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.metaschema.schemagen.ISchemaGenerator
ISchemaGenerator.SchemaFormat -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new XML schema generator using the default XML output factory.XmlSchemaGenerator(org.codehaus.stax2.XMLOutputFactory2 xmlOutputFactory) Constructs a new XML schema generator using the specified XML output factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgenerateSchema(dev.metaschema.schemagen.xml.impl.XmlGenerationState state) Called to generate the actual schema content.protected static voidgenerateSchemaMetadata(IModule module, dev.metaschema.schemagen.xml.impl.XmlGenerationState state) Generates the schema metadata annotation containing module information.protected org.codehaus.stax2.XMLOutputFactory2Retrieves the XML output factory used by this generator.protected dev.metaschema.schemagen.xml.impl.XmlGenerationStatenewGenerationState(IModule module, AutoCloser<org.codehaus.stax2.XMLStreamWriter2, SchemaGenerationException> schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration) Create a new schema generation state object.protected @Owning AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException> Create a new writer to use to write the schema.Methods inherited from class dev.metaschema.schemagen.AbstractSchemaGenerator
analyzeDefinitions, generateFromModule
-
Field Details
-
PREFIX_XML_SCHEMA
The namespace prefix for XML Schema elements.- See Also:
-
NS_XML_SCHEMA
The XML Schema namespace URI.- See Also:
-
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:AbstractSchemaGeneratorCreate a new writer to use to write the schema.The caller owns the returned writer and is responsible for closing it.
- Specified by:
newWriterin classAbstractSchemaGenerator<AutoCloser<org.codehaus.stax2.XMLStreamWriter2,SchemaGenerationException>, dev.metaschema.schemagen.xml.impl.XmlDatatypeManager, dev.metaschema.schemagen.xml.impl.XmlGenerationState> - Parameters:
out- theWriterto 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:AbstractSchemaGeneratorCreate a new schema generation state object.- Specified by:
newGenerationStatein classAbstractSchemaGenerator<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 forschemaWriter- the writer to use to write the schemaconfiguration- 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:AbstractSchemaGeneratorCalled to generate the actual schema content.- Specified by:
generateSchemain classAbstractSchemaGenerator<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 fromstate- the XML generation state for writing output- Throws:
XMLStreamException- if an error occurs while writing XML content
-