最后结果:
XML
<?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="C8.xslt"?> <lists> <ol> <li>the</li> <li>cat</li> <ol> <li>sat</li> <li>on</li> <li>the</li> </ol> <li>mat</li> </ol> </lists>
XSL
<?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="paramelem.xsl"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!--匹配XML Document中的 ol/li mark--> <xsl:template match="ol/li"> <br/> <!--Invoke template--> <xsl:call-template name="number-block"> </xsl:call-template> </xsl:template> <xsl:template match="ol//ol/li"> <br/> <xsl:call-template name="number-block"> <!--Pass param to template--> <xsl:with-param name="format">a.</xsl:with-param> </xsl:call-template> </xsl:template> <!--Declare template named number-block--> <xsl:template name="number-block"> <!--Declare a para named format --> <xsl:param name="format">1. </xsl:param> <fo:block> <xsl:number format ="{$format}"/> <!--Apply template--> <xsl:apply-templates></xsl:apply-templates> </fo:block> </xsl:template> </xsl:stylesheet>