RE: [xsl] HTML RANDOM NODE LIST

Subject: RE: [xsl] HTML RANDOM NODE LIST
From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx>
Date: Fri, 20 Feb 2004 12:06:42 -0800
You may need to provide the more complex structure that you are working with.

If you are in a template match for ITEM, then TITLE is not a sibling, so the preceding-sibling will axis will not include the TITLE node.

TITLE is also not an ancestor of ITEM. You can see that by simply typing a path to the ITEM, GROUP/PARA0/STEP1/ITEM.

In the XML you provided:

<GROUP>
  <PARA0>
    <TITLE>Magic Mountains</TITLE>
    <STEP1>
      <ITEM>This is the first item.</ITEM>
    </STEP1>
    <STEP1>
      <ITEM>This is the second item.</ITEM>
    </STEP1>
  </PARA0>
... <snip/> ...
</GROUP>

You can find the TITLE associated from the context of an ITEM node using:

../../TITLE

preceding::TITLE[1]

If there are more ancestor nodes between ITEM and TITLE, then perhaps in your real scenario the preceding axis is what is called for?

  <xsl:template match="/">
    <ol>
      <xsl:apply-templates/>
    </ol>
  </xsl:template>

  <xsl:template match="ITEM">
    <xsl:if test="not(preceding::TITLE[1]='Raging River')">
      <li><xsl:value-of select="."/></li>
    </xsl:if>
  </xsl:template>

  <xsl:template match="text()"/>


Does that help?
Josh

-----Original Message-----
From: tsterlin@xxxxxxxxxxxxxxxxx [mailto:tsterlin@xxxxxxxxxxxxxxxxx]
Sent: Friday, February 20, 2004 10:20 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] HTML RANDOM NODE LIST


Josh,
    the problem with that method is that the real XML document is much larger
with a multitude of different tags and tag levels.  The info contained within
the tags must be output in a linear fashion so I cannot process it with
for-each loops, I have to use nested/recursive template matches.  It is within
the "template-match" for ITEM, the lowest element in the document, that I must
somehow discern between the ITEM's ancestor TITLE's literal value to determine
whether it should be included within my numbered list.  The parameters for
things like count() and position() are all node sets, and I cannot use a test
such as:"not(preceding-sibling::TITLE[1]='Raging River')" to accumulate count
or position.  I'm stumped.
Tracy.






 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