F
FlickChick
I don't usually post questions, but 2 days of googleing and frustration
have broken my resistance.
I have some scary looking xml that looks something like this:
<?xml version="1.0"?>
<foo xmlns='urn:xxx:yyy'>
<stuff type="why">
<morestuff type="do">
<evenmore>
<stuff_overload type="this">
<finally name="{last}">
<value>Doe</value>
</finally>
<finally name="{first}">
<value>John</value>
</finally>
<finally name="{number}">
<value>14</value>
</finally>
</stuff_overload>
</evenmore>
</morestuff>
</stuff>
<stuff type="why">
<morestuff type="do">
<evenmore>
<stuff_overload type="this">
<finally name="{last}">
<value>Smith</value>
</finally>
<finally name="{first}">
<value>Jane</value>
</finally>
<finally name="{number}">
<value>15</value>
</finally>
</stuff_overload>
</evenmore>
</morestuff>
</stuff>
</foo>
Which I would like to transform into this:
John,Doe,14
Jane,Smith,15
So I wrote this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xdm="urn:xxx:yyy">
<xslutput method="text" indent="yes"/>
<xsl:strip-space elements="xdm:foo xdm:stuff xdm:morestuff xdm:evenmore
xdm:stuff_overload"/>
<xsl:template match="xdm:finally">
<xsl:apply-templates select="xdm:finally[@name='{first}']"/>
<xsl:apply-templates select="xdm:finally[@name='{last}']"/>
<xsl:apply-templates select="xdm:finally[@name='{number}']"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{first}']"><xsl:value-of
select="xdm:value"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{last}']">,<xsl:value-of
select="xdm:value"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{number}']">,<xsl:value-of
select="xdm:value"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
But my output looks like:
,DoeJohn,14
,SmithJane,15
I've also tried nesting the templates, and about 100 other things. Any
ideas on what I'm doing wrong would be a great help.
-tia
have broken my resistance.
I have some scary looking xml that looks something like this:
<?xml version="1.0"?>
<foo xmlns='urn:xxx:yyy'>
<stuff type="why">
<morestuff type="do">
<evenmore>
<stuff_overload type="this">
<finally name="{last}">
<value>Doe</value>
</finally>
<finally name="{first}">
<value>John</value>
</finally>
<finally name="{number}">
<value>14</value>
</finally>
</stuff_overload>
</evenmore>
</morestuff>
</stuff>
<stuff type="why">
<morestuff type="do">
<evenmore>
<stuff_overload type="this">
<finally name="{last}">
<value>Smith</value>
</finally>
<finally name="{first}">
<value>Jane</value>
</finally>
<finally name="{number}">
<value>15</value>
</finally>
</stuff_overload>
</evenmore>
</morestuff>
</stuff>
</foo>
Which I would like to transform into this:
John,Doe,14
Jane,Smith,15
So I wrote this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xdm="urn:xxx:yyy">
<xslutput method="text" indent="yes"/>
<xsl:strip-space elements="xdm:foo xdm:stuff xdm:morestuff xdm:evenmore
xdm:stuff_overload"/>
<xsl:template match="xdm:finally">
<xsl:apply-templates select="xdm:finally[@name='{first}']"/>
<xsl:apply-templates select="xdm:finally[@name='{last}']"/>
<xsl:apply-templates select="xdm:finally[@name='{number}']"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{first}']"><xsl:value-of
select="xdm:value"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{last}']">,<xsl:value-of
select="xdm:value"/>
</xsl:template>
<xsl:template match="xdm:finally[@name='{number}']">,<xsl:value-of
select="xdm:value"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
But my output looks like:
,DoeJohn,14
,SmithJane,15
I've also tried nesting the templates, and about 100 other things. Any
ideas on what I'm doing wrong would be a great help.
-tia