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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 source document (ex: XML) by using the given settings generatorSettings.
    protected abstract String
    Returns the grammar file extension (ex : xsd, dtd) to generate.
    protected boolean
    Returns true if element declaration must be stored as flat mode and false otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractXML2GrammarGenerator

      public AbstractXML2GrammarGenerator()
  • Method Details

    • generate

      public String generate(Document prototypeDocument, SharedSettings sharedSettings, T generatorSettings, IXMLFullFormatter formatter, org.eclipse.lsp4j.jsonrpc.CancelChecker cancelChecker)
      Description copied from interface: IFileContentGenerator
      Generates a file content (ex : XSD, DTD) from the given document source document (ex: XML) by using the given settings generatorSettings.
      Specified by:
      generate in interface IFileContentGenerator<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 settings generatorSettings.
    • 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 <!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 settings
      out - the XML builder to update.
      cancelChecker -