|
Subject: Re: [xsl] genarate key using a variable From: "M. David Peterson" <conners_dad@xxxxxxx> Date: Mon, 1 Sep 2003 03:21:52 -0600 |
This method should still be effective for you... However, I am making the
assumption that the user will first select an attribute they want to sort by
and then select a value. Is this not the case? Or are you saying that they
can select a value they want to sort by and then select the attribute. e.g.
They want to know every transaction that contains the dollar figure $25.00
or took place on the date 23/04/2004 and have it return deposits,
withdrawals, etc... Or is it something entirely different from that which I
have described... In any case I would try the following... Let me know if
im not understanding the real issue and ill give it some more thought...
Add a "Search_By" param and a "Sort_By" param and then use another
<xsl:choose> element structure to choose which value to search by and which
to sort by...
So in other words add the following to the param list..
<xsl:param name="Search_By">Var_1</xsl:param>
<xsl:param name="Sort_By">Var_2</xsl:param>
and the following the the template body...
<xsl:choose>
<xsl:when test="$Search_By = 'Var_1'">
<xsl:choose>
<xsl:when test="$var_1 = 'deposit'">
<xsl:for-each select="key('varMatch_Deposit', $var_2)">
Deposit ID: <xsl:value-of select="@id"/><br/>
Amount: <xsl:value-of select="."/><br/><br/><hr/>
</xsl:for-each>
</xsl:when>
<xsl:when test="$var_1 = 'withdrawal'">
<xsl:for-each select="key('varMatch_Withdrawal', $var_2)">
Other ID: <xsl:value-of select="@id"/><br/>
Other Amount: <xsl:value-of select="."/><br/><br/><hr/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
//code for otherwise
</xsl:otherwise>
</xsl:when>
</xsl:choose>
<xsl:when test="Search_By = 'Var_2'">
//code for this option
</xsl:when>
<xsl:otherwise>
// code for otherwise
</xsl:otherwise>
</xsl:choose>
Best of luck!
M.David
----- Original Message -----
From: <aruniima.chakrabarti@xxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, September 01, 2003 3:02 AM
Subject: RE: [xsl] genarate key using a variable
> Thank you David & Mukund. But my problem is bit tricky...
> I have an xml like the below. & I have to filter the based any of
> attributes's value. That is the user can specify that which of the
> columns' data he wud like to filter based of any that column's values.
> Something like excel sheet data filter. So that's where exactly I am stuck
> as I unable to figure out how to have both the attribute & its value as
> parameter.
> Also, the numbers of Columns C1, C2 etc are not limited
>
> <?xml version="1.0"?>
>
> <PickList>
> <TotalRows>33</TotalRows>
> <Columns C1="Deposit" C2="Period" C3="Status" C4="Value Date" C5="Maturity
> Date" C6="Deposit No"/>
> <Tags>ctlMskDepositNo *</Tags>
> <Rows>
> <Row C1="1" C2="1" C3="Closed Today" C4="23/10/2003" C5="23/04/2004"
> C6="1"/>
> <Row C1="2" C2="1" C3="Open Today" C4="06/11/2003" C5="05/01/2004"
> C6="2"/>
> <Row C1="3" C2="1" C3="Open Today" C4="29/02/2004" C5="29/04/2004"
> C6="3"/>
> <Row C1="7" C2="1" C3="Matured" C4="29/02/2004" C5="29/04/2004" C6="7"/>
> <Row C1="8" C2="1" C3="Closed" C4="29/02/2004" C5="29/04/2004" C6="8"/>
> <Row C1="9" C2="1" C3="Closed" C4="29/02/2004" C5="29/04/2004" C6="9"/>
> <Row C1="10" C2="1" C3=" Matured" C4="29/02/2004" C5="29/04/2004"
> C6="10"/>
> <Row C1="11" C2="1" C3="Open Today" C4="29/02/2004" C5="19/04/2004"
> C6="11"/>
> <Row C1="16" C2="1" C3="Open Today" C4="29/02/2004" C5="29/04/2004"
> C6="16"/>
> <Row C1="17" C2="1" C3="Open Today" C4="29/02/2004" C5="29/04/2004"
> C6="17"/>
> <Row C1="18" C2="1" C3="Open Today" C4="29/02/2004" C5="29/04/2004"
> C6="18"/>
> <Row C1="19" C2="1" C3="Closed" C4="29/02/2004" C5="19/04/2004" C6="19"/>
> <Row C1="32" C2="1" C3="Open Today" C4="29/02/2004" C5="09/04/2004"
> C6="32"/>
> <Row C1="33" C2="1" C3="Open Today" C4="29/02/2004" C5="30/03/2004"
> C6="33"/>
> </Rows>
> </PickList>
> Regards,
> aruniima
>
> -----Original Message-----
> From: M. David Peterson [mailto:conners_dad@xxxxxxx]
> Sent: Monday, September 01, 2003 1:56 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] genarate key using a variable
>
> I forgot that I needed to send this message in plain text format. If the
> other one gets through I apologize for the repeat mail...
>
> Original text of my email....
>
> Hey Aruniima,
>
> You've stumbled upon one that puzzled me for awhile. But I finally came
> up
> with a quick and easy workaround. Im sure there are others but this one
> is
> simple and it works which are my number one rules of coding.
>
> My assumption is that the number of choices the user has as far as node
> names is fairly limited (e.g. Deposits, Withdrawls, etc...) and as such it
> should be a quick and easy task for the xsl:choose element...
>
> heres the xml file...
>
> <?xml version="1.0"?>
> <?xml-stylesheet type="text/xsl" href="transactions.xslt" ?>
> <transactions>
> <deposits>
> <deposit id="001">25.00</deposit>
> <deposit id="002">25.00</deposit>
> <deposit id="003">35.00</deposit>
> <deposit id="004">10.00</deposit>
> <deposit id="005">12.00</deposit>
> <deposit id="006">25.00</deposit>
> <deposit id="007">25.00</deposit>
> </deposits>
> <withdrawals>
> <withdrawal id="001">5.00</withdrawal>
> <withdrawal id="002">2.00</withdrawal>
> <withdrawal id="003">5.00</withdrawal>
> <withdrawal id="004">10.00</withdrawal>
> <withdrawal id="005">12.00</withdrawal>
> <withdrawal id="006">250.00</withdrawal>
> <withdrawal id="007">250.00</withdrawal>
> </withdrawals>
> </transactions>
>
>
>
> and heres the related xslt file named transactions.xslt.... just change
> the
> variables accordingly
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
>
> <xsl:variable name="var_1">deposit</xsl:variable>
> <xsl:variable name="var_2">25.00</xsl:variable>
> <xsl:key name="varMatch_Deposit" match="//deposit" use="."/>
> <xsl:key name="varMatch_Withdrawal" match="//withdrawal" use="."/>
>
> <xsl:template match="/">
>
> <xsl:choose>
> <xsl:when test="$var_1 = 'deposit'">
>
> <xsl:for-each select="key('varMatch_Deposit', $var_2)">
>
> Deposit ID: <xsl:value-of select="@id"/><br/>
> Amount: <xsl:value-of select="."/><br/><br/><hr/>
>
> </xsl:for-each>
>
> </xsl:when>
> <xsl:when test="$var_1 = 'withdrawal'">
>
> <xsl:for-each select="key('varMatch_Withdrawal', $var_2)">
>
> Other ID: <xsl:value-of select="@id"/><br/>
> Other Amount: <xsl:value-of select="."/><br/><br/><hr/>
>
> </xsl:for-each>
>
> </xsl:when>
> <xsl:otherwise>
>
> //code for otherwise
>
> </xsl:otherwise>
> </xsl:choose>
>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Hope this helps.
>
> Best of luck!
>
> M.David
>
>
>
>
> ----- Original Message -----
> From: <aruniima.chakrabarti@xxxxxxxxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Monday, September 01, 2003 12:16 AM
> Subject: [xsl] genarate key using a variable
>
>
> > Hi All,
> > Is it possible to generate a xsl:key using a variable ?
> > As in xsl:key element it does not allow me to use a variable in either
> > match or use attribute. So is there any other way to do the same...
> >
> > e.g.
> > I want to search for all Rows with attribute say "@Deposit = 1"
> > where I receive both the attribute & the attribute value as parameters
> > from the user.
> >
> >
> >
> > Regards,
> > aruniima
> >
> >
> >
> > DISCLAIMER:
> > This message contains privileged and confidential information and is
> > intended only for the individual named.If you are not the intended
> > recipient you should not disseminate,distribute,store,print, copy or
> > deliver this message.Please notify the sender immediately by e-mail if
> > you
> > have received this e-mail by mistake and delete this e-mail from your
> > system.E-mail transmission cannot be guaranteed to be secure or
> > error-free
> > as information could be intercepted,corrupted,lost,destroyed,arrive late
> > or incomplete or contain viruses.The sender therefore does not accept
> > liability for any errors or omissions in the contents of this message
> > which arise as a result of e-mail transmission. If verification is
> > required please request a hard-copy version.
> >
> > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> >
> >
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
>
>
> DISCLAIMER:
> This message contains privileged and confidential information and is
> intended only for the individual named.If you are not the intended
> recipient you should not disseminate,distribute,store,print, copy or
> deliver this message.Please notify the sender immediately by e-mail if you
> have received this e-mail by mistake and delete this e-mail from your
> system.E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted,corrupted,lost,destroyed,arrive late
> or incomplete or contain viruses.The sender therefore does not accept
> liability for any errors or omissions in the contents of this message
> which arise as a result of e-mail transmission. If verification is
> required please request a hard-copy version.
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] genarate key using a vari, aruniima . chakrabar | Thread | RE: [xsl] genarate key using a vari, Mukul Gandhi |
| RE: [xsl] genarate key using a vari, aruniima . chakrabar | Date | RE: [xsl] genarate key using a vari, Mukul Gandhi |
| Month |