The id() Function

Release 2.0 - ...

Syntax

  CopyCode image Copy Code
node-set id(object, node-set?)

Description

The object parameter provides one or more IDREFs. This may be in the form of a string containing a space-separated list of IDREFs or a node-set, each node of which contains an IDREF. The node-set parameter provides nodes in one or more instance data documents to be searched. If the node-set parameter is not given or is empty, then the instance data document to be searched is the one containing the context node of the function call. For each node in the node-set parameter (or its default), the set of element nodes are collected with IDs that match the IDREFs from the object parameter.

The result of this function is a node-set containing the union of the collected element nodes from each string. An element node can be assigned an ID by means of an xml:id attribute or an attribute that is assigned the type ID by a DTD or xsd:ID or any type derived from xsd:ID by an XML schema, or the type model item property.

Example

XML CopyCode image Copy Code
<xforms:model >
   <xforms:instance xmlns="">
      <root>
         <level_1a>
            <level_1achild xml:id="a">Node-A</level_1achild>
            <level_1achild xml:id="d">Node-D</level_1achild>
         </level_1a>
         <level_1b>
            <level_1bchild xml:id="b">Node-B</level_1bchild>
            <level_1bchild xml:id="f">Node-F</level_1bchild>
            <level_1bchild xml:id="c">Node-C</level_1bchild>
         </level_1b>
      </root>
   </xforms:instance>
</xforms:model>
...
<xforms:repeat nodeset="id('a b c')">
   <xforms:output ref=".">
      <xforms:label>Node Values : </xforms:label>
   </xforms:output>
</xforms:repeat>

The above example will display the node values Node-A, Node-B and Node-C.

Specification

Link to the XForms specification: the id() function.