Here it is another 2.0 approach that gives the result in one instruction
:) assumming the edge elements are children of the current context node:
<xsl:copy-of select="
for $i in
distinct-values(*/concat(@dependency, @source, @target))
return *[$i=concat(@dependency, @source, @target)][1]"/>
If you define a key using concat(@dependency, @source, @target) and
matching edge elements
<xsl:key name="e" match="edge"
use="concat(@dependency, @source, @target)"/>
then the return will be
return key('e',$i)[1]"/>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Abel Braaksma wrote:
Something like this:
<xsl:for-each-group select="$input/edge"
group-by="concat(@source, '-', @target, '-', @dependency)">
<xsl:copy-of select="." />
</xsl:for-each-group>
where $input is contains your 'edge' nodes?
cheers,
-- Abel
Garvin Riensche wrote:
Hello,
I am wondering what's the best way of getting rid of duplicate nodes
which contain more than one attribute. Suppose I have den following xml:
<edge source="IGetter" target="CGetter" dependency="positive"/>
<edge source="IGetter" target="CGetter" dependency="positive"/>
<edge source="IGetter" target="CCount" dependency="positive"/>
<edge source="ICount" target="IGetter" dependency="positive"/>
<edge source="ICount" target="CGetter" dependency="positive"/>
<edge source="ICount" target="ICount" dependency="positive"/>
<edge source="ICount" target="CCount" dependency="positive"/>
<edge source="ICount" target="CCount" dependency="positive"/>
How do I get rid of one
<edge source="IGetter" target="CGetter" dependency="positive"/>
and one
<edge source="ICount" target="CCount" dependency="positive"/>
which appear twice?
If there was only one attribute, lets say "source" it would be simple:
<xsl:for-each
select="//edge[not(./@source=preceding-sibling::edge/@source)]">
<xsl:copy-of select="."/>
</xsl:for-each>
So I thought with more attributes this would work:
<xsl:for-each
select="//edge[not(./@source=preceding-sibling::edge/@source
and ./@target=preceding-sibling::edge/@target
and ./@dependency=preceding-sibling::edge/@dependency
)]">
</xsl:for-each>
But of course it doesen't because in one iterartion the
"preceding-siblings" doesn't point to the same element.
So, any help would be appreciated on how to get rid of duplicates.
Regards,
Garvin
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--