[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: error executing path expression

Subject: RE: error executing path expression
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 26 May 2005 14:00:04 +0100
xsl tokenize path
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

> -----Original Message-----
> From: Rahil [mailto:qamar_rahil@xxxxxxxxxxx] 
> Sent: 26 May 2005 12:18
> To: XSL List
> Subject:  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 
>               </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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.