XSL newbie

E

egan006

HI
I have a XML file in the form below, Which i'm looking to transform
with XSL

<Section>
<Name>Count(SITE_VALUE)</Name>
<Detail>
<Line>
<Case>Pass</Case>
<Instances>84</Instances>
<Percent>87.50</Percent>
<Drilldown>Y</Drilldown>
<OutputID>51</OutputID>
<OutputVal>1</OutputVal>
</Line>
<Line>
<Case>Fail</Case>
<Instances>8</Instances>
<Percent>8.33</Percent>
<Drilldown>Y</Drilldown>
<OutputID>51</OutputID>
<OutputVal>2</OutputVal>
</Line>
<Line>
<Case>Invalid</Case>
<Instances>4</Instances>
<Percent>4.17</Percent>
<Drilldown>Y</Drilldown>
<OutputID>51</OutputID>
<OutputVal>3</OutputVal>
</Line>
<Line>
<Case>Others</Case>
<Instances>0</Instances>
<Percent>0.00</Percent>
<Drilldown>N</Drilldown>
<OutputID>51</OutputID>
<OutputVal>-1</OutputVal>
</Line>
</Detail>
</Section>

I want this to output in the form
Line/Instances where case = "Pass"
then comma
Then Line/Instances where case = "Fail"
then comma
Then
Sum all instance where Line/Instances <> "pass" or "Fail"

So the output would be
84,8,4

I have some code which works(it outputs the pass and fail figures) its
the summing that i cannot get to work

Here is what i have

<xsl:for-each select="Detail/Line[Case='PASS']">
<xsl:value-of select="Instances" />
</xsl:for-each>
<xsl:value-of select="','"/>
<xsl:for-each select="Detail/Line[Case='FAIL']">
<xsl:value-of select="Instances" />
</xsl:for-each>
<xsl:value-of select="','"/>
<xsl:for-each select="Detail/Line[Case!='FAIL' and Case!='Pass']">
<xsl:value-of select="sum(Instances)" />
</xsl:for-each>
 
J

Joseph Kesselman

<xsl:value-of select="','"/>

A simpler solution is said:
<xsl:for-each select="Detail/Line[Case!='FAIL' and Case!='Pass']">
<xsl:value-of select="sum(Instances)" />
</xsl:for-each>

You're asking for the sum of the values of all instances children of
each individual specific Line. It sounds like what you want is the sum
of all instances that are children of those lines. If so, let XSLT do
the work:

<xsl:value-of select="sum(Detail/Line[Case!='FAIL' and
Case!='Pass']/Instances)" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top