5 Accessors

A set of accessors is defined on nodes in the data model. For consistency, all the accessors are defined on every kind of node, although several accessors return a constant empty sequence on some kinds of nodes.

In order for processors to be able to operate on instances of the data model, the model must expose the properties of the items it contains. The data model does this by defining a family of accessor functions. These are not functions in the literal sense; they are not available for users or applications to call directly. Rather they are descriptions of the information that an implementation of the data model must expose to applications. Functions and operators available to end-users are described in [XQuery and XPath Functions and Operators 4.0].

Some typed values in the data model are absent. Attempting to access an absent typed value is an error. Behavior in these cases is implementation-defined and the host language is responsible for determining the result.

5.1 attributes Accessor

dm:attributes($n as node()) as attribute()*

The dm:attributes accessor returns the attributes of a node as a sequence containing zero or more Attribute Nodes. The order of Attribute Nodes is stable but implementation dependent.

It is defined on all seven node kinds.

5.2 base-uri Accessor

dm:base-uri($n as node()) as xs:anyURI?

The dm:base-uri accessor returns the base URI of a node as a sequence containing zero or one URI reference. For more information about base URIs, see [XML Base].

It is defined on all seven node kinds.

5.3 children Accessor

dm:children($n as node()) as node()*

The dm:children accessor returns the children of a node as a sequence containing zero or more nodes.

It is defined on all seven node kinds.

5.4 document-uri Accessor

dm:document-uri($node as node()) as xs:anyURI?

The dm:document-uri accessor returns the absolute URI of the resource from which the Document Node was constructed, if the absolute URI is available. If there is no URI available, or if it cannot be made absolute when the Document Node is constructed, or if it is used on a node other than a Document Node, the empty sequence is returned.

It is defined on all seven node kinds.

5.5 is-id Accessor

dm:is-id($node as node()) as xs:boolean?

The dm:is-id accessor returns true if the node is an XML ID. Exactly what constitutes an ID depends in part on how the data model was constructed, see 6.2 Element Nodes and 6.3 Attribute Nodes.

It is defined on all seven node kinds.

5.6 is-idrefs Accessor

dm:is-idrefs($node as node()) as xs:boolean?

The dm:is-idrefs accessor returns true if the node is an XML IDREF or IDREFS. Exactly what constitutes an IDREF or IDREFS depends in part on how the data model was constructed, see 6.2 Element Nodes and 6.3 Attribute Nodes.

It is defined on all seven node kinds.

5.7 namespace-nodes Accessor

dm:namespace-nodes($n as node()) as node()*

The dm:namespace-nodes accessor returns the dynamic, in-scope namespaces associated with a node as a sequence containing zero or more Namespace Nodes. The order of Namespace Nodes is stable but implementation dependent.

It is defined on all seven node kinds.

5.8 nilled Accessor

dm:nilled($n as node()) as xs:boolean?

The dm:nilled accessor returns true if the node is "nilled". [Schema Part 1] introduced the nilled mechanism to signal that an element should be accepted as valid when it has no content even when it has a content type which does not require or even necessarily allow empty content.

It is defined on all seven node kinds.

5.9 node-kind Accessor

dm:node-kind($n as node()) as xs:string

The dm:node-kind accessor returns a string identifying the kind of node. It will be one of the following, depending on the kind of node: “attribute”, “comment”, “document”, “element”, “namespace” “processing-instruction”, or “text”.

It is defined on all seven node kinds.

5.10 node-name Accessor

dm:node-name($n as node()) as xs:QName?

The dm:node-name accessor returns the name of the node as a sequence of zero or one xs:QNames. Note that the QName value includes an optional prefix as described in 3.3.3 QNames and NOTATIONS.

It is defined on all seven node kinds.

5.11 parent Accessor

dm:parent($n as node()) as node()?

The dm:parent accessor returns the parent of a node as a sequence containing zero or one nodes.

It is defined on all seven node kinds.

5.12 string-value Accessor

dm:string-value($n as node()) as xs:string

The dm:string-value accessor returns the string value of a node.

It is defined on all seven node kinds.

5.13 type-name Accessor

dm:type-name($n as node()) as xs:QName?

The dm:type-name accessor returns the name of the schema type of a node as a sequence of zero or one xs:QNames.

It is defined on all seven node kinds.

5.14 typed-value Accessor

dm:typed-value($n as node()) as xs:anyAtomicType*

The dm:typed-value accessor returns the typed-value of the node as a sequence of zero or more atomic values.

It is defined on all seven node kinds.

5.15 unparsed-entity-public-id Accessor

dm:unparsed-entity-public-id( $node  as node(),
$entityname  as xs:string) as xs:string?

The dm:unparsed-entity-public-id accessor returns the public identifier of an unparsed external entity declared in the specified document. If no entity with the name specified in $entityname exists, or if the entity is not an external unparsed entity, or if the entity has no public identifier, the empty sequence is returned.

It is defined on all seven node kinds.

5.16 unparsed-entity-system-id Accessor

dm:unparsed-entity-system-id( $node  as node(),
$entityname  as xs:string) as xs:anyURI?

The dm:unparsed-entity-system-id accessor returns the system identifier of an unparsed external entity declared in the specified document. The value is an absolute URI, and is obtained by resolving the [system identifier] of the unparsed entity information item against the [declaration base URI] of the same item. If no entity with the name specified in $entityname exists, or if the entity is not an external unparsed entity, the empty sequence is returned.

It is defined on all seven node kinds.