[xsl] RE: FOR-EACH based on criteria and number output

Subject: [xsl] RE: FOR-EACH based on criteria and number output
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Wed, 18 Feb 2004 23:30:10 -0500
you need to locate all ITEM nodes
-- //ITEM

then check the very preceding TITLE node 
-- [preceding::TITLE[1] != $title1

finally, use position() to give you the numbers

Good luck.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"

<xsl:variable name="title1" select="'Raging River'"/>

<xsl:template match="/">
	<xsl:for-each select="//ITEM[preceding::TITLE[1] != $title1]">
		<xsl:value-of select="concat(position(), '. ', .)"/><br/>

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
Sent: Wednesday, February 18, 2004 10:28 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx

   I'm attempting to produce an HTML document from an XML one using XSLT.  I
need to make a numbered list of a certain tag's(<ITEM>) info contained
the XML document.  This challenge here is that I only want certain <ITEM>s
be contained in my list while others should be omitted, however all <ITEM>s
have the same ancestry.  The only distinguishing element is a sibling tag
as <TITLE> with different literal values stored in them.  It is the value
stored in this <TITLE> that needs to determine the <ITEM>'s inclusion to or
exclusion from the list:

    <TITLE>Magic Mountains</TITLE>
      <ITEM>This is the first item.</ITEM>
      <ITEM>This is the second item.</ITEM>
    <TITLE>Raging River</TITLE>
      <ITEM>I don't want this item.</ITEM>
      <ITEM>I don't want this item either.</ITEM>
    <TITLE>Spectacular Sky</TITLE>
      <ITEM>This is the third item.</ITEM>
      <ITEM>This is the fourth item.</ITEM>

---------------The HTML output should be as follows:
             1.  This is the first item.
             2.  This is the second item.
             3.  This is the third item.
             4.  This is the fouth item.

Any ideas?

 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