Take the 2-minute tour ×

I have a working style-sheet that works fine with saxon.Now I am using simple XQuery:

transform:transform($xmlNode, $xslNode, ()),  

to do the same thing, it always complains about a syntax in my style sheet, which is:

<xsl:template match="CrossReference ">
     <xsl:variable name="currentNode" select="//*[@Target=@pointer]"/>
     <xsl:if test="$currentNode/name()!= 'Figure'">


It always complains about the line, and the message is "An exception occurred while compiling the stylesheet: Unknown nodetype: name". Seems that it cannot understand the function name()?

Could anyone help? Thanks.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You cannot use a function call as part of a path (i.e. after a slash /) in XPath 1.x. To work around this the built-in XPath functions typically accept a node-set as their argument and default to . if the argument is omitted. That is, name() is shorthand for name(.).

Try this instead:

<xsl:if test="name($currentNode) != 'Figure'">
share|improve this answer
Great, worked. But I wonder why my original syntax worked in Saxon? –  Kevin Apr 21 '11 at 17:51
When you ran it in Saxon you were using an XSLT 2.0 processor. You don't say what you were running when you ran it from XQuery, but the error message suggests it was an XSLT 1.0 processor. The syntax a/name() is allowed in XSLT 2.0 but not in 1.0. Downvoting the response as it is misleading. –  Michael Kay Apr 21 '11 at 21:23
add comment

Your Answer


