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

Re:

Subject: Re:
From: Peter Flynn <pflynn@xxxxxx>
Date: Thu, 19 Feb 2004 09:16:24 +0000
xsl match 2nd
On Thu, 2004-02-19 at 03:28, tsterlin@xxxxxxxxxxxxxxxxx wrote:
> Hello,
> 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

Elements.

> (<ITEM>) info contained within the XML document.  This challenge here 
> is that I only want certain <ITEM>s to 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 known 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:

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

<xsl:template match="ITEM">
  <xsl:if test="parent::STEP1/preceding-sibling::TITLE!='Raging River'">
    <li>
      <xsl:apply-templates/>
    </li>
  </xsl:if>
</xsl:template>

<xsl:template match="TITLE"/>

If you want the test to match a list of values instead of exclude a
single value, use

<xsl:template match="ITEM">
  <xsl:variable name="title" 
        select="parent::STEP1/preceding-sibling::TITLE"/>
  <xsl:if test="$title='Magic Mountains' or
               $title='Spectacular Sky'">
    <li>
      <xsl:apply-templates/>
    </li>
  </xsl:if>
</xsl:template>

///Peter

> <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>
>   <PARA0>
>     <TITLE>Raging River</TITLE>
>     <STEP1>
>       <ITEM>I don't want this item.</ITEM>
>     </STEP1>
>     <STEP1>
>       <ITEM>I don't want this item either.</ITEM>
>     </STEP>
>   </PARA0>
>   <PARA0>
>     <TITLE>Spectacular Sky</TITLE>
>     <STEP1>
>       <ITEM>This is the third item.</ITEM>
>     </STEP1>
>     <STEP1>
>       <ITEM>This is the fourth item.</ITEM>
>     </STEP1>
>   </PARA0>
> </GROUP>
> 
> ---------------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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.