xsl-list
[Top] [All Lists]

Re: [xsl] Filtering/Removing Truly Duplicate Elements

2007-07-19 06:18:45
Wow guys thats incredible! Thank you so very much for your help. I'm restricted to using XPath 1.0 due to compatibility issues with JBoss and our framework. But thanks to this neat little script courtesy of David is a blessing.

I knew I was supposed to use keys, but I wasn't using it properly. The

use="concat(@name,' ',@type)"

is brilliant! And I wasn't using generateID correctly either. If you could be so kind as to explain how this statement works, I would greatly appreciate it.

<xsl:for-each select="//xsd:element[generate-id()=generate-id(key('allElements',concat(@name,' ',@type,' ',@ref)))]">

(dont mind the subtle changes)

From my understanding, it is selecting all (or each??) elements whose
generated ID equals an ID value generated from corresponding key value.

OR is it selecting the entire element collection whose ID equals the ID of the entire key collection (this seems to make more sense)

Thank you everyone for your help!

Wasiq Shaikh




----Original Message Follows----

see muenchian grouping

<xsl:key name="k" match="xsd:element" use="concat(@name,' ',@type)"/>

<xsl:template match"/">
<uniqueElements>
<xsl:for-each
select="//xsd:element[generate-id()=generate-id(key('k',concat(@name,' ',@type)))]">
<xsl:copy>
<xsl:copy-of select="@name|@type"/>
</xsl:copy>
</xsl:for-each>
</uniqueElements>
</xsl:template>

should be all you need.

David

_________________________________________________________________
Windows Live Hotmail gives you the control you need to help you keep your e-mail private, safe and secure. See for yourself! www.newhotmail.ca?icid=WLHMENCA147


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--