Mega Code Archive

 
Categories / XML Tutorial / XSLT StyleSheet
 

The format is given with format attribute

File: Data.xml <?xml version="1.0" encoding="utf-8"?> <data>             <n>one</n>     <n>two</n>     <n>three</n>     <n>four</n> </data> File: Transform.xslt <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet       version="1.0"       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">     <xsl:template match="/">       <TABLE>         <xsl:for-each select="//n">           <TR>             <TD>               <xsl:number value="position()" format="001. "/>               <xsl:value-of select="."/>             </TD>           </TR>         </xsl:for-each>       </TABLE>     </xsl:template></xsl:stylesheet> Output: <?xml version="1.0" encoding="UTF-8"?><TABLE><TR><TD>001. one</TD></TR><TR><TD>002. two</TD></TR><TR><TD>003. three</TD></TR><TR><TD>004. four</TD></TR></TABLE>