XSL newbie

Discussion in 'XML' started by egan006@gmail.com, Mar 10, 2008.

  1. Guest

    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>
     
    , Mar 10, 2008
    #1
    1. Advertising

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

    A simpler solution is <xsl:text>,</xsl:text>

    > <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)" />


    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Mar 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Flood
    Replies:
    0
    Views:
    1,022
    Kevin Flood
    Sep 8, 2004
  2. Kevin Flood
    Replies:
    1
    Views:
    2,739
    Kevin Flood
    Sep 13, 2004
  3. Klaus Friese
    Replies:
    0
    Views:
    468
    Klaus Friese
    Nov 22, 2004
  4. Replies:
    1
    Views:
    3,611
    A. Bolmarcich
    May 27, 2005
  5. Rob Smegma
    Replies:
    1
    Views:
    1,816
    shaun
    Sep 26, 2005
Loading...

Share This Page