[4suite] error with position() in arithmetic expressions
Sam Brauer
sam at webslingerZ.com
Thu Feb 1 09:33:52 MST 2001
I am trying to use an <xsl:if> to set the background color of every other
row in an html table that my stylesheet produces.
Something like this simple example:
<xsl:template match="person">
<tr>
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="bgcolor">#dddddd</xsl:attribute>
</xsl:if>
<td>
<xsl:value-of select="firstname"/>
<xsl:value-of select="lastname"/>
</td>
<td>
<xsl:value-of select="email"/>
</td>
</tr>
</xsl:template>
I get the following error:
processor.appendStylesheetNode(sheet)
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xslt/Processor.py", line
94, in appendStylesheetNode
sty = StylesheetReader.FromDocument(styleSheetNode, baseUri)
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xslt/StylesheetReader.py
", line 197, in FromDocument
sheet.setup()
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xslt/Stylesheet.py", lin
e 144, in setup
curr_node.setup()
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xslt/IfElement.py", line
33, in setup
self.__dict__['_expr'] = parser.parseExpression(self._test)
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xpath/XPathParser.py", l
ine 36, in parseExpression
XPathParserBase.XPathParserBase.parse(self, st)
File
"/usr/local/lib/python2.0/site-packages/_xmlplus/xpath/XPathParserBase.py
", line 60, in parse
XPath.cvar.g_prodNum)
SyntaxException:
********** Syntax Exception **********
Exception at or near "mod"
Line: 0, Production Number: 0
I did some experimentation and found that the following expressions work
correctly:
"position()"
"position() + 2"
"position() - 2"
But these do not:
"position() * 2"
"position() div 2"
"position() mod 2"
I'm using the latest 4Suite (0.10.1) with Python2.0 on Linux.
Is this a bug? I'm pretty sure my XSL is legal. I've done similar stuff
in the past with Xalan (Java XSLT processor).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sam Brauer : Systems Programmer : sam at webslingerZ.com
More information about the 4suite
mailing list