[xsl] invalid xpath?

Subject: [xsl] invalid xpath?
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Jul 2008 22:23:49 +1200
The following template errors in xsltproc and XMLSpy but appears to function
correctly when run by Saxon.

<!-- retain leading and trailing WS, remove line-breaks from the rest -->
<!-- special case for initial text, or text following <nl> element, when it
starts with a NL -->
<xsl:template name="KeepWS">
 <xsl:param name="Arg" select="." />
 <xsl:variable name="tArg">
  <xsl:choose>
   <xsl:when
test="preceding-sibling::*[1][self::nl][starts-with($Arg,'&#x0a;')]">
    <xsl:call-template name="WS">
     <xsl:with-param name="Arg" select="substring($Arg,2)" />
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="not(preceding-sibling::*)[starts-with($Arg,'&#x0a;')]">
    <xsl:call-template name="WS">
     <xsl:with-param name="Arg" select="substring($Arg,2)" />
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:call-template name="WS">
     <xsl:with-param name="Arg" select="$Arg" />
    </xsl:call-template>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 <xsl:value-of select="$tArg" />
</xsl:template>

The xsltproc error is "XPath error: Invalid type"
XMLSpy says "Error in XPath expression, Not a node set"

I thought the test expressions are valid v1.0 XSL. Is this not so?

Cheers
Trevor

Current Thread