| 
 
Subject: Re: [xsl] traversing the tree from an arbitrary node From: "Chris d'Aquin" <CDAquin@xxxxxxxxxxx> Date: Wed, 15 Aug 2001 13:50:26 -0500  | 
Since my title got much more response than my question, here is a
simplified restate of my problem.
I am using XT on a Windows NT platform.  When I run this line, I get the
error message of "expected node test":
       <xsl:when test="id('$id')/from-ancestors(*[position()
=$elementDepth][self::rootTag])">
$id contains the ID of the tag I want, and $elementDepth contains the
number of steps down from the <rootTag> I expect to be.  What I am trying
to say for that node test is "from the node that has this id, go up
$elementDepth ancestor nodes and see if that node is <rootTag>." What am I
doing wrong?
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Chris d'Aquin, XML Engineer
Questia Media, Inc.
713.358.2515
cdaquin@xxxxxxxxxxx
http://www.questia.com/
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                                                                                           
                    "Chris d'Aquin"                                                                        
                    <CDAquin@xxxxxxxxxxx>              To:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx             
                    Sent by:                           cc:                                                 
                    owner-xsl-list@xxxxxxxxxxxx        Subject:     [xsl] traversing the tree from an      
                    rytech.com                         arbitrary node                                      
                                                                                                           
                                                                                                           
                    08/15/01 10:55 AM                                                                      
                    Please respond to xsl-list                                                             
                                                                                                           
                                                                                                           
I am trying to traverse the tree from an arbitrary node (as designated by
its ID).  But I can't get it right!
As some background, I have an XML document where if I find a certain tag
with a certain attribute I need to check the previous and/or following
identical tag to see if it is nested at the same depth within the document.
If not, there is a basic structural error within the file that needs to be
corrected before the XML file can be fully processed.
Here is some sample XML:
<rootTag>
  <parentTag>
    <childTag id='id1' att='checkThis'>
      . . . some info . . .
    </childTag>
  </parentTag>
  <parentTag>
    <childTag id='id2' att='thisChecks'>
      . . . some more info . . .
    </childTag>
  </parentTag>
</rootTag>
When I find a <childTag>, I count how deep the tag is from <rootTag>, get
the ID of the next <childTag>, then try to see if the next <childTag> is at
the same depth.  Here are the steps from the stylesheet:
<xsl:if test="@att='checkThis'">
  <xsl:variable name="elementDepth">
    <xsl:value-of select="count(ancestor::*)" />  <!-- this gets the depth
of the current childTag from rootTag, right? -->
  </xsl:variable>
  <xsl:variable name="id">
    <xsl:value-of select="following::childTag[1]/@id" />
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="id('$id')/from-ancestors(*[position()
=$elementDepth][self::rootTag])">
      <!-- do nothing since this is the right depth -->
    </xsl:when>
    <xsl:otherwise>
      . . . error message . . .
    </xsl:otherwise>
  </xsl:choose>
</xsl:if>
I am using XT on a Windows NT platform.  When I run this, I get the error
message of "expected node test" for the line that has the id() function.
What I am trying to say for that node test is "from the node that has this
id, go up $elementDepth ancestor nodes and see if that node is <rootTag>."
What am I doing wrong?
Thanks,
Chris
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Chris d'Aquin, XML Engineer
Questia Media, Inc.
713.358.2515
cdaquin@xxxxxxxxxxx
http://www.questia.com/
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: Re: [xsl] traversing the tree f, cutlass | Thread | Re: [xsl] traversing the tree from , Jeni Tennison | 
| RE: [xsl] Re: Microsoft XML, sara . mitchell | Date | Re: [xsl] apostrophe in paramter ca, Mike Brown | 
| Month |