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

RE: Filtering/Removing Truly Duplicate Elements

Subject: RE: Filtering/Removing Truly Duplicate Elements
From: cknell@xxxxxxxxxx
Date: Wed, 18 Jul 2007 15:03:07 -0400
RE:  Filtering/Removing Truly Duplicate Elements
Move to XSLT 2.0 and use <xsl:for-each-group> to eliminate the duplicates.

If you can't download Saxon-J for some reason, google for "Muenchian method".
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Wasiq Shaikh <wasiq911@xxxxxxxxxxx>
Sent:     Wed, 18 Jul 2007 14:36:12 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:   Filtering/Removing Truly Duplicate Elements

Hello everyone,

I have searched everywhere for a similar problem but most problems are 
actually very simple with simple solutions. But the techniques are the same. 
Except I cant seem to put differenct peices together. When i run my XSL, the 
desired result is not desired! :)

The Objective:
Remove truly duplicate elements, not just by name but by its attributes and 
attribute values.

The Example:
I have an xml input file (which is actually an XSD) with various 
<xsd:element>'s which may have many attributes.
The attributes I care about are "name" and "type". Below is a sample input 
file:

<xsd:element name="ABC" type="123" ... >
   <xsd:element name="def" type="456" .../>
   <xsd:element name="ghi" type="456" .../>
</xsd:element>

<xsd:element name="ABC" type="456" ...>
   <xsd:element name="ghi">
      <xsd:element name="def" type="456" .../>
      <xsd:element name="def"/>
   </xsd:element>
   <xsd:element name="ABC"/>
   <xsd:element name="ABC"/>
   <xsd:element name="ghi" type="456" .../>
</xsd:element>

The desired result should be a flat list of elements:

<uniqueElements>
   <element name="ABC"/>
   <element name="ABC" type="123"/>
   <element name="ABC" type="456"/>
   <element name="def"/>
   <element name="def" type="456"/>
   <element name="ghi"/>
   <element name="ghi" type="456"/>
</uniqueElements>

The order of the result doesn't matter. But understand that all those 
elements are distinctly unique. I'm using Xalan Java 2.7/XPath 1.0.

My XSL Logic:
Since i need a flat list i will interate through "//xsd:element".
So, for every element encountered, check to see if there are any elements 
before it with the same name, and same type.

Sounds simple enough! But it isn't. I cant get the right combination of 
conditional logic with correct XPath syntax to execute this task. Maybe this 
task can not be done at all? I would like to know first if I'm wasting my 
time trying to figure this out or if there is any hope.

Please help as I'm sure this will benefit anyone else wanting to do the same 
task. Thank you!

Wasiq Shaikh

_________________________________________________________________
Windows Live Hotmail. Even hotter than before. Get a better look now. 
www.newhotmail.ca?icid=WLHMENCA148

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.