Name
[2.0] idref()
Given a sequence of ID
values, returns a sequence containing
all the nodes with an IDREF
value matching one of the given ID
s.
Syntax
node()*idref(
xs:string*
)
node()*idref(
xs:string*
,node()
)
Inputs
A sequence of xs:string
s,
each of which represents an ID
value. If the node()
argument is supplied, the XSLT processor looks for matching
IDREF
and IDREFS
values in the document that
contains that node. Without the node()
argument, the processor looks
in the document that contains the context node.
Outputs
A sequence of nodes, each of which has an IDREF
or IDREFS
value that matches one of the
given ID
s. The nodes are
returned in document order, and any duplicate nodes are
removed.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 15.5, “Functions and Operators that Generate Sequences.”
Example
For our example, we’ll use a list of components and parts
with an embedded DTD. We’ll list each part, followed by the name
of each component that uses that part. The idref()
function lets us retrieve
the <component>
element
with the specific ID
; from
there we can get the name of the component.
Note
This is the exact opposite of the example for the id()
function. In that example, we
take each <component>
and list all of the parts that it uses.
To illustrate the idref()
function, we’ll use an XML
document with an embedded DTD. (This allows us to demonstrate the
function without requiring a schema-aware XSLT processor.) Here is
a fragment of the document:
<?xml version="1.0"?> ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.