Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

XSL Coding Stumped

  • 10-03-2008 07:10PM
    #1
    Closed Accounts Posts: 214 ✭✭


    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 for the file above 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>


    Any help greatly appreciated


Advertisement