I have a xml document and I am trying to get distinct leaf nodes path from root's child.
XML:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<class>
<city>Test Data</city>
<activity_version_id>Test Data</activity_version_id>
<event_id>Test Data</event_id>
</class>
<class>
<city>Test Data</city>
<activity_version_id>Test Data</activity_version_id>
<event_id>Test Data</event_id>
</class>
</root>
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="*[not(*)]">
<xsl:for-each select="ancestor-or-self::*">
<xsl:if test="name(/*) != name(current())">
<xsl:value-of select="name()"/>
<xsl:if test="count(descendant::*) != 0">
<xsl:value-of select="concat('.','')"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:text>,
</xsl:text>
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="*"/>
</xsl:template>
</xsl:stylesheet>
Actual:
class.city,
class.activity_version_id,
class.event_id,
class.city,
class.activity_version_id
class.event_id
But I want to get only distinct node paths like this i.e., distinct node path
class.city
class.activity_version_id
class.event_id
The XSLT processor is Apache Software Foundation
.
Please help. Thanks in advance.