Page 1 of 1

XSL if-expression question

Posted: Fri Jun 16, 2006 10:30 pm
by jgarrison
OxygenXML is rejecting the following usage with "Unknown system function: if"
I have XPath level set to 2.0

<xsl:variable name="qd"
select="if(value/qDisplay/text() eq '')
then 'empty'
else 'right'"/>

Is this syntactically correct?

XPath 2.0 if-expr

Posted: Fri Jun 16, 2006 11:10 pm
by jgarrison
My original title is misleading. The if-expression I'm trying to use is defined by XPath, not XSLT.

Posted: Sat Jun 17, 2006 7:50 am
by george
Hi,

Where did you set the XPath level to 2.0?
If you edit a stylesheet then you should specify in xsl:stylesheet version="2.0"

Code: Select all


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
Best Regards,
George

Posted: Tue Jun 20, 2006 6:31 pm
by jkmyoung
You could always do:
<xsl:variable name="qd">
<xsl:choose>
<xsl:when test="if(value/qDisplay/text() eq '')>empty</xsl:when>
<xsl:otherwise>right</xsl:otherwise>
</xsl:choose>
</xsl:variable>

Posted: Wed Jun 21, 2006 8:45 am
by Radu
Hi,

As George said, you have to change the xsl:stylesheet's version attribute to 2.0 in order for it to validate a version 2.0 XPath "if() then else" expression.
This is also true for running a transformation on the stylesheet (you have to run it using the Saxon 8B transformer).
Indeed, if the stylesheet version remains 1.0 you get the error reported above.

Regards,
Radu