Description
The functx:id-untyped function simulates the built-in fn:id function except that the value specified can be the value of any attribute, not just one declared to be of type xs:ID . This is useful for getting elements based on ID when a schema is not present. It returns all elements that have any attribute, regardless of name, whose value is the specified value.
Arguments and Return TypeName | Type | Description |
$node |
node()* |
the root node(s) to start from |
$id |
xs:anyAtomicType |
the "id" to find |
return value |
element()* |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:id-untyped
( $node as node()* ,
$id as xs:anyAtomicType ) as element()* {
$node//*[@* = $id]
} ; |
Exampleslet $in-xml := | <in-xml>
<a id="A001">abc</a>
<b foo="A001">def</b>
<c id="B001">ghi</c>
</in-xml>
| return |
XQuery Example | Results |
---|
functx:id-untyped($in-xml,'B001') |
<c id="B001">ghi</c> |
functx:id-untyped($in-xml,'A001') |
<a id="A001">abc</a>
<b foo="A001">def</b> |
functx:id-untyped($in-xml,'C001') |
() |
See AlsoHistory |
Recommended Reading:
|