XSL if-expression question

Here should go questions about transforming XML with XSLT and FOP.
jgarrison
Posts: 4
Joined: Mon Jun 05, 2006 7:17 pm

XSL if-expression question

Post 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?
jgarrison
Posts: 4
Joined: Mon Jun 05, 2006 7:17 pm

XPath 2.0 if-expr

Post by jgarrison »

My original title is misleading. The if-expression I'm trying to use is defined by XPath, not XSLT.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post 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
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post 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>
Radu
Posts: 9045
Joined: Fri Jul 09, 2004 5:18 pm

Post 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
Post Reply