O'Reilly logo

XSLT, 2nd Edition by Doug Tidwell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

id()

Returns the node in the source tree whose ID attribute matches the value(s) passed in as input.

Syntax

[1.0] node-set id(object)
[2.0] element()* id(xs:string*)
[2.0] element()* id(xs:string*, node())

Inputs

[1.0] 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.

[2.0] An xs:string and an optional node. If the optional node argument is present, the processor looks for those values in the document that contains that node.

In both XSLT 1.0 and 2.0, if the string value contains multiple values separated by spaces, each space-separated value is used as a search argument for the id() function. Our examples here use both simple strings and strings with multiple values.

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 description of the key() function earlier in this appendix and the description of the <xsl:key> element in Appendix A for more information.

Output

[1.0] A node-set containing all nodes whose attributes of type ID match the string values of the input node-set.

[2.0] A sequence containing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required