I have a problem with XPATH. I have an XML structred like this:
<root>
<state name="UsUed">
<transition event-source="this" event="edit()" target="UsEd_editing" />
...
</state>
<state>
<transition event-source="this" event="edit()" target="UsEd" />
<transition event-source="that" event="new()" target="SUed" />
...
</state>
</root>
and I need to get <transition />
's only with @event-source='this'
and distinct @event
.
My solution to this point is selecting all <transitions />
with 'this' attribute, sorts them by @event
then tries to select only distinct ones of them like here
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="//transition[@event-source='this']">
<xsl:sort select="@event"/>
<xsl:if https://stackoverflow.com/questions/2812122/distinct-in-xpath>
<!--Here goes the transformation-->
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
But it doesn't work.