How can I internationalize XSLT auto-numbering?

Joe Sam Shirah

The xsl:number element provides for auto-numbering. The format attribute and, potentially, the letter-value attribute can be used to internationalize numbering. Any alphanumeric character that has a Unicode category of Nd, Nl, No, Lu, Ll, Lt, Lm or Lo can be used.

For example, if we had an XSL document for a book broken down into chapters called Crawling, Walking, and Running, the XSL transformation snippet might look like this:

<xsl:template match="book">
<xsl:number/>
<xsl:text> </xsl:text>
<xsl:value-of select="chapter" />
</xsl:template>
The output would be:
1 Crawling
2 Walking
3 Running
For I18N, we change the element to begin with the desired value. To use Thai digits, the element would be:
<xsl:number format="&#x0E51;"/>
To use the Greek letters alpha, beta, gamma and so on:
<xsl:number format="&#x03B1;" letter-value="traditional"/>
Clearly the appropriate fonts or character sets must be available. For more information, see XSL Transformations (XSLT) - 7.7 Numbering; for some ( non-I18N'ed ) examples, see XSL Basics (part 2).
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact