Subject: RE: xml cells transformed in to a 2-d table, some table cells missing, full table required - constant variables.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 3 Jan 2009 22:53:46 -0000
|
> When using XSLT 1.0 I got various error messages with the
> above syntax.
> XPath error : Invalid expression
> if (exists($ig)) then $ig/length else 0
> ^
Yes, sorry, I'm very out of practice with writing 1.0 code. You have to
expand the XPath if()then ...else to an XSLT xsl:choose. The exists()
function can often be replaced with boolean() or just omitted
<xsl:choose>
<xsl:when test="$ig">
<xsl:value-of select="$ig/length"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
or there's often a less verbose way, as you say here using string-length.
Michael Kay
http://www.saxonica.com/
|