XSL provides a set of methods for common counting and datatype formatting tasks. These methods are implemented by the XTLRuntime object, and can be called directly from within the xsl:eval and xsl:script elements in your style sheet.
For example, the following fragment from an XSL file shows how to transform chapter/title input into a numbered table of contents in HTML using the built-in methods formatIndex and childNumber.
<xsl:for-each select="chapter">
<H2>
Chapter <xsl:eval>formatIndex(childNumber(this), "I")</xsl:eval>:
<xsl:value-of select="title"/>
</H2>
<xsl:apply-templates />
</xsl:for-each>
XSL Built-in Methods
absoluteChildNumber | Returns the number of the node relative to all siblings. |
ancestorChildNumber | Returns the number of the nearest ancestor of a node with the requested node name. |
childNumber | Returns the number of the node relative to siblings of the same node name. |
depth | Returns the depth within the document tree at which the specified node appears. |
formatDate | Formats the supplied date using the specified formatting options. |
formatIndex | Formats the supplied integer using the specified numerical system. |
formatNumber | Formats the supplied number using the specified format. |
formatTime | Formats the supplied time using the specified formatting options. |
uniqueID | Returns the unique identifier for the supplied node. |