id() Function — Returns the node in the source tree whose ID attribute matches the value passed in as input.
An object. If the input object is a node-set, the result is a node-set that contains the result of applying the
id() function to the string value of each node in the argument node-set. Usually, the argument is some other node type, which is (or is converted to) a string. That string is then used as the search value while all attributes of type ID are searched.
Remember that a limitation of the XML
ID datatype is that a single set of names across all attributes is declared to be of type
ID. The XSLT
key() function and the associated
<xsl:key> element address this and other limitations; see the
key() function and
<xsl:key> for more information.
A node-set containing all nodes whose attributes of type
ID match the string values of the input node-set. In practice, this node-set is a single node, the node whose attribute of type
ID matches a string value.
XPath section 4.1, Node Set Functions.
For our example, we’ll take this shortened version of the glossary we discussed earlier:
<?xml version="1.0" ?> <!DOCTYPE glossary SYSTEM "glossary.dtd"> <glossary> <glentry> <term id="applet">applet</term> <defn> An application program, written in the Java programming language, that can be retrieved from a web server and executed by a web browser. A reference to an applet appears in the markup for a web page, in the same way that ...