This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
copying attributes
- To: "xsl-list" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] copying attributes
- From: "Russ Holmes" <rholmes at elite dot com>
- Date: Tue, 9 Jan 2001 11:13:45 +1300
- Reply-To: xsl-list at lists dot mulberrytech dot com
When converting the result of three SQL queries to xml I generate something
like;
<breakfasts>
<life_to_date>
<z breakfast="bacon" servings="2000"/>
<z breakfast="eggs" servings="2000"/>
<z breakfast="cereal" servings="7000"/>
</life_to_date>
<y2000>
<z breakfast="bacon" servings="130">
<z breakfast="eggs" servings="100">
</y2000>
<january>
<z breakfast="eggs" servings="1">
</january>
</breakfasts>
..you can assume that any 'breakfast' types in the y2000 and january nodes
will show in the life_to_date node..
I would like to load this xml into a Data Source Object using the following
format;
<z breakfast="bacon" january_servings="" y2000_servings="130"
life_to_date_servings="2000"/>
<z breakfast="eggs" january_servings="1" y2000_servings="100"
life_to_date_servings="2000"/>
<z breakfast="cereal" january_servings="" y2000_servings=""
life_to_date_servings="7000"/>
Can I transform into this format? If so how?
In trying to create the 'january_servings' node I've tried;
<xsl:template match="/breakfasts/life_to_date/z">
<z>
<xsl:for-each select="@breakfast" >
<xsl:attribute name="breakfast"><xsl:value-of
select="."/></xsl:attribute>
<xsl:attribute name="january_servings"><xsl:value-of
select="/breakfasts/january[@breakfast=.]/@servings"/>
</xsl:attribute>
</xsl:for-each>
</z>
</xsl:template>
But with no success...could anyone help me out here? I'm trying to say for
each life_to_date/z node, iterate through the 'breakfast' attributes and
create new attributes with values that match the value of the corresponding
'january' node..where the 'breakfast' attibutes match..
Thanks heaps,
Russ
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list