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

RE: 2 unique lists

Subject: RE: 2 unique lists
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Mon, 7 Aug 2000 17:47:29 +0100
RE: 2 unique lists
>Hello all.  
>
>This another question about deriving a unique list from xmldata, 
>but I think 
>mine is a little different.  I have the following xml:
>
><schedule>
>	<person name="person1">
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>	</person>
>	<person name="person2">
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>		<date>Feb2000</date>
>		<date>Mar2000</date>
>		<date>Apr2000</date>
>	</person>
></schedule>	
>
>	 and from this I want two unique lists of dates, thus 
>
>	 person1: Feb2000, Mar2000, Apr2000.
>	 person2: Feb2000, Mar2000, Apr2000.
>
>	 Here is the first stylesheet, using preceding:
>
><xsl:template match="person">
>  <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
>  <xsl:for-each select="date[ not( . = preceding::date )]">
>    <xsl:value-of select="."/>
>    <xsl:if test="not(position()=last())">, </xsl:if>
>  </xsl:for-each>
></xsl:template>

You could try 

<xsl:template match="person">
  <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
  <xsl:for-each select="date[ not( . = preceding-sibling::date )]">
    <xsl:value-of select="."/>
    <xsl:if test="not(position()=last())">, </xsl:if>
  </xsl:for-each>
</xsl:template>

Ciao Chris


 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-2011 All Rights Reserved.