Description
The functx:id-from-element function takes the $element element and returns its attribute (there can only be one) that is of type xs:ID. If no such attribute exists, or if the argument is the empty sequence, the function returns the empty sequence. The attribute must have been declared to be of type xs:ID in a schema, and validated by that schema, for this function to return it.
Arguments and Return Type| Name | Type | Description |
$element |
element()? |
the element |
| return value |
xs:string? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for July 2004 - January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:id-from-element
( $element as element()? ) as xs:string? {
data(($element/@*[id(.) is ..])[1])
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function id-from-element
( $element as element()? ) as xs:string? {
fn:data(($element/@*[fn:id(.) is ..])[1])
} |
Examples| XQuery Example | Results | Explanation |
|---|
functx:id-from-element($book/book/section[1])
|
preface
|
Assumes that the attribute id of $element is declared to be of type xs:ID. |
See Also| fn:id | Retrieves elements by their ID | | fn:idref | Retrieves elements that refer to other elements based on ID |
History |
|