Class QNameParser


  • public class QNameParser
    extends Object
    Parser to handle QNames in either lexical QName or EQName syntax, including resolving any prefix against a URIResolver. The parser can be instantiated with various options to control the returned error code, the handling of defaults, etc.
    • Method Detail

      • setNamespaceResolver

        public void setNamespaceResolver​(NamespaceResolver resolver)
      • setAcceptEQName

        public void setAcceptEQName​(boolean acceptEQName)
      • setDefaultNamespace

        public void setDefaultNamespace​(String defaultNamespace)
      • setErrorOnBadSyntax

        public void setErrorOnBadSyntax​(String code)
      • setErrorOnUnresolvedPrefix

        public void setErrorOnUnresolvedPrefix​(String code)
      • parse

        public StructuredQName parse​(CharSequence lexicalName)
                              throws XPathException
        Make a structured QName from a lexical QName, using a supplied NamespaceResolver to resolve the prefix. The local part of the QName is checked for validity; the prefix is not checked, on the grounds that an invalid prefix will fail to resolve to a URI.
        Parameters:
        lexicalName - the QName as a lexical name (prefix:local)
        Returns:
        the StructuredQName object corresponding to this lexical QName
        Throws:
        XPathException - if the namespace prefix is not in scope or if the value is lexically invalid. Error code FONS0004 is set if the namespace prefix has not been declared; error code FOCA0002 is set if the name is lexically invalid. These may need to be changed on return depending on the caller's requirements.