XSLT Functions
These functions are only available during XSLT transformation (not in standalone XPath evaluation).
key
key($name as xs:string, $value as xs:anyAtomicType) as node()*
key($name as xs:string, $value as xs:anyAtomicType, $top as node()) as node()*
Looks up nodes indexed by xsl:key. The 3-argument form restricts the search to the document containing $top.
<xsl:key name="id" match="item" use="@id"/>
<xsl:value-of select="key('id', 'A42')/@name"/>document
document($uri as xs:string) as document-node()
Loads an external XML document. Results are cached. Use document('') to access the stylesheet document itself.
id
id($value as xs:string) as element()*
id($value as xs:string, $node as node()) as element()*
Finds elements with a matching xml:id attribute. Space-separated values in $value are treated as multiple IDs.
current
current() as item()
Returns the current item being processed by xsl:apply-templates or xsl:for-each. Unlike ., this remains stable inside predicates.
generate-id
generate-id() as xs:string
generate-id($node as node()) as xs:string
Returns a unique identifier string for a node, stable across calls.
regex-group
regex-group($group as xs:integer) as xs:string
Returns the captured group from the current regex match inside xsl:matching-substring of xsl:analyze-string.
<xsl:analyze-string select="'2024-01-15'" regex="(\d{{4}})-(\d{{2}})-(\d{{2}})">
<xsl:matching-substring>
Year: <xsl:value-of select="regex-group(1)"/>
</xsl:matching-substring>
</xsl:analyze-string>current-group
current-group() as item()*
Returns all items in the current group inside xsl:for-each-group.
current-grouping-key
current-grouping-key() as xs:anyAtomicType
Returns the grouping key for the current group inside xsl:for-each-group.
unparsed-text
unparsed-text($href as xs:string) as xs:string
Reads a text file and returns its content as a string. Relative URIs are resolved against the stylesheet location.
<xsl:variable name="data" select="unparsed-text('data.csv')"/>unparsed-text-available
unparsed-text-available($href as xs:string) as xs:boolean
Returns true if the file at $href exists and can be read.
element-available
element-available($name as xs:string) as xs:boolean
Returns true if the given XSLT instruction is supported. Useful for xsl:fallback scenarios.
<xsl:if test="element-available('xsl:result-document')">
...
</xsl:if>system-property
system-property($name as xs:string) as xs:string
Returns the value of a system property. Supported properties:
| Property | Value |
|---|---|
xsl:version |
3.0 |
xsl:vendor |
speedata |
xsl:vendor-url |
https://github.com/speedata/goxslt |
xsl:product-name |
goxslt |
xsl:product-version |
0.1 |
xsl:supports-serialization |
yes |
xsl:supports-backwards-compatibility |
yes |
function-available
function-available($name as xs:string) as xs:boolean
Returns true if the named function exists. Accepts prefixed names (e.g. xs:integer).
<xsl:if test="function-available('format-number')">
<xsl:value-of select="format-number($price, '#,##0.00')"/>
</xsl:if>serialize
serialize($items as item()*) as xs:string
serialize($items as item()*, $params as item()?) as xs:string
Serializes a sequence of items to an XML string representation.
<xsl:variable name="fragment">
<item id="1"/>
<item id="2"/>
</xsl:variable>
<xsl:value-of select="serialize($fragment)"/>