[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl:when conditions
try declaring the parameter with a default in the template and toss the xsl:when statement... <xsl:param name="alignment" select="string('left')"/> Steve Crowers Software Engineer Liberate Technologies 2 Walnut Grove, Suite 200 Horsham, PA 19044 Phone: 215-773-9400 x 9514 Fax: 215-773-9401 scrowers@xxxxxxxxxxxx http://www.liberate.com "The good Lord sets definite limits on man's wisdom but sets no limits on his stupidity -- and that's just not fair." --Konrad Adenauer, German Chancellor -----Original Message----- From: Stuart Wilson [mailto:coracle@xxxxxxxxxxxxxx] Sent: Thursday, August 16, 2001 12:00 PM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: xsl:when conditions Hello, In the XSL below I'm trying to pass a optional parameter called "alignment" into a template. When the parameter is not passed into the template I want to assign a default value (left) to the variable "alignment" The line <xsl:when test="$alignment"> seems to be causing the problem and did work under Xalan 1_2_2, however it fails under Xalan 2_2 with "Unknown error in XPath" Could someone explain how best to set a default value to the parameter ? <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match ="/"> <!-- Text aligned right --> <xsl:call-template name="writeline"> <xsl:with-param name="text" select="string('some text')"/> <xsl:with-param name="alignment" select="string('right')"/> </xsl:call-template> <!-- Should take default --> <xsl:call-template name="writeline"> <xsl:with-param name="text" select="string('some more text')"/> </xsl:call-template> </xsl:template> <xsl:template name="writeline"> <xsl:param name="text"/> <xsl:param name="alignment"/> <xsl:variable name="alignment"> <xsl:choose> <xsl:when test="$alignment"> <===== This syntax causes error <xsl:value-of select="$alignment"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="string('left')"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <table width="100%" border="1"> <tr> <td align="{$alignment}"><xsl:value-of select="$text"/></td> </tr> </table> </xsl:template> </xsl:stylesheet> Regards, Stuart ----------------------- The Totalise Email system, probably the most flexible email system in the world. To register for an account goto http://www.totalise.net XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|