Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: transpose with logic transpose with logicTo: NULL Date: 3/31/2005 8:35:00 PM hi
i'm very new to xslt and have the task to transpose one structure into
another. i already found solutions on the net but could not get it to work
with my problem:
Source XML:As you can see is that i have 3 records in xml but only 2 logical
ones because a record is defined over its ID.
---
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Record>
<ID>1</ID>
<Name>criteria1</Name>
<Value>44</Value>
</Record>
<Record>
<ID>1</ID>
<Name>criteria2</Name>
<Value>1920</Value>
</Record>
<Record>
<ID>3</ID>
<Name>criteria3</Name>
<Value>98</Value>
</Record>
<Record>
<ID>7</ID>
<Name>criteria2</Name>
<Value>18</Value>
</Record>
</NewDataSet>
Target XML: my xslt should now be able to sum that like this. i must concat
these 3 xml records into 2 logical xml records.
---
<?xml version="1.0" standalone="yes"?>
<RecordCollection>
<Record>
<ID>1</ID>
<C1>44</C1>
<C2>1920</C2>
<C3>98</C3>
</Record>
<Record>
<ID>7</ID>
<C2>18</C2>
</Record>
</RecordCollection>
My Solution: here is my solution which is not working because i really don't
know how to go on now...
---
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:transform xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version =
"1.0" xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xsl:template match = "/">
<RecordCollection>
<xsl:for-each select = "NewDataSet/Record">
<xsl:variable name = "iOuterId" select = "ID"/>
<Record>
<xsl:apply-templates select = "ID"/>
<xsl:apply-templates select = "XCoordinate"/>
<xsl:for-each select = "/NewDataSet/Record">
<xsl:variable name = "iInnerID" select = "ID"/>
<xsl:variable name = "strCriteria" select = "Name"/>
<xsl:if test="$iInnerID = $iOuterId">
<xsl:choose>
<xsl:when test="$strCriteria = 'criteria1'">
<C1>
<xsl:value-of select = "Value"/>
</C1>
</xsl:when>
<xsl:when test="$strCriteria = 'criteria2'">
<C2>
<xsl:value-of select = "Value"/>
</C2>
</xsl:when>
<xsl:when test="$strCriteria = 'criteria2'">
<C2>
<xsl:value-of select = "Value"/>
</C2>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</Record>
</xsl:for-each>
</RecordCollection>
</xsl:template>
<xsl:template match = "ID">
<xsl:element name = "ID">
<xsl:value-of select = "."/>
</xsl:element>
</xsl:template>
<xsl:template match = "Value">
<xsl:element name = "X">
<xsl:value-of select = "."/>
</xsl:element>
</xsl:template>
</xsl:transform>
is there anybody out there in the crule xml world who can help my solution
to fix?
thank you very much
jazper
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
