Package net.sf.saxon.value
Class QNameValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.QNameValue
- All Implemented Interfaces:
Serializable
,Expression
,Item
,ValueRepresentation
- Direct Known Subclasses:
NotationValue
A QName value. This implements the so-called "triples proposal", in which the prefix is retained as
part of the value. The prefix is not used in any operation on a QName other than conversion of the
QName to a string.
- See Also:
-
Field Summary
Fields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionQNameValue
(String prefix, String uri, String localName, NameChecker checker) Constructor.QNameValue
(NamePool namePool, int nameCode) Constructor -
Method Summary
Modifier and TypeMethodDescriptionint
allocateNameCode
(NamePool pool) Allocate a nameCode for this QName in the NamePoolconvertPrimitive
(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data typeconvertToJava
(Class target, XPathContext context) Convert to Java object (for passing to external functions)boolean
Determine if two QName values are equal.Get the name in Clark notation, that is {uri}localgetComponent
(int part) Get a component.Return the type of the expressionGet the local partGet the namespace part (null means no namespace)Get the prefixGet the string value as a String.int
hashCode()
Return a hash code to support the equals() functionstatic AtomicValue
makeQName
(String prefix, String uri, String local, AtomicType targetType, CharSequence lexicalForm, TypeHierarchy th) makeQName
(Configuration config) Temporary method to construct a javax.xml.namespace.QName without actually mentioning it by name (because the class is not available in JDK 1.4)toString()
The toString() method returns the name in the form QName("uri", "local")Methods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getLength, getPrimitiveValue, getStringValueCS, getTypedValue, hasBuiltInType, iterate, process
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
-
Constructor Details
-
QNameValue
Constructor- Parameters:
namePool
- The name pool containing the specified name codenameCode
- The name code identifying this name in the name pool
-
QNameValue
public QNameValue(String prefix, String uri, String localName, NameChecker checker) throws XPathException Constructor. This constructor validates that the local part is a valid NCName.- Parameters:
prefix
- The prefix part of the QName (not used in comparisons). Use null or "" to represent the default prefix. Note that the prefix is not checked for lexical correctness, because in most cases it will already have been matched against in-scope namespaces. Where necessary the caller must check the prefix.uri
- The namespace part of the QName. Use null or "" to represent the null namespace.localName
- The local part of the QNamechecker
- NameChecker used to check the name against XML 1.0 or XML 1.1 rules. Supply null if the name does not need to be checked (the caller asserts that it is known to be valid)- Throws:
XPathException
-
-
Method Details
-
makeQName
public static AtomicValue makeQName(String prefix, String uri, String local, AtomicType targetType, CharSequence lexicalForm, TypeHierarchy th) throws XPathException - Throws:
XPathException
-
getStringValue
Get the string value as a String. Returns the QName as a lexical QName, retaining the original prefix if available.- Specified by:
getStringValue
in interfaceItem
- Specified by:
getStringValue
in interfaceValueRepresentation
- Specified by:
getStringValue
in classAtomicValue
- Returns:
- the string value of the item
- See Also:
-
getClarkName
Get the name in Clark notation, that is {uri}local -
getLocalName
Get the local part -
getNamespaceURI
Get the namespace part (null means no namespace) -
getPrefix
Get the prefix -
allocateNameCode
Allocate a nameCode for this QName in the NamePool- Parameters:
pool
- the NamePool to be used- Returns:
- the allocated nameCode
-
getComponent
Get a component. Returns a zero-length string if the namespace-uri component is requested and is not present.- Overrides:
getComponent
in classAtomicValue
- Parameters:
part
- either Component.LOCALNAME or Component.NAMESPACE indicating which component of the value is required- Returns:
- either the local name or the namespace URI, in each case as a StringValue
-
convertPrimitive
public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data type- Specified by:
convertPrimitive
in classAtomicValue
- Parameters:
requiredType
- an integer identifying the required atomic typevalidate
- true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested.context
-- Returns:
- an AtomicValue, a value of the required type; or an ErrorValue
-
getItemType
Return the type of the expression- Specified by:
getItemType
in interfaceExpression
- Overrides:
getItemType
in classValue
- Parameters:
th
-- Returns:
- Type.QNAME (always)
-
equals
Determine if two QName values are equal. This comparison ignores the prefix part of the value.- Overrides:
equals
in classValue
- Throws:
ClassCastException
- if they are not comparableIllegalStateException
- if the two QNames are in different name pools
-
hashCode
public int hashCode()Description copied from class:Value
Return a hash code to support the equals() function -
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJava
in classValue
- Throws:
XPathException
-
toString
The toString() method returns the name in the form QName("uri", "local")- Overrides:
toString
in classAtomicValue
- Returns:
- the name in in the form QName("uri", "local")
-
makeQName
Temporary method to construct a javax.xml.namespace.QName without actually mentioning it by name (because the class is not available in JDK 1.4)
-