[xsl] RE: Attribute to elements conversion, "preserving "and simplifying hierarchy, insertion of new element

Subject: [xsl] RE: Attribute to elements conversion, "preserving "and simplifying hierarchy, insertion of new element
From: "jcastanheira@xxxxxxxxxxxxxxxxxxxx" <jcastanheira@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Nov 2004 03:46:56 -0500
Yes. Han (thank you) provided the following solution, which inserts a <row>
after each time/currency combination but it is not exactly the end result
I'd like to reach :

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method='xml'
indent='no' omit-xml-declaration='yes'/>

<xsl:template match='/'>
<x>
<xsl:apply-templates select='//Cube[not(*)]'/>
</x>
</xsl:template>

<xsl:template match='Cube'>
<row>
<time><xsl:value-of select="../@time"/></time>
<xsl:element name="{@currency}"><xsl:value-of
select="@rate"/></xsl:element>
</row>
</xsl:template>

</xsl:stylesheet>

Result :

- <x>
- <row>
  <time>2004-11-19</time>
  <USD>1.302</USD>
  </row>
- <row>
  <time>2004-11-19</time>
  <JPY>134.97</JPY>
  </row>
- <row>

The end result would be something like :
Result :

- <x>
- <row>
      <time>2004-11-19</time>
         <USD>1.302</USD>
         <JPY>134.97</JPY>
  </row>
- <row>
     <time>2004-11-18</time>
...

Subject: RE: [xsl] Attribute to elements conversion, "preserving "and
simplifying hierarchy, insertion of new element
From: "Joe Heidenreich" <HeidenreichJ@xxxxxxxx>
Date: Fri, 19 Nov 2004 11:38:04 -0500

Do you want the <Row> to appear for each date?

Jeni has a great example on how to add hierarchy to a flat structure. You
can
view that here:
http://www.biglist.com/lists/xsl-list/archives/200012/msg00175.html



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

Current Thread