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

Re: Dynamic Filter Menus

Subject: Re: Dynamic Filter Menus
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 26 Oct 2001 09:59:09 -0700 (PDT)
xsl dynamic filter javascript
> ....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


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.