Package net.sf.saxon.om
Class QNameParser
java.lang.Object
net.sf.saxon.om.QNameParser
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.
The QNameParser is immutable; its properties are set using the
withProperty()
fluent API style.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparse
(String lexicalName, NamespaceUri defaultNS) Make a structured QName from a lexical QName, using a supplied NamespaceResolver to resolve the prefix.withAcceptEQName
(boolean acceptEQName) Say whether URI-qualified names inQ{uri}local
format should be acceptedwithErrorOnBadSyntax
(String code) Say what error code should be thrown when the QName syntax is invalidSay what error code should be thrown when the prefix is undeclaredwithNamespaceResolver
(NamespaceResolver resolver) Set the namespace resolver to be usedwithUnescaper
(XQueryParser.Unescaper unescaper) Supply a callback used to unescape special characters appearing in the URI part of an EQName
-
Constructor Details
-
QNameParser
-
-
Method Details
-
withNamespaceResolver
Set the namespace resolver to be used- Parameters:
resolver
- the namespace resolver- Returns:
- a new QNameParser using the specified NamespaceResolver
-
withAcceptEQName
Say whether URI-qualified names inQ{uri}local
format should be accepted- Parameters:
acceptEQName
- true if extended QName syntax is accepted- Returns:
- a new QNameParser with the requested properties
-
withErrorOnBadSyntax
Say what error code should be thrown when the QName syntax is invalid- Parameters:
code
- the error code to be thrown- Returns:
- a new QNameParser with the requested properties
-
withErrorOnUnresolvedPrefix
Say what error code should be thrown when the prefix is undeclared- Parameters:
code
- the error code to be thrown- Returns:
- a new QNameParser with the requested properties
-
withUnescaper
Supply a callback used to unescape special characters appearing in the URI part of an EQName- Parameters:
unescaper
- the callback to be used- Returns:
- a new QNameParser with the requested properties
-
parse
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)defaultNS
- the default namespace to use if there is no prefix- 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.
-