XSL transformation

Hi Guys,

First off, thank you for taking the time to read my question!!

I have the following XSLT sample:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
            <xsl:variable name="scope" select="/clientdemo/transaction[account = 16 and tr_payment_date &gt; 20091231 and tr_payment_date &lt;= 20100131]"/>
            <xsl:value-of select="sum($scope/tr_to_agency) + sum($scope/tr_to_client)"/>
      </xsl:template>
</xsl:stylesheet>

that goes off the following example data:

<clientdemo><transaction><account>16</account><tr_to_agency>-2808.6</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20090202</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>750</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100505</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>0</tr_to_agency><tr_to_client>250</tr_to_client><tr_payment_date>20100527</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>1200</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100712</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>1</account><tr_to_agency>100</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100909</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091128</tr_listed_date></transaction>
<transaction><account>16</account><tr_to_agency>-35.8</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20100529</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20100703</tr_listed_date></transaction>
<transaction><account>16</account><tr_to_agency>-1000</tr_to_agency><tr_to_client>0</tr_to_client><tr_payment_date>20090330</tr_payment_date><Client_row_id>1</Client_row_id><tr_listed_date>20091230</tr_listed_date></transaction>
</clientdemo>

The XSLT sample works perfectly but what I want to do is this:

On The page where this XSLT goes, there is another XSLT section up the top.  If I click on one of the individual records it also sends through a variable called accountclientrowid.  What I want to happen, is IF it is clicked, the XSLT still works the same but it filters the data so that only the rows that have a clientrowid=accountclientrowid are added.

could someone please give me example of how this would work?

many thanks!!!
mavmanauNetwork Engineer/SysadminAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
Just assuming you have the server side ready

You likely have a parameter set in the request header when pushing the button (the accountclientrow)
Pass this parameter to the XSLT when you call it

In the XSLT get that parameter and do a test:
I assume it would be empty when you don't pass it
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="accountclientrowid"/>
    <xsl:template match="/">
        <xsl:variable name="scope" select="/clientdemo/transaction[account = 16 and tr_payment_date &gt; 20091231 and tr_payment_date &lt;= 20100131]"/>
        <xsl:choose>
            <xsl:when test="$accountclientrowid > 0">
                <xsl:value-of select="sum($scope[$accountclientrowid = Client_row_id]/tr_to_agency) + sum($scope[$accountclientrowid = Client_row_id]/tr_to_client)"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="sum($scope/tr_to_agency) + sum($scope/tr_to_client)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
mavmanauNetwork Engineer/SysadminAuthor Commented:
sweet...thank you....it is giving me a few issues but i should be able to work through them.

Thank you very much!!
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.