In XSLT 2.0 the context item can be either a node or an atomic value. When
you do this:
<xsl:variable name="split"
select="tokenize(replace($AName,'(.)([A-Z])','$1 $2'), ' ')"/>
<xsl:for-each select="$split">
tokenize() returns a sequence of strings, so within the for-each the context
item is a string. This means that when you use a relative path expression
TopContext/*... the system doesn't know what it's relative to. Perhaps you
intended it to be relative to the node that was the context item outside the
for-each, in which case the answer is to bind that to a variable, and use
the variable at the start of the path expression:
<xsl:variable name="c" select="."/>
<xsl:variable name="split"
select="tokenize(replace($AName,'(.)([A-Z])','$1 $2'), ' ')"/>
<xsl:for-each select="$split">
<xsl:value-of select="$c/TopContext/*...
But actually looking at your code I think you might actually have intended
it to be relative to the root of that document, in which case you would want
<xsl:variable name="c" select="/"/>
Whichever it is, you need to be explicit.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Rahil [mailto:qamar_rahil(_at_)yahoo(_dot_)co(_dot_)uk]
Sent: 26 May 2005 12:18
To: XSL List
Subject: [xsl] error executing path expression
Hi
I am getting an error "FATAL ERROR: The context item for an
axis step is
not a node"
on the line <xsl:if
test="TopConcept/*[lower-case(name())=lower-case($archTerm)]">
</xsl:if>.
My structure is such
--------------------------------------------------------------
-------------------------------------------------------
<xsl:template match="/">
<TopConcept name="{TopConcept/@name}">
<xsl:apply-templates select="TopConcept"/>
</TopConcept>
</xsl:template>
<xsl:template match="TopConcept">
<xsl:for-each select="/*/*/O/Class[text()=$notPresent]">
<xsl:variable name="clsName"
select="..//preceding-sibling::A/Class/text()"/>
<xsl:if
test="matches($clsName,'(.)([A-Z])')"><!--only call the template if
there is any word to split-->
<xsl:call-template name="splitTerm">
<xsl:with-param name="AName"
select="$clsName"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="splitTerm">
<xsl:param name="AName"/> <!-- Eg: AName = 'NextTime' -->
<xsl:variable name="split"
select="tokenize(replace($AName,'(.)([A-Z])','$1 $2'), ' ')"/>
<xsl:for-each select="$split">
<xsl:variable name="ATerm" select="."/> <!--
ATerm = 'Next' -->
<xsl:if test="string-length($ATerm)>2">
<xsl:if
test="TopConcept/*[lower-case(name())=lower-case($archTerm)]">
</xsl:if>
<!--look for existence of <Next> as a child of <TopConcept> -->
<!-- PROBLEM WITH THIS
LINE OF CODE-->
</xsl:if>
</xsl:for-each>
</xsl:template>
--------------------------------------------------------------
-------------------------------------------------------
I have tested and seen that current( ) does not return a node( ) but
rather the atomic value 'Next' for instance. Prior to using the
'saxon:next-in-chain' feature the code was working fine when
I went back
to the top node to start a search but now it generates an error. Ive
tried several options but none seem to resolve the issue.
Could someone please help.
Thanks
Rahil
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--