ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] Handling Duplicate Lines in XSL
by Murali Korrapati other posts by this author
Oct 31 2003 7:04PM messages near this date
RE: [xsl] Select statement within HREF | Re: [xsl] Handling Duplicate Lines in XSL
Hi,
  Thanks for the people who posted and answered this question. This gives me lead to solve s
ome 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
Thread:
Murali Korrapati
J.Pietschmann

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved