[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

copying attributes

Subject: copying attributes
From: "Russ Holmes" <rholmes@xxxxxxxxx>
Date: Tue, 9 Jan 2001 11:13:45 +1300
 copying attributes
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.