[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Dynamic Filter Menus

Subject: Re: Re: Dynamic Filter Menus
From: brian.witgen@xxxxxxxxxxx
Date: Fri, 26 Oct 2001 18:51:47 -0500
witgen

I figured it out, so here is what I had to use. I couldnt use DOM like was
suggested because it didnt like "xsl:script" for some reason and when I
tried to use it directly with entries like:

document.getdocs.filterbyversion.options[document.getdocs.filterbyversion.selectedIndex].text

it gave me errors on the brackets. I didnt realize a variable could be set outside the templates and still have the value available to all templates
created, but it works.

Outside my templates I used:

<xsl:variable name="vven" select="/docs/vendorfilter" />
<xsl:variable name="vcat" select="/docs/categoryfilter" />
<xsl:variable name="vver" select="/docs/versionfilter" />

<xsl:key name="venkey"       match="entry" use="@vendor" />
<xsl:key name="catkey"       match="entry" use="@category" />
<xsl:key name="verkey"       match="entry" use="@version" />
<xsl:key name="vencatkey"    match="entry[@category=$vcat]"                    use="@vendor" />
<xsl:key name="venverkey"    match="entry[@version=$vver]"                     use="@vendor" />
<xsl:key name="vencatverkey" match="entry[@category=$vcat and @version=$vver]" use="@vendor" />
<xsl:key name="catvenkey"    match="entry[@vendor=$vven]"                      use="@category" />
<xsl:key name="catverkey"    match="entry[@version=$vver]"                     use="@category" />
<xsl:key name="catvenverkey" match="entry[@vendor=$vven and @version=$vver]"   use="@category" />
<xsl:key name="vervenkey"    match="entry[@vendor=$vven]"                      use="@version" />
<xsl:key name="vercatkey"    match="entry[@category=$vcat]"                    use="@version" />
<xsl:key name="vervencatkey" match="entry[@vendor=$vven and @category=$vcat]"  use="@version" />


and within the template where the menus are created I used the following to get the unique lists from the indexes:

   <xsl:variable name="uven"       select="entry[generate-id() = generate-id(key('venkey', @vendor)[1])]"/>
   <xsl:variable name="uvencat"    select="entry[generate-id() = generate-id(key('vencatkey', @vendor)[1])]"/>
   <xsl:variable name="uvenver"    select="entry[generate-id() = generate-id(key('venverkey', @vendor)[1])]"/>
   <xsl:variable name="uvencatver" select="entry[generate-id() = generate-id(key('vencatverkey', @vendor)[1])]"/>
   <xsl:variable name="ucat"       select="entry[generate-id() = generate-id(key('catkey', @category)[1])]"/>
   <xsl:variable name="ucatven"    select="entry[generate-id() = generate-id(key('catvenkey', @category)[1])]"/>
   <xsl:variable name="ucatver"    select="entry[generate-id() = generate-id(key('catverkey', @category)[1])]"/>
   <xsl:variable name="ucatvenver" select="entry[generate-id() = generate-id(key('catvenverkey', @category)[1])]"/>
   <xsl:variable name="uver"       select="entry[generate-id() = generate-id(key('verkey', @version)[1])]"/>
   <xsl:variable name="uverven"    select="entry[generate-id() = generate-id(key('vervenkey', @version)[1])]"/>
   <xsl:variable name="uvercat"    select="entry[generate-id() = generate-id(key('vercatkey', @version)[1])]"/>
   <xsl:variable name="uvervencat" select="entry[generate-id() = generate-id(key('vervencatkey', @version)[1])]"/>

This might have been what you were trying to explain to me Dimitre.......

Anyway, thanks for all help provided!

Brian Witgen




brian.witgen@xxxxxxxxxxx@l... on 10/26/2001 04:56:34 PM

Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx

Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To:   xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc:

Subject:  Re:  Re: Dynamic Filter Menus




Solution one looks like the best way to go , but unfortunately Im not up to
speed on DOM. Im assuming your solution is something like using
"xsl:script" with javascript outside the templates and before I create the
indexes and then use the function in the index creation. According to
w3.org, I should be able to use "xsl:script", but the tag isnt recognised.
I must be way off. Can you pass me a little more info about the
javascript/DOM solution. Im continuing to look for info/examples but not
finding too much.

Thanks for your help.




Dimitre Novatchev <dnovatchev@xxxxxxxxx>@lists.mulberrytech.com on
10/26/2001 11:59:09 AM

Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx

Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To:   xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc:

Subject:   Re: Dynamic Filter Menus


> ....and with those entries, I have created 3 keys based on the vendor,
category,
> and version:
>
> <xsl:key name="venkey" match="entry" use="@vendor" />
> <xsl:key name="catkey" match="entry" use="@category" />
> <xsl:key name="verkey" match="entry" use="@version" />
>
> The menus are a unique list of the vendors, categories, or versions to
> select. I dont have any probelm with getting the initial unique list when
> no filters have been selected yet. I am trying to make the menus work in
> such a way that when one filter is selected, the other two menus that do
> not have a filter selected will show a unique list of only those values
> that match the selected filter.
>
> Example:  With the entries above, if I choose version 2.9 as a filter,
then
> only "newmanufacturer" will show up in the vendor menu (once being
unique)
> and "gorycat2" and "gorycat3" will both show up in the category menu.
>
> I have an xml file that is updated with the selected filter for each menu
> through javascript and pulled into the template as parameters:
>
>                <xsl:call-template name="filtermenus">
>                     <xsl:with-param name="pven" select
="/docs/vendorfilter" />
>                     <xsl:with-param name="pcat" select
="/docs/categoryfilter" />
>                     <xsl:with-param name="pver" select
="/docs/versionfilter" />
>                </xsl:call-template>

One solution is (because you're passing parameters from javascript) just to
update
the definitions of the "xsl:key" -s using DOM before performing the
transformation:

 <xsl:key name="venkey" match="entry[fExp1 and fExp2 and fExp3]" use="
@vendor" />
 <xsl:key name="catkey" match="entry[fExp1 and fExp2 and fExp3]" use="
@category" />
 <xsl:key name="verkey" match="entry[fExp1 and fExp2 and fExp3]" use="
@version" />

Another solution is to construct an RTF (and convert it to a node-set)
containing
only the "entry" elements that satisfy the filters. Then use the key()
function on
this document tree. Assuming that the "entry" elements are children of the
current
node:

<xsl:variable name="vFiltered">
  <xsl:copy-of select="entry[fExp1 and fExp2 and fExp3]"/>
<xsl:variable>

<xsl:variable name="vFilteredEntries" select="xx:node-set($vFiltered)"/>

<xsl:for-each select="$vFilteredEntries">
   <xsl:variable name="uven" select="entry[generate-id()
                                       = generate-id(key('venkey',
@vendor)[1])]"/>
   <xsl:variable name="ucat" select="entry[generate-id()
                                       = generate-id(key('catkey',
@category)[1])]"/>
   <xsl:variable name="uver" select="entry[generate-id()
                                       = generate-id(key('verkey',
@version)[1])]"/>

<!--  Do whatever is necessary with the above 3 variables here -->
</xsl:for-each>

Here the "xx" prefix must be associated with the namespace in which the
vendor-supplied extension function node-set() is defined/implemented.

Hope this helped.

Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.