[prog] XSL parameters

Dan dan at cellectivity.com
Tue May 17 21:31:17 EST 2005


I'm teaching myself XSL using Xalan (an XSL engine), and I'm having
trouble passing parameters to the stylesheet.

I invoke Xalan as in the comment (see below). Note that I've put Xalan's
command-line parameters (such as -XSL and -PARAM) in capital and
lowercase, and it makes no difference.

Here is my stylesheet:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<!--
   - This stylesheet demonstrates parameters.
   - To invoke it using Xalan:
   -    xalan -IN anything.xml -XSL this.xsl -OUT foo.txt
   -          -param myParameter my-value
   - See also Doug Tidwell's book, page 76-77.
  -->
<xsl:param name="myParameter"/>

<xsl:template match="/">
  <text>
You set the parameter to:
<xsl:value-of select="$myParameter"/>
  </text>
</xsl:template>

</xsl:stylesheet>




More information about the Programming mailing list