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 TypeName | Type | Description |
$element |
element()? |
the element |
return value |
xs:string? |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:id-from-element" as="xs:string?"
xmlns:functx="http://www.functx.com">
<xsl:param name="element" as="element()?"/>
<xsl:sequence select="
data(($element/@*[id(.) is ..])[1])
"/>
</xsl:function>
|
Examples<xsl:variable name="book" select="doc('https://www.datypic.com/functx./input/book.xml')"/>
|
XPath 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 Alsofn:id | Retrieves elements by their ID | fn:idref | Retrieves elements that refer to other elements based on ID |
History |
Recommended Reading:
|