Hello I have a requirement where I have an xml file (generic the element names and nodes may change). The intention is to produce a properties file out of it where on left side will be the absolute path of the element name and right side is the value for that element. for instance :-
If I have below xml :-
<?xml version="1.0" encoding="UTF-8"?>
<group>
<root>
<child>
<subchild>xyz</subchild>
</child>
</root>
<root1>
<child>
<subchild>abc</subchild>
</child>
</root1>
<root2>
<child>
<subchild>pqr</subchild>
</child>
</root2>
<root3>
<child>
<subchild>lmn</subchild>
</child>
</root3>
</group>
then the output should be :-
/group/root/child/subchild=xyz
/group/root1/child/subchild=abc
/group/root2/child/subchild=pqr
/group/root3/child/subchild=lmn
So far I have written below xslt but it does not work correctly:-
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="node()">
<xsl:for-each select="ancestor-or-self::*">
<xsl:value-of select="concat('/',name(.))"/>
</xsl:for-each>
<xsl:value-of select="concat('=',.)"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="*"/>
</xsl:template>
</xsl:transform>
any help would be much appreciated.
thansk.