i am trying to transform my xml via java/xalan (2.7.1) with org.apache.xalan.xslt.Process class
I am getting “Extra illegal tokens” and not sure of the work around
i basically want to pass in a parameter to a Template and then use that parameter as a attribute of a <xsl:when test="$textAlign eq 'center'">
if i pass a 'center' param into TableCell template, I would want to create a table cell that has it’s text centered, and of course, 'left' would get it’s contents left justified.
the error message is complaining about the 'center'
the quotes around center trip it up and seems like it should be okay.
here are a few snippets (sample xml and xsl)
<ingredients>
<ingredient>
<quantity>1 1/2</quantity>
<foodstuff>flour</foodstuff>
</ingredient>
</ingredients>
and here is a sample xsl
<xsl:output method="html"/>
<xsl:template match="ingredients">
<xsl:apply-templates select="ingredient"/>
</xsl:template>
.
<xsl:template match="ingredient">
<xsl:call-template name="TableCell">
<xsl:with-param name="cellValue" select="quantity" />
<xsl:with-param name="textAlign" select="'center'" />
</xsl:call-template>
</xsl:template>
.
<xsl:template name="TableCell">
<xsl:param name="cellValue" />
<xsl:param name="textAlign" />
<xsl:choose>
<xsl:when test="$textAlign eq 'center'">
<td align='center'>
<xsl:value-of select="$cellValue"/>
</td>
</xsl:when>
</xsl:choose>
</xsl:template>
maybe there is another way to do this? I thought it was pretty simple but i guess I just not versed enough on xsl
I am using xalan 2.7.1 for my xsl engine
org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl -OUT out.html
thanks everyone
eqis an operator introduced in XPath and XSLT 2.0, you are using Xalan which only supports XPath and XSLT 1.0 so use the=operator instead.Or move from Xalan to Saxon 9 (http://saxon.sourceforge.net/), that processor supports XSLT 2.0.