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

[no subject]

eurofxref
<Cube>
<Cube @time>
   <Cube @currency/>
   <Cube @currency/>
   ...
</Cube>
</Cube>

so ideally you'd want

<Cube>
<-- INSERT <ROW>
<Cube @time>
   <Cube @currency/>
   <Cube @currency/>
   ...
</Cube>
<-- INSERT </ROW>
</Cube>

So if you could handle the case without breaking the hierarchy and then adding
it back in that would probably be best. Just sort of seems like double work.


-----Original Message-----
From: jcastanheira@xxxxxxxxxxxxxxxxxxxx
[mailto:jcastanheira@xxxxxxxxxxxxxxxxxxxx]
Sent: Friday, November 19, 2004 10:45 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Attribute to elements conversion, "preserving "and
simplifying hierarchy, insertion of new element


Hello,

I've been trying to convert the following XML structure
(http://www.ecb.int/stats/eurofxref/eurofxref-hist.xml) to achieve
something like this :

<?xml version="1.0" encoding="UTF-8" ?>
<EuroFxRef>
   <Row>
     <time>2004-11-19</time>
     <USD>1.302</USD>
     ....
   </Row>
     <time>2004-11-18</time>
     <USD>1.3024</USD>
     ....
</EuroFxRef>

After checking the list and FAQ for similar problems (attribute to element
conversion, hierarchy, ...), I came up with the following XSL which is
close to what I'm trying to get but not quite it as I do not see how to
insert the <Row> element as shown here above:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
     <xsl:output method="xml"/>
     <xsl:template match="/">
        <EuroFxRef>
           <xsl:apply-templates select="*|@*"/>
       </EuroFxRef>
     </xsl:template>
     <xsl:template match="*">
         <xsl:apply-templates select="*|@*"/>
     </xsl:template>
    <xsl:template match="@time">
        <xsl:element name="{name()}">
            <xsl:value-of select="."/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="@currency">
           <xsl:variable name="Thename" select="."/>
           <xsl:variable name="Therate" select="../@rate"/>
           <xsl:element name="{$Thename}">
               <xsl:value-of select="$Therate"/>
          </xsl:element>
    </xsl:template>
    <xsl:template match="@rate"/>
</xsl:stylesheet>

Thanks in advance,

Joco


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

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.