Saxon.Api
Class QName
-
public class QName
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.
Note that a QName
is not itself an XdmItem
in this model; however it can
be converted to an XdmAtomicValue
.
Field Summary |
|
---|---|
static QName | XS_ANYURI QName constant for the name xs:anyURI |
static QName | XS_BOOLEAN QName constant for the name xs:boolean |
static QName | XS_DECIMAL QName constant for the name xs:decimal |
static QName | XS_DOUBLE QName constant for the name xs:double |
static QName | XS_FLOAT QName constant for the name xs:float |
static QName | XS_INTEGER QName constant for the name xs:integer |
static QName | XS_QNAME QName constant for the name xs:QName |
static QName | XS_STRING QName constant for the name xs:string |
static QName | XS_UNTYPED_ATOMIC QName constant for the name xs:untypedAtomic |
Constructor Summary |
|
---|---|
QName (string local)
Construct a |
|
QName (string uri, string lexical)
Construct a |
|
QName (string prefix, string uri, string local)
Construct a |
|
QName (string lexicalQName, XdmNode element)
Construct a |
|
QName (XmlQualifiedName qualifiedName)
Construct a |
Property Summary |
|
---|---|
string | ClarkName Get 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 |
string | EQName Get the expanded name in EQName format, that is |
string | LocalName Get the local part of the |
string | Prefix Get the prefix of the |
string | Uri Get the namespace URI of the |
Method Summary |
|
---|---|
bool | 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. |
static QName | FromClarkName (string expandedName)
Factory method to construct a |
static QName | FromEQName (string expandedName)
Factory method to construct a |
int | GetHashCode ()
Get a hash code for the |
net.sf.saxon.om.StructuredQName | GetStructuredQName ()
Convert the value to an |
bool | IsValid ()
Validate the |
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. |
XmlQualifiedName | ToXmlQualifiedName ()
Convert the value to an |
Field Detail
XS_UNTYPED_ATOMIC
QName constant for the name xs:untypedAtomic
Constructor Detail
QName
Construct a QName
representing a name in no namespace
This constructor does not check that the components of the QName are lexically valid.
Parameters:
local
- 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 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.
local
- The local part of the nameQName
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="..."
.
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:
QName
Construct a QName
from an XmlQualifiedName
(as defined in the
System.Xml
package).
Note that an XmlQualifiedName
does not contain any prefix, so the result
will always have a prefix of ""
Parameters:
qualifiedName
- The XmlQualifiedName
Property Detail
ClarkName
Get 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.
EQName
Get the expanded name in EQName format, that is Q{uri}local
. A no-namespace name is returned as Q{}local
.
Prefix
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.
Uri
Get the namespace URI of the QName
. Returns "" (the zero-length string) if the
QName is not in a namespace.
Method Detail
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 simply local
if not.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 QName in EQName notation: Q{uri}local
.
For a name in no namespace, either of the
forms Q{}local
or simply local
are accepted.Returns:
GetHashCode
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.
The algorithm for allocating a hash code does not depend on registering the QName
with the Processor
.
GetStructuredQName
Convert the value to an StructuredQName
, which is the representation
Saxon uses internally.
IsValid
Validate the QName
against the XML rules for valid names.
Returns:
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.
ToXmlQualifiedName
Convert the value to an XmlQualifiedName
(as defined in the
System.Xml
package)
Note that this loses the prefix.
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.
Parameters:
other
- The value to be compared with thisQName
. If this value is not aQName
, the result is always false. Otherwise, it is true if the namespace URI and local name both match.