Class QName
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
FieldsModifier and TypeFieldDescriptionstatic final QName
QName denoting the schema type xs:anyAtomicType *static final QName
QName denoting the schema type xs:anyURI *static final QName
QName denoting the schema type xs:base64Binary *static final QName
QName denoting the schema type xs:boolean *static final QName
QName denoting the schema type xs:byte *static final QName
QName denoting the schema type xs:date *static final QName
QName denoting the schema type xs:dateTime *static final QName
QName denoting the schema type xs:dateTimeStamp *static final QName
QName denoting the schema type xs:dayTimeDuration *static final QName
QName denoting the schema type xs:decimal *static final QName
QName denoting the schema type xs:double *static final QName
QName denoting the schema type xs:duration *static final QName
QName denoting the schema type xs:ENTITIES *static final QName
QName denoting the schema type xs:ENTITY *static final QName
QName denoting the schema type xs:float *static final QName
QName denoting the schema type xs:gDay *static final QName
QName denoting the schema type xs:gMonth *static final QName
QName denoting the schema type xs:gMonthDay *static final QName
QName denoting the schema type xs:gYear *static final QName
QName denoting the schema type xs:gYearMonth *static final QName
QName denoting the schema type xs:hexBinary *static final QName
QName denoting the schema type xs:ID *static final QName
QName denoting the schema type xs:IDREF *static final QName
QName denoting the schema type xs:IDREFS *static final QName
QName denoting the schema type xs:int *static final QName
QName denoting the schema type xs:integer *static final QName
QName denoting the schema type xs:language *static final QName
QName denoting the schema type xs:long *static final QName
QName denoting the schema type xs:Name *static final QName
QName denoting the schema type xs:NCName *static final QName
QName denoting the schema type xs:negativeInteger *static final QName
QName denoting the schema type xs:NMTOKEN *static final QName
QName denoting the schema type xs:NMTOKENS *static final QName
QName denoting the schema type xs:nonNegativeInteger *static final QName
QName denoting the schema type xs:nonPositiveInteger *static final QName
QName denoting the schema type xs:normalizedString *static final QName
QName denoting the schema type xs:NOTATION *static final QName
QName denoting the schema type xs:positiveInteger *static final QName
QName denoting the schema type xs:QName *static final QName
QName denoting the schema type xs:short *static final QName
QName denoting the schema type xs:string *static final QName
QName denoting the schema type xs:time *static final QName
QName denoting the schema type xs:token *static final QName
QName denoting the schema type xs:unsignedByte *static final QName
QName denoting the schema type xs:unsignedInt *static final QName
QName denoting the schema type xs:unsignedLong *static final QName
QName denoting the schema type xs:unsignedShort *static final QName
QName denoting the schema type xs:untyped *static final QName
QName denoting the schema type xs:untypedAtomic *static final QName
QName denoting the schema type xs:yearMonthDuration * -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a QName from a localName alone.Construct a QName using a namespace URI and a lexical representation.Construct a QName using a namespace prefix, a namespace URI, and a local name (in that order).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.Construct a QName from a JAXP QName objectQName
(NamespaceUri uri, String lexical) Construct a QName using a namespace URI and a lexical representation.QName
(StructuredQName sqName) Construct a QName from a StructuredQName -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether two QNames are equal.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
static QName
fromEQName
(String expandedName) Factory method to construct a QName from a string containing the expanded QName in EQName notation, that is,Q{uri}local
The expanded name, as a string using the notation devised by James Clark.The local part of the QNameThe namespace URI of the QName, as a string.The namespace URI of the QName.Deprecated.Get the prefix of the QName.Get the underlying StructuredQNameint
hashCode()
Get a hash code for the QName, to support equality matching.boolean
Validate the QName against the XML 1.0 or XML 1.1 rules for valid names.toString()
Convert the value to a string.
-
Field Details
-
XS_STRING
QName denoting the schema type xs:string * -
XS_BOOLEAN
QName denoting the schema type xs:boolean * -
XS_DECIMAL
QName denoting the schema type xs:decimal * -
XS_FLOAT
QName denoting the schema type xs:float * -
XS_DOUBLE
QName denoting the schema type xs:double * -
XS_DURATION
QName denoting the schema type xs:duration * -
XS_DATE_TIME
QName denoting the schema type xs:dateTime * -
XS_TIME
QName denoting the schema type xs:time * -
XS_DATE
QName denoting the schema type xs:date * -
XS_G_YEAR_MONTH
QName denoting the schema type xs:gYearMonth * -
XS_G_YEAR
QName denoting the schema type xs:gYear * -
XS_G_MONTH_DAY
QName denoting the schema type xs:gMonthDay * -
XS_G_DAY
QName denoting the schema type xs:gDay * -
XS_G_MONTH
QName denoting the schema type xs:gMonth * -
XS_HEX_BINARY
QName denoting the schema type xs:hexBinary * -
XS_BASE64_BINARY
QName denoting the schema type xs:base64Binary * -
XS_ANY_URI
QName denoting the schema type xs:anyURI * -
XS_QNAME
QName denoting the schema type xs:QName * -
XS_NOTATION
QName denoting the schema type xs:NOTATION * -
XS_INTEGER
QName denoting the schema type xs:integer * -
XS_NON_POSITIVE_INTEGER
QName denoting the schema type xs:nonPositiveInteger * -
XS_NEGATIVE_INTEGER
QName denoting the schema type xs:negativeInteger * -
XS_LONG
QName denoting the schema type xs:long * -
XS_INT
QName denoting the schema type xs:int * -
XS_SHORT
QName denoting the schema type xs:short * -
XS_BYTE
QName denoting the schema type xs:byte * -
XS_NON_NEGATIVE_INTEGER
QName denoting the schema type xs:nonNegativeInteger * -
XS_POSITIVE_INTEGER
QName denoting the schema type xs:positiveInteger * -
XS_UNSIGNED_LONG
QName denoting the schema type xs:unsignedLong * -
XS_UNSIGNED_INT
QName denoting the schema type xs:unsignedInt * -
XS_UNSIGNED_SHORT
QName denoting the schema type xs:unsignedShort * -
XS_UNSIGNED_BYTE
QName denoting the schema type xs:unsignedByte * -
XS_NORMALIZED_STRING
QName denoting the schema type xs:normalizedString * -
XS_TOKEN
QName denoting the schema type xs:token * -
XS_LANGUAGE
QName denoting the schema type xs:language * -
XS_NMTOKEN
QName denoting the schema type xs:NMTOKEN * -
XS_NMTOKENS
QName denoting the schema type xs:NMTOKENS * -
XS_NAME
QName denoting the schema type xs:Name * -
XS_NCNAME
QName denoting the schema type xs:NCName * -
XS_ID
QName denoting the schema type xs:ID * -
XS_IDREF
QName denoting the schema type xs:IDREF * -
XS_IDREFS
QName denoting the schema type xs:IDREFS * -
XS_ENTITY
QName denoting the schema type xs:ENTITY * -
XS_ENTITIES
QName denoting the schema type xs:ENTITIES * -
XS_UNTYPED
QName denoting the schema type xs:untyped * -
XS_UNTYPED_ATOMIC
QName denoting the schema type xs:untypedAtomic * -
XS_ANY_ATOMIC_TYPE
QName denoting the schema type xs:anyAtomicType * -
XS_YEAR_MONTH_DURATION
QName denoting the schema type xs:yearMonthDuration * -
XS_DAY_TIME_DURATION
QName denoting the schema type xs:dayTimeDuration * -
XS_DATE_TIME_STAMP
QName denoting the schema type xs:dateTimeStamp *
-
-
Constructor Details
-
QName
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
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
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. UseNamespaceUri.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- Since:
- 12.3
-
QName
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
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 formprefix:local
or simplylocal
. The EQName syntax "Q{uri}local" and the ClarkName syntax "{uri}local" are also accepted.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
Construct a QName from a JAXP QName object- Parameters:
qName
- the JAXP QName object
-
QName
Construct a QName from a StructuredQName- Parameters:
sqName
- the StructuredQName
-
-
Method Details
-
fromClarkName
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 simplylocal
if not.- Returns:
- the QName corresponding to the supplied name in Clark notation. This will always have an empty prefix.
- Throws:
IllegalArgumentException
- if the format of the supplied name is incorrect
-
fromEQName
Factory method to construct a QName from a string containing the expanded QName in EQName notation, that is,Q{uri}local
The prefix part of the
QName
will be set to an empty string.- Parameters:
expandedName
- The URI in EQName notation:Q{uri}local
if the name is in a namespace. For a name in no namespace, either of the formsQ{}local
or simplylocal
are accepted.- Returns:
- the QName corresponding to the supplied name in EQName notation. This will always have an empty prefix.
-
isValid
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 was at one time used to determine whether the XML 1.0 or XML 1.1 rules for forming names are used. However, the XML 1.0 and 1.1 rules are now aligned, so this argument is no longer used.- Returns:
- true if the name is valid, false if not
-
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
-
getNamespace
The namespace URI of the QName, as a string. 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
-
getNamespaceURI
Deprecated.since 12.0 - usegetNamespaceUri()
orgetNamespace()
The namespace URI of the QName, as a string. Returns the zero-length string if the QName is not in a namespace.Retained for backwards compatibility; deprecated.
- Returns:
- the namespace part of the QName, or "" for a name in no namespace
-
getNamespaceUri
The namespace URI of the QName. ReturnsNamespaceUri.NULL
(the zero-length string) if the QName is not in a namespace.- Returns:
- the namespace part of the QName, or NamespaceUri#NULL for a name in no namespace
-
getLocalName
The local part of the QName- Returns:
- the local part of the QName
-
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.
-
getEQName
-
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. -
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. -
equals
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. -
getStructuredQName
Get the underlying StructuredQName- Returns:
- the underlying StructuredQName
-
getNamespaceUri()
orgetNamespace()