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

Re: Handling Duplicate Lines in XSL

Subject: Re: Handling Duplicate Lines in XSL
From: "Murali Korrapati" <murali.korrapati@xxxxxxxxx>
Date: Fri, 31 Oct 2003 14:04:24 -0500
preceding sibling duplicate
Hi,
  Thanks for the people who posted and answered this question. This gives me lead to solve some other problem. 
But I have a slightly different problem though.

My XML is like:
<root>
	<foo>
    		<bar>Cust1 443 West</bar>
    		<bar2>Cust1</bar2>
	</foo>
	<foo>
    		<bar>Cust1 443 East</bar>
    		<bar2>Cust1</bar2>
	</foo>
	<foo> 
    		<bar>Cust1 443 East</bar>
    		<bar2>Cust1</bar2>
	</foo>
	<foo>
    		<bar>Cust1 443 West</bar>
    		<bar2>Cust1</bar2>
	</foo>
</root>
 and I want my output to be something like

Cust1 443 West
Cust1 443 East

and I tried with 


<xsl:for-each select="root[not(foo/bar = preceding-sibling::foo/bar)]">

    <xsl:value-of select="."/><br/>

</xsl:for-each>

but, it doesn't seem like working. 

Any help with this??
thanks.

~Mur





Heres a quick fix to your grouping problem...

If the XML was in the following format...

<foo>
    <bar>Cust1 443 West</bar>
    <bar>Cust1 443 West</bar>
    <bar>Cust1 443 West</bar>
    <bar>Cust1 443 East</bar>
</foo>

the following XSL will test to see if the current node is equal to any of
the preceding elements and if it is it will not include it in the resulting
node-set.  It then prints the value of each node.  So this...

<xsl:for-each select="foo/bar[not(. = preceding-sibling::bar)]">

    <xsl:value-of select="."/><br/>

</xsl:for-each>

Will produce this...

Cust1 443 West
Cust1 443 East

Best of luck,

M.


 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.