[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Attribute to elements conversion, "preserving "and simplifying hierarchy, insertion of new element
Subject: [xsl] Attribute to elements conversion, "preserving "and simplifying hierarchy, insertion of new element From: "jcastanheira@xxxxxxxxxxxxxxxxxxxx" <jcastanheira@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 19 Nov 2004 10:45:23 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] defining a key, Osman Çınar Eren | Thread | RE: [xsl] Attribute to elements con, Joe Heidenreich |
[xsl] On Sourceforge: Cool: Saxon d, Gunther Schadow | Date | RE: [xsl] xsl and xalan extensions/, Adam Morgan |
Month |