Re: [xsl] Re: Re: Re: Dynamic Filter Menus

Subject: Re: [xsl] Re: Re: Re: Dynamic Filter Menus
From: brian.witgen@xxxxxxxxxxx
Date: Mon, 29 Oct 2001 17:18:47 -0600

Im using Xalan within Cocoon 1 and no it did not flag the illegal variable
usage. The values I set in those variables come from a config file included
by my DTD. The config file gets updated by javascript with the new filters
each time the webpage is updated:

<!ENTITY fdata SYSTEM "/web/context/docs/conf/filter.data">

Instead of putting those values into a variable (since it is illegal within a key match), is there any problem with using the node directly like
such?:

<xsl:key name="vencatkey"       match="entry[@category=/docs/categoryfilter]"          use="@vendor" />
<xsl:key name="venverkey"       match="entry[@version=/docs/versionfilter]"                use="@vendor" />
<xsl:key name="vencatverkey" match="entry[@category=/docs/categoryfilter and
                                                                                         @version=/docs/versionfilter]"                use="@vendor"
/>
<xsl:key name="catvenkey"       match="entry[@vendor=/docs/vendorfilter]"                  use="@category" />
<xsl:key name="catverkey"        match="entry[@version=/docs/versionfilter]"                 use="@category" />
<xsl:key name="catvenverkey" match="entry[@vendor=/docs/vendorfilter and
                                                                                        @version=/docs/versionfilter]"                 use="@category"
 />
<xsl:key name="vervenkey"       match="entry[@vendor=/docs/vendorfilter]"                  use="@version" />
<xsl:key name="vercatkey"        match="entry[@category=/docs/categoryfilter]"           use="@version" />
<xsl:key name="vervencatkey" match="entry[@vendor=/docs/vendorfilter and
                                                                                         @category=/docs/categoryfilter]"           use="@version" />

Im going to need to do some work on learning the DOM stuff, but Id like to at least have proper code  running in the interim.





Dimitre Novatchev <dnovatchev@xxxxxxxxx>@lists.mulberrytech.com on
10/27/2001 12:30:14 AM

Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx

Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To:   xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc:

Subject:  [xsl] Re: Re: Re: Dynamic Filter Menus


> 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:

Unfortunately, You didn't get the idea. I suggested that you modify your
stylesheet
after it has been loaded and compiled (after you have obtained a
DOMDocument object
containing the stylesheet), but ***before*** the transformation is started.

Therefore this excludes any usage of "xsl:script" (BTW there's no such
element in
XSLT 1.0).

> 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"
/>


The above xsl:key definition is illegal -- references to variables are not
allowed
in the match pattern of xsl:key. This is to avoid circular definitions, as
global
variables may be defined using the key() function.

In case your XSLT processor did not flag this as error, it is better to use
a truly
compliant XSLT processor instead.

Even if this worked, it suffers from a "combinatorial explosion" problem
and should
not be preferred to other, more compact and maintainable solutions.

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


Current Thread