Subject: [xsl] Re: Dynamic Filter Menus From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 26 Oct 2001 09:59:09 -0700 (PDT) |
> ....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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] String Manipulation in XS, Chris Bayes | Thread | Re: [xsl] Re: Dynamic Filter Menus, brian . witgen |
Re: [xsl] escaping from CDATA, David Carlisle | Date | Re: [xsl] String Manipulation in XS, David Carlisle |
Month |