Class TREXGrammarReader

All Implemented Interfaces:
IDContextProvider2, XSDatatypeResolver, org.relaxng.datatype.ValidationContext, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

public class TREXGrammarReader extends TREXBaseReader implements XSDatatypeResolver
reads TREX grammar from SAX2 and constructs abstract grammar model.
  • Field Details

    • currentGrammarURI

      protected String currentGrammarURI
      TREX allows either (1) the predefined namespace for TREX or (2) default namespace "" as its namespace. This variable holds which namespace is currently in use.
    • TREXNamespace

      public static final String TREXNamespace
      Namespace URI of TREX
      See Also:
    • issueObsoletedXMLSchemaNamespace

      private boolean issueObsoletedXMLSchemaNamespace
  • Constructor Details

  • Method Details

    • parse

      public static TREXGrammar parse(String grammarURL, SAXParserFactory factory, GrammarReaderController controller)
      loads TREX pattern
    • parse

      public static TREXGrammar parse(InputSource grammar, SAXParserFactory factory, GrammarReaderController controller)
      loads TREX pattern
    • localizeMessage

      protected String localizeMessage(String propertyName, Object[] args)
      Description copied from class: GrammarReader
      formats localized message with arguments
      Overrides:
      localizeMessage in class TREXBaseReader
    • getGrammar

      protected TREXGrammar getGrammar()
    • isGrammarElement

      protected boolean isGrammarElement(StartTagInfo tag)
      Description copied from class: GrammarReader
      checks if given element is that of the grammar elements.
      Specified by:
      isGrammarElement in class GrammarReader
    • getStateFactory

      protected TREXGrammarReader.StateFactory getStateFactory()
    • mapNamespace

      private String mapNamespace(String namespace)
      maps obsoleted XML Schema namespace to the current one.
    • createExpressionChildState

      public State createExpressionChildState(State parent, StartTagInfo tag)
      Description copied from class: GrammarReader
      this method must be implemented by the derived class to create language-default expresion state.
      Overrides:
      createExpressionChildState in class TREXBaseReader
      Returns:
      null if the start tag is an error.
    • resolveXSDatatype

      public XSDatatypeExp resolveXSDatatype(String qName)
      Specified by:
      resolveXSDatatype in interface XSDatatypeResolver
      Parameters:
      qName - The type of this value varies in the schema language. In XML Schema, for example, in which QNames are used to designate datatypes, this parameter will be QName. In RELAX Core, in which the same syntax is used but NCName is used to designate datatypes. So this parameter will be NCName.
      Returns:
      A non-null valid object. An error should be reported and recovered by the callee.
    • resolveDatatype

      public org.relaxng.datatype.Datatype resolveDatatype(String qName)
      obtains a named DataType object referenced by a QName.
    • wrapUp

      public void wrapUp()
      Description copied from class: TREXBaseReader
      performs final wrap-up. This method is called from the RootState object, after the parsing is completed.

      This method has to be called after the run-away expression check is done.

      Overrides:
      wrapUp in class TREXBaseReader