Package net.sf.saxon.om
Class QNameParser
- java.lang.Object
-
- net.sf.saxon.om.QNameParser
-
public class QNameParser extends java.lang.ObjectParser 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 thewithProperty()fluent API style.
-
-
Constructor Summary
Constructors Constructor Description QNameParser(NamespaceResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StructuredQNameparse(java.lang.CharSequence lexicalName, java.lang.String defaultNS)Make a structured QName from a lexical QName, using a supplied NamespaceResolver to resolve the prefix.QNameParserwithAcceptEQName(boolean acceptEQName)Say whether URI-qualified names inQ{uri}localformat should be acceptedQNameParserwithErrorOnBadSyntax(java.lang.String code)Say what error code should be thrown when the QName syntax is invalidQNameParserwithErrorOnUnresolvedPrefix(java.lang.String code)Say what error code should be thrown when the prefix is undeclaredQNameParserwithNamespaceResolver(NamespaceResolver resolver)Set the namespace resolver to be usedQNameParserwithUnescaper(XQueryParser.Unescaper unescaper)Supply a callback used to unescape special characters appearing in the URI part of an EQName
-
-
-
Constructor Detail
-
QNameParser
public QNameParser(NamespaceResolver resolver)
-
-
Method Detail
-
withNamespaceResolver
public QNameParser withNamespaceResolver(NamespaceResolver resolver)
Set the namespace resolver to be used- Parameters:
resolver- the namespace resolver- Returns:
- a new QNameParser using the specified NamespaceResolver
-
withAcceptEQName
public QNameParser withAcceptEQName(boolean acceptEQName)
Say whether URI-qualified names inQ{uri}localformat should be accepted- Parameters:
acceptEQName- true if extended QName syntax is accepted- Returns:
- a new QNameParser with the requested properties
-
withErrorOnBadSyntax
public QNameParser withErrorOnBadSyntax(java.lang.String code)
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
public QNameParser withErrorOnUnresolvedPrefix(java.lang.String code)
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
public QNameParser withUnescaper(XQueryParser.Unescaper unescaper)
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
public StructuredQName parse(java.lang.CharSequence lexicalName, java.lang.String defaultNS) 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)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.
-
-