Avatar of mavmanau
mavmanau
Flag for Australia asked on

Adding a new filter into XSL project

Hi Guys,

Thank you for taking the time to take a look at my question, your assistance is most appreciated.  

Take the sample XML below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <row>
            <LoanNo>132138</LoanNo>
            <Method>Direct Debit</Method>
            <Status>Cleared</Status>
            <Cleared>241.38</Cleared>
            <DateSched>40210</DateSched>
            <Out_Interest>87.75</Out_Interest>
            <Out_Charges>55</Out_Charges>
            <Out_Costs>0</Out_Costs>
            <In_Actual>100.00</In_Actual>
            <Curr_Balance>-26.37</Curr_Balance>
            <Brand>FSM</Brand>
            <Product>NULL</Product>
            <Lead_Gen>Web FSM</Lead_Gen>
            <Broker_Code_ID>JSF0177667</Broker_Code_ID>
            <Broker_Code>FB - 01</Broker_Code>
            <Funded>40127.6845356134</Funded>
            <Request>325</Request>
            <Offer>325</Offer>
            <Title>Miss</Title>
            <First_Name>TEST</First_Name>
            <Middle_Name>TEST</Middle_Name>
            <Surname>TEST</Surname>
            <DOB>18209</DOB>
            <Email>test@hotmail.com</Email>
            <State>Western Australia</State>
            <Pay_Frequency>Fortnightly</Pay_Frequency>
            <RLD>NULL</RLD>
            <Home_Phone>07555555555</Home_Phone>
            <Mobile_Phone>07555555555</Mobile_Phone>
            <Loan_Status>Defaulted</Loan_Status>
            <Age_of_Loan>580.315464386571</Age_of_Loan>
            <Days_Ago>498</Days_Ago>
            <Loan_Funded>10/11/2009</Loan_Funded>
      </row>
</document>

to filter the product  - I build a selection box and populate it on the fly with all different products.  Below is the code that I use.

 <xsl:for-each select="/document/row[generate-id() = generate-id(key('product', Product)[1])]">
                        <listproductrow name="Product_{Product}" pvalue="{Product}">
                            <xsl:attribute name="selected">
                                <xsl:if test="Product = $product">
                                    <xsl:text>yes</xsl:text>
                                </xsl:if>
                            </xsl:attribute>
                        </listproductrow>
                    </xsl:for-each>

What I want to do, is to add a select box that has three options:
Never Paid (when In_Actual = 0)
Paid (When In_Actual > 0)
All (all of the above)

how would I go about this?  would I send select box value back to a javascript function then do a transform, or is there a way I can do it without sending the value out to javascript?

Any light you could shine on my question, I would be most appreciative!!
Web Languages and StandardsXMLJavaScript

Avatar of undefined
Last Comment
Gertone (Geert Bormans)

8/22/2022 - Mon
Gertone (Geert Bormans)

Well, since you do that for all filters allready,
I would suggest that you take the same approach.
(so roundtrip for a transform)

In this case however you don't have distinct values.
So when making the select you can't rely on a muenchian for-each as you do above,
but you have to hardcode the select in the gridview XSLT

I would suggest that you do the following: add a new filter variable, which can have three values
1 for positive values
0 for 0 values
-1 for all
And you can use that value (passed in as a parameter) in your filter XSLT

This is how I would tackle this, just to be consistent with the other filter values
mavmanau

ASKER
I worked out the hardcoding of the Select, I have done that on another filter but that was a numerical field where I was sending fixed variables through,

here was how I did that one:
(CODE IN FILTER.XSL)
 <xsl:for-each select="/document/row[generate-id() = generate-id(key('daysago', Days_Ago)[1][Daysago &gt; $daysago])]">
                        <listdaysagorow name="Days_Ago_{Days_Ago}" danvalue="{Days_Ago}">
                            <xsl:attribute name="selected">
                                <xsl:if test="Days_Ago &gt; $daysago ">
                                    <xsl:text>yes</xsl:text>
                                </xsl:if>
                            </xsl:attribute>
                        </listdaysagorow>
                    </xsl:for-each>

(code out of gridview.xsl   this is one of the options out of the select....to put them all in would fill this out much bigger.   )
  <option><xsl:attribute name="onclick">
                    <xsl:text>runTransform("</xsl:text>
                    <xsl:value-of select="$rld"/>
                    <xsl:text>","</xsl:text>
                    <xsl:value-of select="$brand"/>
                    <xsl:text>","</xsl:text>
                    <xsl:value-of select="$loanstatus"/>
                    <xsl:text>","</xsl:text>
                    <xsl:value-of select="$state"/>
                    <xsl:text>","</xsl:text>
                    <xsl:value-of select="$leadgen"/>
                    <xsl:text>","</xsl:text>
                    <xsl:value-of select="$product"/>
                     <xsl:text>","30","</xsl:text>
                    <xsl:value-of select="$sortvar"/>
                    <xsl:text>","1","</xsl:text>
                              <xsl:text>","</xsl:text>
                    <xsl:value-of select="$product"/>
                              <xsl:text>","</xsl:text>
                    <xsl:value-of select="$order"/>
                    <xsl:text>");</xsl:text>
                    </xsl:attribute>
                    <xsl:if test="$daysago = 30">
                             <xsl:attribute name="selected">yes</xsl:attribute>
                         </xsl:if>
                    No Payments in last 30 days(30+)
             </option>

so based on that how would the code in filter.xsl look roughly?
mavmanau

ASKER
I tried doing this...

 <xsl:for-each select="/document/row[generate-id() = generate-id(key('loanamt', In_Actual)[1][In_Actual &gt; $loanamtlow][In_Actual &lt; $loanamthigh])]">
                        <listdaysagorow name="In_Actual_{In_Actual}" invalue="{In_Actual}">
                            <xsl:attribute name="selected">
                                <xsl:if test="In_Actual &gt; $loanamtlow ">
                                    <xsl:text>yes</xsl:text>
                                </xsl:if>
                            </xsl:attribute>
                        </listdaysagorow>
                    </xsl:for-each>

but it doesn't appear to work.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mavmanau

ASKER
I got it!  thank you once again for your help....took it a couple of days to filter through what you were saying.  
mavmanau

ASKER
Thank you for the assist.

Very much appreciated!
Gertone (Geert Bormans)

welcome
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
mavmanau

ASKER
Have a great holiday!!
Gertone (Geert Bormans)

thx