I
icedgar
I currently have the following XML:
<AAA>
<dict>
<a>apple</a>
<dict>
<a>2</a>
<dict>
<a>James</a>
<x>1</x>
<a>Tammy</a>
<y>2</y>
<a>Pat</a>
<z>3</z>
<a>George</a>
<z>4</z>
<a>Fred</a>
<x>5</x>
</dict>
<a>4</a>
<dict>
<a>James</a>
<x>1</x>
<a>Tammy</a>
<y>2</y>
<a>Pat</a>
<z>3</z>
<a>George</a>
<z>4</z>
<a>Fred</a>
<z>5</z>
</dict>
</dict>
</dict>
</AAA>
When I apply the following XSL template:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xslutput method="xml"/>
<xslutput indent="yes"/>
<xsl:template match="/AAA/dict/dict/*">
<xsl:copy>
<xsl:apply-templates select="a"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a">
<xsl:attribute name="{translate(.,' ','_')}">
<xsl:apply-templates select="following-sibling::*[1]"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
I get the following results:
<a></a>
<dict James="1" Tammy="2" Pat="3" George="4" Fred="5"></dict>
<a></a>
<dict James="1" Tammy="2" Pat="3" George="4" Fred="5"></dict>
Which is what I want but in a different format. I need the following
output to look like this below:
<labels>
James="1"
Tammy="2"
Pat="3"
George="4"
Fred="5"
</labels>
<labels>
James="1"
Tammy="2"
Pat="3"
George="4"
Fred="5"
</labels>
I am still a newbie at this. Any help would be great.
Thanks in advance.
<AAA>
<dict>
<a>apple</a>
<dict>
<a>2</a>
<dict>
<a>James</a>
<x>1</x>
<a>Tammy</a>
<y>2</y>
<a>Pat</a>
<z>3</z>
<a>George</a>
<z>4</z>
<a>Fred</a>
<x>5</x>
</dict>
<a>4</a>
<dict>
<a>James</a>
<x>1</x>
<a>Tammy</a>
<y>2</y>
<a>Pat</a>
<z>3</z>
<a>George</a>
<z>4</z>
<a>Fred</a>
<z>5</z>
</dict>
</dict>
</dict>
</AAA>
When I apply the following XSL template:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xslutput method="xml"/>
<xslutput indent="yes"/>
<xsl:template match="/AAA/dict/dict/*">
<xsl:copy>
<xsl:apply-templates select="a"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a">
<xsl:attribute name="{translate(.,' ','_')}">
<xsl:apply-templates select="following-sibling::*[1]"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
I get the following results:
<a></a>
<dict James="1" Tammy="2" Pat="3" George="4" Fred="5"></dict>
<a></a>
<dict James="1" Tammy="2" Pat="3" George="4" Fred="5"></dict>
Which is what I want but in a different format. I need the following
output to look like this below:
<labels>
James="1"
Tammy="2"
Pat="3"
George="4"
Fred="5"
</labels>
<labels>
James="1"
Tammy="2"
Pat="3"
George="4"
Fred="5"
</labels>
I am still a newbie at this. Any help would be great.
Thanks in advance.