net.sf.saxon.s9api

Class QName

public class QName extends Object

The QName class represents an instance of xs:QName, as defined in the XPath 2.0 data model. Internally, it has three components, a namespace URI, a local name, and a prefix. The prefix is intended to be used only when converting the value back to a string.

This class also defines a number of QName-valued constants relating to built-in types in XML Schema

A QName is immutable.

Note that a QName is not itself an XdmItem in this model; however it can be wrapped in an XdmItem.

Field Summary
static QNameXS_ANY_ATOMIC_TYPE
QName denoting the schema type xs:anyAtomicType *
static QNameXS_ANY_URI
QName denoting the schema type xs:anyURI *
static QNameXS_BASE64_BINARY
QName denoting the schema type xs:base64Binary *
static QNameXS_BOOLEAN
QName denoting the schema type xs:boolean *
static QNameXS_BYTE
QName denoting the schema type xs:byte *
static QNameXS_DATE
QName denoting the schema type xs:date *
static QNameXS_DATE_TIME
QName denoting the schema type xs:dateTime *
static QNameXS_DATE_TIME_STAMP
QName denoting the schema type xs:dateTimeStamp *
static QNameXS_DAY_TIME_DURATION
QName denoting the schema type xs:dayTimeDuration *
static QNameXS_DECIMAL
QName denoting the schema type xs:decimal *
static QNameXS_DOUBLE
QName denoting the schema type xs:double *
static QNameXS_DURATION
QName denoting the schema type xs:duration *
static QNameXS_ENTITIES
QName denoting the schema type xs:ENTITIES *
static QNameXS_ENTITY
QName denoting the schema type xs:ENTITY *
static QNameXS_FLOAT
QName denoting the schema type xs:float *
static QNameXS_G_DAY
QName denoting the schema type xs:gDay *
static QNameXS_G_MONTH
QName denoting the schema type xs:gMonth *
static QNameXS_G_MONTH_DAY
QName denoting the schema type xs:gMonthDay *
static QNameXS_G_YEAR
QName denoting the schema type xs:gYear *
static QNameXS_G_YEAR_MONTH
QName denoting the schema type xs:gYearMonth *
static QNameXS_HEX_BINARY
QName denoting the schema type xs:hexBinary *
static QNameXS_ID
QName denoting the schema type xs:ID *
static QNameXS_IDREF
QName denoting the schema type xs:IDREF *
static QNameXS_IDREFS
QName denoting the schema type xs:IDREFS *
static QNameXS_INT
QName denoting the schema type xs:int *
static QNameXS_INTEGER
QName denoting the schema type xs:integer *
static QNameXS_LANGUAGE
QName denoting the schema type xs:language *
static QNameXS_LONG
QName denoting the schema type xs:long *
static QNameXS_NAME
QName denoting the schema type xs:Name *
static QNameXS_NCNAME
QName denoting the schema type xs:NCName *
static QNameXS_NEGATIVE_INTEGER
QName denoting the schema type xs:negativeInteger *
static QNameXS_NMTOKEN
QName denoting the schema type xs:NMTOKEN *
static QNameXS_NMTOKENS
QName denoting the schema type xs:NMTOKENS *
static QNameXS_NON_NEGATIVE_INTEGER
QName denoting the schema type xs:nonNegativeInteger *
static QNameXS_NON_POSITIVE_INTEGER
QName denoting the schema type xs:nonPositiveInteger *
static QNameXS_NORMALIZED_STRING
QName denoting the schema type xs:normalizedString *
static QNameXS_NOTATION
QName denoting the schema type xs:NOTATION *
static QNameXS_POSITIVE_INTEGER
QName denoting the schema type xs:positiveInteger *
static QNameXS_QNAME
QName denoting the schema type xs:QName *
static QNameXS_SHORT
QName denoting the schema type xs:short *
static QNameXS_STRING
QName denoting the schema type xs:string *
static QNameXS_TIME
QName denoting the schema type xs:time *
static QNameXS_TOKEN
QName denoting the schema type xs:token *
static QNameXS_UNSIGNED_BYTE
QName denoting the schema type xs:unsignedByte *
static QNameXS_UNSIGNED_INT
QName denoting the schema type xs:unsignedInt *
static QNameXS_UNSIGNED_LONG
QName denoting the schema type xs:unsignedLong *
static QNameXS_UNSIGNED_SHORT
QName denoting the schema type xs:unsignedShort *
static QNameXS_UNTYPED
QName denoting the schema type xs:untyped *
static QNameXS_UNTYPED_ATOMIC
QName denoting the schema type xs:untypedAtomic *
static QNameXS_YEAR_MONTH_DURATION
QName denoting the schema type xs:yearMonthDuration *
Constructor Summary
QName(String prefix, String uri, String localName)
Construct a QName using a namespace prefix, a namespace URI, and a local name (in that order).
QName(String uri, String lexical)
Construct a QName using a namespace URI and a lexical representation.
QName(String localName)
Construct a QName from a localName alone.
QName(String lexicalQName, XdmNode element)
Construct a QName from a lexical QName, supplying an element node whose in-scope namespaces are to be used to resolve any prefix contained in the QName.
QName(QName qName)
Construct a QName from a JAXP QName object
protected QName(StructuredQName sqName)
Protected constructor accepting a StructuredQName
Method Summary
booleanequals(Object other)
Test whether two QNames are equal.
static QNamefromClarkName(String expandedName)
Factory method to construct a QName from a string containing the expanded QName in Clark notation, that is, {uri}local

The prefix part of the QName will be set to an empty string.

StringgetClarkName()
The expanded name, as a string using the notation devised by James Clark.
StringgetLocalName()
The local part of the QName
StringgetNamespaceURI()
The namespace URI of the QName.
StringgetPrefix()
Get the prefix of the QName.
protected StructuredQNamegetStructuredQName()
Get the underlying StructuredQName
inthashCode()
Get a hash code for the QName, to support equality matching.
booleanisValid(Processor processor)
Validate the QName against the XML 1.0 or XML 1.1 rules for valid names.
StringtoString()
Convert the value to a string.

Field Detail

XS_ANY_ATOMIC_TYPE

public static final QName XS_ANY_ATOMIC_TYPE
QName denoting the schema type xs:anyAtomicType *

XS_ANY_URI

public static final QName XS_ANY_URI
QName denoting the schema type xs:anyURI *

XS_BASE64_BINARY

public static final QName XS_BASE64_BINARY
QName denoting the schema type xs:base64Binary *

XS_BOOLEAN

public static final QName XS_BOOLEAN
QName denoting the schema type xs:boolean *

XS_BYTE

public static final QName XS_BYTE
QName denoting the schema type xs:byte *

XS_DATE

public static final QName XS_DATE
QName denoting the schema type xs:date *

XS_DATE_TIME

public static final QName XS_DATE_TIME
QName denoting the schema type xs:dateTime *

XS_DATE_TIME_STAMP

public static final QName XS_DATE_TIME_STAMP
QName denoting the schema type xs:dateTimeStamp *

XS_DAY_TIME_DURATION

public static final QName XS_DAY_TIME_DURATION
QName denoting the schema type xs:dayTimeDuration *

XS_DECIMAL

public static final QName XS_DECIMAL
QName denoting the schema type xs:decimal *

XS_DOUBLE

public static final QName XS_DOUBLE
QName denoting the schema type xs:double *

XS_DURATION

public static final QName XS_DURATION
QName denoting the schema type xs:duration *

XS_ENTITIES

public static final QName XS_ENTITIES
QName denoting the schema type xs:ENTITIES *

XS_ENTITY

public static final QName XS_ENTITY
QName denoting the schema type xs:ENTITY *

XS_FLOAT

public static final QName XS_FLOAT
QName denoting the schema type xs:float *

XS_G_DAY

public static final QName XS_G_DAY
QName denoting the schema type xs:gDay *

XS_G_MONTH

public static final QName XS_G_MONTH
QName denoting the schema type xs:gMonth *

XS_G_MONTH_DAY

public static final QName XS_G_MONTH_DAY
QName denoting the schema type xs:gMonthDay *

XS_G_YEAR

public static final QName XS_G_YEAR
QName denoting the schema type xs:gYear *

XS_G_YEAR_MONTH

public static final QName XS_G_YEAR_MONTH
QName denoting the schema type xs:gYearMonth *

XS_HEX_BINARY

public static final QName XS_HEX_BINARY
QName denoting the schema type xs:hexBinary *

XS_ID

public static final QName XS_ID
QName denoting the schema type xs:ID *

XS_IDREF

public static final QName XS_IDREF
QName denoting the schema type xs:IDREF *

XS_IDREFS

public static final QName XS_IDREFS
QName denoting the schema type xs:IDREFS *

XS_INT

public static final QName XS_INT
QName denoting the schema type xs:int *

XS_INTEGER

public static final QName XS_INTEGER
QName denoting the schema type xs:integer *

XS_LANGUAGE

public static final QName XS_LANGUAGE
QName denoting the schema type xs:language *

XS_LONG

public static final QName XS_LONG
QName denoting the schema type xs:long *

XS_NAME

public static final QName XS_NAME
QName denoting the schema type xs:Name *

XS_NCNAME

public static final QName XS_NCNAME
QName denoting the schema type xs:NCName *

XS_NEGATIVE_INTEGER

public static final QName XS_NEGATIVE_INTEGER
QName denoting the schema type xs:negativeInteger *

XS_NMTOKEN

public static final QName XS_NMTOKEN
QName denoting the schema type xs:NMTOKEN *

XS_NMTOKENS

public static final QName XS_NMTOKENS
QName denoting the schema type xs:NMTOKENS *

XS_NON_NEGATIVE_INTEGER

public static final QName XS_NON_NEGATIVE_INTEGER
QName denoting the schema type xs:nonNegativeInteger *

XS_NON_POSITIVE_INTEGER

public static final QName XS_NON_POSITIVE_INTEGER
QName denoting the schema type xs:nonPositiveInteger *

XS_NORMALIZED_STRING

public static final QName XS_NORMALIZED_STRING
QName denoting the schema type xs:normalizedString *

XS_NOTATION

public static final QName XS_NOTATION
QName denoting the schema type xs:NOTATION *

XS_POSITIVE_INTEGER

public static final QName XS_POSITIVE_INTEGER
QName denoting the schema type xs:positiveInteger *

XS_QNAME

public static final QName XS_QNAME
QName denoting the schema type xs:QName *

XS_SHORT

public static final QName XS_SHORT
QName denoting the schema type xs:short *

XS_STRING

public static final QName XS_STRING
QName denoting the schema type xs:string *

XS_TIME

public static final QName XS_TIME
QName denoting the schema type xs:time *

XS_TOKEN

public static final QName XS_TOKEN
QName denoting the schema type xs:token *

XS_UNSIGNED_BYTE

public static final QName XS_UNSIGNED_BYTE
QName denoting the schema type xs:unsignedByte *

XS_UNSIGNED_INT

public static final QName XS_UNSIGNED_INT
QName denoting the schema type xs:unsignedInt *

XS_UNSIGNED_LONG

public static final QName XS_UNSIGNED_LONG
QName denoting the schema type xs:unsignedLong *

XS_UNSIGNED_SHORT

public static final QName XS_UNSIGNED_SHORT
QName denoting the schema type xs:unsignedShort *

XS_UNTYPED

public static final QName XS_UNTYPED
QName denoting the schema type xs:untyped *

XS_UNTYPED_ATOMIC

public static final QName XS_UNTYPED_ATOMIC
QName denoting the schema type xs:untypedAtomic *

XS_YEAR_MONTH_DURATION

public static final QName XS_YEAR_MONTH_DURATION
QName denoting the schema type xs:yearMonthDuration *

Constructor Detail

QName

public QName(String prefix, String uri, String localName)
Construct a QName using a namespace prefix, a namespace URI, and a local name (in that order).

This constructor does not check that the components of the QName are lexically valid.

Parameters: prefix The prefix of the name. Use either the string "" or null for names that have no prefix (that is, they are in the default namespace) uri The namespace URI. Use either the string "" or null for names that are not in any namespace. localName The local part of the name

QName

public QName(String uri, String lexical)
Construct a QName using a namespace URI and a lexical representation. The lexical representation may be a local name on its own, or it may be in the form prefix:local-name.

This constructor does not check that the components of the QName are lexically valid.

Parameters: uri The namespace URI. Use either the string "" or null for names that are not in any namespace. lexical Either the local part of the name, or the prefix and local part in the format prefix:local

QName

public QName(String localName)
Construct a QName from a localName alone. The localName must not contain a colon. The resulting QName represents a name in no namespace (which therefore has no prefix)

Parameters: localName The local name. This must be a valid NCName, in particular it must contain no colon

QName

public QName(String lexicalQName, XdmNode element)
Construct a QName from a lexical QName, supplying an element node whose in-scope namespaces are to be used to resolve any prefix contained in the QName.

This constructor checks that the components of the QName are lexically valid.

If the lexical QName has no prefix, the name is considered to be in the default namespace, as defined by xmlns="...".

If the prefix of the lexical QName is not in scope, returns null.

Parameters: lexicalQName The lexical QName, in the form prefix:local or simply local. element The element node whose in-scope namespaces are to be used to resolve the prefix part of the lexical QName.

Throws: IllegalArgumentException If the prefix of the lexical QName is not in scope or if the lexical QName is invalid (for example, if it contains invalid characters)

QName

public QName(QName qName)
Construct a QName from a JAXP QName object

Parameters: qName the JAXP QName object

QName

protected QName(StructuredQName sqName)
Protected constructor accepting a StructuredQName

Parameters: sqName the StructuredQName

Method Detail

equals

public boolean equals(Object other)
Test whether two QNames are equal. This supports the semantics of equality, which considers only the namespace URI and local name, and not the prefix.

Returns: true if the namespace URIs are equal and the local parts are equal, when compared character-by-character.

fromClarkName

public static QName fromClarkName(String expandedName)
Factory method to construct a QName from a string containing the expanded QName in Clark notation, that is, {uri}local

The prefix part of the QName will be set to an empty string.

Parameters: expandedName The URI in Clark notation: {uri}local if the name is in a namespace, or simply local if not.

Returns: the QName corresponding to the supplied name in Clark notation. This will always have an empty prefix.

getClarkName

public String getClarkName()
The expanded name, as a string using the notation devised by James Clark. If the name is in a namespace, the resulting string takes the form {uri}local. Otherwise, the value is the local part of the name.

Returns: the name in Clark notation. If the name is not in a namespace, returns the local part of the name. Otherwise returns the concatenation of "{", the namespace part of the QName, "}", and the local part of the QName.

getLocalName

public String getLocalName()
The local part of the QName

Returns: the local part of the QName

getNamespaceURI

public String getNamespaceURI()
The namespace URI of the QName. Returns "" (the zero-length string) if the QName is not in a namespace.

Returns: the namespace part of the QName, or "" for a name in no namespace

getPrefix

public String getPrefix()
Get the prefix of the QName. This plays no role in operations such as comparison of QNames for equality, but is retained (as specified in XPath) so that a string representation can be reconstructed.

Returns the zero-length string in the case of a QName that has no prefix.

Returns: the prefix part of the QName, or "" if the name has no known prefix

getStructuredQName

protected StructuredQName getStructuredQName()
Get the underlying StructuredQName

Returns: the underlying StructuredQName

hashCode

public int hashCode()
Get a hash code for the QName, to support equality matching. This supports the semantics of equality, which considers only the namespace URI and local name, and not the prefix.

Returns: a hashCode for the QName

isValid

public boolean isValid(Processor processor)
Validate the QName against the XML 1.0 or XML 1.1 rules for valid names.

Parameters: processor The Processor in which the name is to be validated. This determines whether the XML 1.0 or XML 1.1 rules for forming names are used.

Returns: true if the name is valid, false if not

toString

public String toString()
Convert the value to a string. The resulting string is the lexical form of the QName, using the original prefix if there was one.