[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: Tue, 23 Nov 2004 10:06:52 -0500
Finally, I've found the solution. Here it is :

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

	<xsl:template match="/">
		<eurofxref>
			<xsl:apply-templates/>
		</eurofxref>
	</xsl:template>
	<xsl:template match="*[@*]">
		<Row>
			<time>
				<xsl:value-of select="./@time"/>
			</time>
			<xsl:apply-templates select="*/@currency"/>
	</Row>

	</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:stylesheet>

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/ .



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

Current Thread