xs:QName
The primitive type xs:QName represents an XML namespace-qualified name. In XQuery, xs:QName values have three parts: the full namespace URI, the local part of the name, and the prefix. The namespace and the prefix are optional. If a QName does not have a namespace associated with it, it is considered to be in "no namespace."
When used in a query or schema, the lexical representation of an xs:QName has just two parts: an optional prefix and the local part of the name. Based on the prefix, the context is used to determine the namespace URI. If the prefix is not present, either the name is in the default namespace or it is in no namespace at all.
Table B-19 lists some values of the xs:QName type.
Table B-19. Values of the xs:QName type
|
Values |
Explanation |
|---|---|
|
Valid | |
prod:number |
Valid assuming the prefix |
number |
Prefix and colon are optional |
|
Invalid | |
:number |
An |
prod:3rdnumber |
The local part must not start with a number; it must be a valid |
|
An empty value or zero-length string is not permitted |
The prefix itself has no meaning; it is just a placeholder. However, the XQuery processor does keep track of a QName's prefix. This simplifies certain processes such as serializing QNames and casting them to strings.
One of the most common ways of getting an xs:QName is to use the node-name function, which returns the name of an element or attribute as an xs:QName value.
The xs:QName type has a standard ...