Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

XSL Coding Stumped

Options
  • 10-03-2008 7: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