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

Re: Removing Duplicates & Formatting

Subject: Re: Removing Duplicates & Formatting
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 10 Dec 2003 14:44:26 GMT
xsl duplicates
you'd probbaly better off doing this in two passes, first get the paths
then elimiate duplicates.

this uses saxon node-set extension to do two passes in one stylesheet,
more or less every xslt engine (except mozilla) has a similar extension.

<a>
  <b><c/><c/><d/></b>
  <b><d/></b>
  <c><d><e/></d></c>
  <c><d><e/></d></c>
</a>




<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:saxon="http://icl.com/saxon"
extension-element-prefixes="saxon"
>
<xsl:output method="xml" indent="yes" />

<xsl:key name="ref" match="elem" use="ref"/>

<xsl:template match="/">
<xsl:variable name="x">
<xsl:for-each select="//*[not(*)]">
<p>
<xsl:for-each select="ancestor-or-self::*"
 >/<xsl:value-of select="name()"/>
</xsl:for-each>
</p>
</xsl:for-each>
</xsl:variable>

<xsl:copy-of select="saxon:node-set($x)/p[not(.=following-sibling::p)]"/>
</xsl:template>


</xsl:stylesheet>

$ saxon path.xml path.xsl
<?xml version="1.0" encoding="utf-8"?>
<p>/a/b/c</p>
<p>/a/b/d</p>
<p>/a/c/d/e</p>


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Re: Removing Duplicates & Formatting, (continued)
    • David Carlisle - Wed, 10 Dec 2003 05:38:53 -0500 (EST)
      • JCS - Wed, 10 Dec 2003 07:27:43 -0500 (EST)
      • David Carlisle - Wed, 10 Dec 2003 07:33:44 -0500 (EST)
        • JCS - Wed, 10 Dec 2003 09:03:27 -0500 (EST)
        • David Carlisle - Wed, 10 Dec 2003 09:45:32 -0500 (EST) <=
        • JCS - Thu, 11 Dec 2003 03:07:54 -0500 (EST)
        • David Carlisle - Thu, 11 Dec 2003 04:49:11 -0500 (EST)
        • JCS - Thu, 11 Dec 2003 05:20:11 -0500 (EST)

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.