[no subject]

<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: [xsl] 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