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
Grammarinstance from the XML source and each implementation uses this grammar information to generate the proper grammar.
-
-
Constructor Summary
Constructors Constructor Description AbstractXML2GrammarGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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.Stringgenerate(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 StringgetFileExtension()Returns 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.
-
-
-
Method Detail
-
generate
public String generate(Document prototypeDocument, SharedSettings sharedSettings, T generatorSettings, IXMLFullFormatter formatter, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
Description copied from interface:IFileContentGeneratorGenerates a file content (ex : XSD, DTD) from the given document sourcedocument(ex: XML) by using the given settingsgeneratorSettings.- Specified by:
generatein interfaceIFileContentGenerator<Document,T extends FileContentGeneratorSettings>- Parameters:
prototypeDocument- the XML document source.sharedSettings- the shared settings.generatorSettings- the generator settings.formatter- the formatter.- Returns:
- the result of the generation of the file content (ex : XSD, DTD) from
the given document source
document(ex: XML) by using the given settingsgeneratorSettings.
-
getFileExtension
protected abstract String 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
- 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-
-
-