Class AbstractXML2GrammarGenerator<T extends FileContentGeneratorSettings>
java.lang.Object
org.eclipse.lemminx.extensions.generators.AbstractXML2GrammarGenerator<T>
- Type Parameters:
T- the grammar generator settings.
- All Implemented Interfaces:
IFileContentGenerator<Document,T>
- Direct Known Subclasses:
XML2DTDGenerator,XML2RelaxNGGenerator,XML2XMLSchemaGenerator
public abstract class AbstractXML2GrammarGenerator<T extends FileContentGeneratorSettings>
extends Object
implements IFileContentGenerator<Document,T>
Abstract class to generate a grammar (XSD, DTD, etc) from a given XML source.
The process is to build a generic Grammar instance from the XML
source and each implementation uses this grammar information to generate the
proper grammar.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidgenerate(Grammar grammar, T grammarSettings, XMLBuilder out, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Generate the grammar content from the given grammar information into the given builder.generate(Document prototypeDocument, SharedSettings sharedSettings, T generatorSettings, IXMLFullFormatter formatter, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Generates a file content (ex : XSD, DTD) from the given document sourcedocument(ex: XML) by using the given settingsgeneratorSettings.protected abstract StringReturns the grammar file extension (ex : xsd, dtd) to generate.protected booleanisFlat()Returns true if element declaration must be stored as flat mode and false otherwise.
-
Constructor Details
-
AbstractXML2GrammarGenerator
public AbstractXML2GrammarGenerator()
-
-
Method Details
-
getFileExtension
Returns the grammar file extension (ex : xsd, dtd) to generate.- Returns:
- the grammar file extension (ex : xsd, dtd) to generate.
-
isFlat
protected boolean isFlat()Returns true if element declaration must be stored as flat mode and false otherwise.- flat=true: helpful for DTD which declares <!ELEMENT without hierarchy.
- flat=false: helpful for XSD which declares xs:element with hierarchy.
- Returns:
- true if element declaration must be stored as flat mode and false otherwise.
-
generate
protected abstract void generate(Grammar grammar, T grammarSettings, XMLBuilder out, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker) Generate the grammar content from the given grammar information into the given builder.- Parameters:
grammar- the grammar information.grammarSettings- the grammar settingsout- the XML builder to update.cancelChecker-