fn:idref( $arg as xs:string*, [$node as node()] ) as node()*
Returns the sequence of element or attribute nodes that have an IDREF value matching the value of one or more of the ID values supplied in $arg.
Parameters | |
---|---|
arg | The IDREFs of the elements and attributes to return. |
node | The target node. |
The function returns a sequence, in document order with duplicates eliminated, containing every element or attribute node $N that satisfies all the following // conditions:
$arg[. castable as xs:ID]
Notes:
An element or attribute typically acquires the is-idrefs property by being validated against the schema type xs:IDREF or xs:IDREFS, or (for attributes only) by being described as of type IDREF or IDREFS in a DTD.
No error is raised in respect of a candidate ID value that does not match the IDREF value of any element or attribute in the document. If no candidate ID value matches the IDREF value of any element or attribute, the function returns the empty sequence.
It is possible for two or more nodes to have an IDREF value that matches a given candidate ID value. In this situation, the function will return all such nodes. However, each matching node will be returned at most once, regardless how many candidate ID values it matches.
It is possible in a well-formed but invalid document to have a node whose is-idrefs property is true but that does not conform to the lexical rules for the xs:IDREF type. The effect of the above rules is that ill-formed candidate ID values and ill-formed IDREF values are ignored
(: assume /mydocs/idref.xml has an element named idrefs that is of type xs:IDREF or xs:IDREFS :) fn:idref("myID", doc("/mydocs/idref.xml")) => <idrefs>myID</idrefs>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.