Is there an equivalent function for string format in XSLT?
This is a close equivalent in XSLT :
The dictionary entry has the following format:
<t>Your query "<query/>" matched <nResults/> results</t>
Converting (appropriate string.format()) is very simple:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="pQuery" select="'XPath and XSLT'"/>
<xsl:param name="pNumResults" select="3"/>
<xsl:template match="query">
<xsl:value-of select="$pQuery"/>
</xsl:template>
<xsl:template match="nResults">
<xsl:value-of select="$pNumResults"/>
</xsl:template>
</xsl:stylesheet>
, and it produces the desired, correct result :
Your query "XPath and XSLT" matched 3 results
source
share