home contribute faq download

FunctX XSLT Functions

functx:id-untyped

Gets XML element(s) that have an attribute with a particular value

Google
Webdatypic.com

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 Type

NameTypeDescription
$node node()* the root node(s) to start from
$id xs:anyAtomicType the "id" to find
return value element()*

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:id-untyped" as="element()*"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="node" as="node()*"/>
  <xsl:param name="id" as="xs:anyAtomicType"/>

  <xsl:sequence select="
  $node//*[@* = $id]
 "/>

</xsl:function>

Examples

<xsl:variable name="in-xml" as="item()*">
<in-xml>
  <a id="A001">abc</a>
  <b foo="A001">def</b>
  <c id="B001">ghi</c>
</in-xml>
  
</xsl:variable>
XPath ExampleResults
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 Also

fn:idRetrieves elements by their ID
fn:idrefRetrieves elements that refer to other elements based on ID
functx:id-from-elementGets the ID of an XML element

History

Published OnLast UpdatedContributor(s)
2006-07-092007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery