-
XML/XSL formatting issues
I need to format the following XML into a savings chart:
<SavingsChart>
<Header>Expected Differential Savings for xxx Trucks and Tractors versus
Competition</Header>
<Disclaimer>Figures in Table are net differences in expected dollar costs
or value of xxx vs competitor</Disclaimer>
<CompetitorEngines>
<CompetitorEngine>
<Type>ISB 5.9L</Type>
<ValueCategory>
<Name>Resale value</Name>
<Savings>
<LowPrice>700</LowPrice>
<HighPrice>1,050</HighPrice>
<Range>$ 700 - 1,050</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Engine overhaul cost</Name>
<Savings>
<LowPrice>0</LowPrice>
<HighPrice>0</HighPrice>
<Range>Not Available</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Preventive maintenance costs</Name>
<Savings>
<LowPrice>167</LowPrice>
<HighPrice>250</HighPrice>
<Range>$ 167 - 250</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Repairability</Name>
<Savings>
<LowPrice>0</LowPrice>
<HighPrice>0</HighPrice>
<Range>Not Available</Range>
</Savings>
</ValueCategory>
<Total>
<Savings>
<LowPrice>867</LowPrice>
<HighPrice>1,300</HighPrice>
<Range>$ 867 - 1,300</Range>
</Savings>
</Total>
</CompetitorEngine>
<CompetitorEngine>
<Type>ISC 8.3L</Type>
<ValueCategory>
<Name>Resale value</Name>
<Savings>
<LowPrice>700</LowPrice>
<HighPrice>1,050</HighPrice>
<Range>$ 700 - 1,050</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Engine overhaul cost</Name>
<Savings>
<LowPrice>0</LowPrice>
<HighPrice>0</HighPrice>
<Range>Not Available</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Preventive maintenance costs</Name>
<Savings>
<LowPrice>288</LowPrice>
<HighPrice>432</HighPrice>
<Range>$ 288 - 432</Range>
</Savings>
</ValueCategory>
<ValueCategory>
<Name>Repairability</Name>
<Savings>
<LowPrice>0</LowPrice>
<HighPrice>0</HighPrice>
<Range>Not Available</Range>
</Savings>
</ValueCategory>
<Total>
<Savings>
<LowPrice>988</LowPrice>
<HighPrice>1,482</HighPrice>
<Range>$ 988 - 1,482</Range>
</Savings>
</Total>
</CompetitorEngine>
</CompetitorEngines>
<Footer>(Figures in table are net differences in expected dollar costs
or value of xxx vs. competitor)</Footer>
</SavingsChart>
The Savings chart has the format:
Value Category ISB 5.9L ISC 8.3L
Resale value $ 700 - 1,050 $ 700 - 1,050
Engine overhaul cost Not Available Not Available
Preventive maintenance costs $ 167 - 250 $ 288 - 432
Repairability Not Available Not Available
Total $ 867 - 1,300 $ 988 - 1,482
There can be up to 12 CompetitorEngine/ValueCategories, and 4 CompetitorEngine/Types
I have tried evry combination of XSL templates but no matter what, I can
not get it to work. My latest incarnation returns multiple value categories...
Any help would greatly be appreciated.
-
Re: XML/XSL formatting issues
If I understand what you wanted to output, I think that this will work for
you:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl utput method="html"/>
<xsl:template match="/">
<html>
<head>
<title>Savings Chart</title>
</head>
<body>
<h1>Savings Chart</h1>
<table>
<tr>
<th>Value Category</th><xsl:apply-templates select="//Type"/>
</tr>
<xsl:for-each select="/SavingsChart/CompetitorEngines/CompetitorEngine[1]/ValueCategory">
<xsl:variable name="category" select="Name"/>
<tr>
<td><xsl:value-of select="$category"/></td><xsl:apply-templates
select="//ValueCategory[Name=$category]/Savings/Range"/>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="Type">
<th><xsl:value-of select="."/></th>
</xsl:template>
<xsl:template match="Range">
<td><xsl:value-of select="."/></td>
</xsl:template>
</xsl:transform>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|