XSLT also supports numbering with Roman numerals in either upper- or lowercase with I, II, III, IV, or i, ii, iii, iv, and so forth. To get Roman numerals in your output, just supply an upper- or lowercase letter I or i in the format attribute. The roman.xsl stylesheet, shown in Example 9-13, formats its output with lowercase Roman numerals. Example 9-13. A stylesheet for numbering with Roman numerals<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="us"> <xsl:apply-templates select="state"/> </xsl:template> <xsl:template match="state"> <xsl:number format="i	"/> <xsl:value-of select="."/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> In this example, the lowercase letter i isn't preceded by any character, and it is followed by a single tab (	). Apply this stylesheet to us.xml with: xalan us.xml roman.xsl and you get the results shown in Example 9-14. Example 9-14. U.S. states listed with Roman numeralsi Alabama ii Alaska iii Arizona iv Arkansas v California vi Colorado vii Connecticut viii Delaware ix Florida x Georgia xi Hawaii xii Idaho xiii Illinois xiv Indiana xv Iowa xvi Kansas xvii Kentucky xviii Louisiana xix Maine xx Maryland xxi Massachusetts xxii Minnesota xxiii Michigan xxiv Mississippi xxv Missouri xxvi Montana xxvii Nebraska xxviii Nevada xxix New Hampshire xxx New Jersey xxxi New Mexico xxxii New York xxxiii North Carolina xxxiv North Dakota xxxv Oklahoma xxxvi Oregon xxxvii Ohio xxxviii Pennsylvania xxxix Rhode Island xl South Carolina xli South Dakota xlii Tennessee xliii Texas xliv Utah xlv Vermont xlvi Virginia xlvii Washington xlviii West Virginia xlix Wisconsin l Wyoming 9.3.1 Uppercase Roman NumeralsFor uppercase Roman numerals, do the same thing as you do with alphabetical lists. The stylesheet upper-roman.xsl replaces the lowercase i with an uppercase I, followed by a decimal character reference for a tab (	). (This stylesheet is not shown here but is in examples/ch09.) If you transform us.xml with upper-roman.xsl, it will give you uppercase Roman numerals rather than lowercase. |