Class GrammarReader

    • Method Detail

      • createParserFactory

        protected static SAXParserFactory createParserFactory()
        Creates a default SAXParserFactory.
      • getResultAsGrammar

        public abstract Grammar getResultAsGrammar()
        gets the parsed AGM. Should any error happens, this method should returns null. derived classes should implement type-safe getGrammar method, along with this method.
      • isGrammarElement

        protected abstract boolean isGrammarElement​(StartTagInfo tag)
        checks if given element is that of the grammar elements.
      • iterateInscopeNamespaces

        public Iterator iterateInscopeNamespaces()
        Iterates Map.Entry objects which has the prefix as key and the namespace URI as value.
      • splitQName

        public String[] splitQName​(String qName)
        Resolves a QName into a pair of (namespace URI,local name). Therefore this method returns null if it fails to process QName.
      • interceptExpression

        protected Expression interceptExpression​(State state,
                                                 Expression exp)
        intercepts an expression made by ExpressionState before it is passed to the parent state. derived class can perform further wrap-up before it is received by the parent. This mechanism is used by RELAXReader to handle occurs attribute.
      • getBackwardCompatibleType

        public XSDatatype getBackwardCompatibleType​(String typeName)
        tries to obtain a DataType object by resolving obsolete names. this method is useful for backward compatibility purpose.
      • resolveLocation

        public final InputSource resolveLocation​(State sourceState,
                                                 String uri)
                                          throws AbortException
        obtains InputSource for the specified url. Also this method allows GrammarReaderController to redirect or prohibit inclusion.
        Parameters:
        sourceState - The base URI of this state is used to resolve the resource.
        Returns:
        always return non-null valid object
        Throws:
        AbortException
      • combineURI

        public final String combineURI​(String baseURI,
                                       String relativeURI)
        converts the relative URL to the absolute one by using the specified base URL.
      • combineURL

        public final String combineURL​(String baseURI,
                                       String relativeURI)
        Deprecated.
        use the combineURI method.
      • switchSource

        public void switchSource​(State sourceState,
                                 String url,
                                 State newState)
                          throws AbortException
        Switchs InputSource to the specified URL and parses it by the specified state. The method will return after the parsing of the new source is completed. derived classes can use this method to realize semantics of 'include'.
        Parameters:
        sourceState - this state is used to resolve the URL.
        newState - this state will parse top-level of new XML source. this state receives document element by its createChildState method.
        Throws:
        AbortException
      • switchSource

        public void switchSource​(InputSource source,
                                 State newState)
        start reading input from a source defined by a SAX InputSource.
        Parameters:
        source -
        newState -
      • switchSource

        public void switchSource​(Source source,
                                 State newState)
        Start reading input from a source defined by a javax.xml.transform source.
        Parameters:
        source -
        newState -
      • _parse

        public final void _parse​(Object source,
                                 Locator errorSource)
        parses a grammar from the specified source
      • setDeclaredLocationOf

        public void setDeclaredLocationOf​(Object o)
      • getDeclaredLocationOf

        public Locator getDeclaredLocationOf​(Object o)
      • detectUndefinedOnes

        public void detectUndefinedOnes​(ReferenceContainer container,
                                        String errMsg)
        detects undefined ReferenceExp and reports it as an error. this method is used in the final wrap-up process of parsing.
      • pushState

        public void pushState​(State newState,
                              State parentState,
                              StartTagInfo startTag)
        pushs the current state into the stack and sets new one
      • popState

        public void popState()
        pops the previous state from the stack
      • getCurrentState

        public final State getCurrentState()
        gets current State object.
      • createExpressionChildState

        public abstract State createExpressionChildState​(State parent,
                                                         StartTagInfo tag)
        this method must be implemented by the derived class to create language-default expresion state.
        Returns:
        null if the start tag is an error.
      • resolveNamespacePrefix

        public String resolveNamespacePrefix​(String prefix)
        Specified by:
        resolveNamespacePrefix in interface org.relaxng.datatype.ValidationContext
      • isUnparsedEntity

        public boolean isUnparsedEntity​(String entityName)
        Specified by:
        isUnparsedEntity in interface org.relaxng.datatype.ValidationContext
      • isNotation

        public boolean isNotation​(String notationName)
        Specified by:
        isNotation in interface org.relaxng.datatype.ValidationContext
      • getBaseUri

        public String getBaseUri()
        Specified by:
        getBaseUri in interface org.relaxng.datatype.ValidationContext
      • onID

        public final void onID​(org.relaxng.datatype.Datatype dt,
                               StringToken token)
        Description copied from interface: IDContextProvider2
        this method is called when a type with ID semantics is matched. It is the callee's responsibility that stores ID and checks doubly defined ID, if it is necessary.
        Specified by:
        onID in interface IDContextProvider2
      • addBackPatchJob

        public final void addBackPatchJob​(XSDatatypeExp job)
      • runBackPatchJob

        public final void runBackPatchJob()
        Performs all back-patchings.
      • reportError

        public final void reportError​(String propertyName)
      • reportError

        public final void reportError​(String propertyName,
                                      Object arg1)
      • reportError

        public final void reportError​(String propertyName,
                                      Object arg1,
                                      Object arg2)
      • reportError

        public final void reportError​(Exception nestedException,
                                      String propertyName)
      • reportError

        public final void reportError​(Exception nestedException,
                                      String propertyName,
                                      Object arg1)
      • reportError

        public final void reportError​(Locator[] locs,
                                      String propertyName,
                                      Object[] args)
      • reportWarning

        public final void reportWarning​(String propertyName)
      • reportWarning

        public final void reportWarning​(String propertyName,
                                        Object arg1)
      • reportWarning

        public final void reportWarning​(String propertyName,
                                        Object arg1,
                                        Object arg2)
      • reportError

        public final void reportError​(String propertyName,
                                      Object[] args,
                                      Exception nestedException,
                                      Locator[] errorLocations)
        reports an error to the controller
      • reportWarning

        public final void reportWarning​(String propertyName,
                                        Object[] args,
                                        Locator[] locations)
        reports a warning to the controller
      • inputSourceFromLSInput

        public static Source inputSourceFromLSInput​(LSInput input)
        This is a stopgap until we can wean more of this code from SAX-dependence.
        Parameters:
        input -
        Returns:
      • localizeMessage

        protected abstract String localizeMessage​(String propertyName,
                                                  Object[] args)
        formats localized message with arguments
      • setLocator

        public void setLocator​(Locator locator)
      • getLocator

        public Locator getLocator()