Re: [xsl] top level params and xsl:attribute magic?

Subject: Re: [xsl] top level params and xsl:attribute magic?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 21 Jan 2003 21:39:24 -0800 (PST)
> > What I think is the best solution of your problem is to set the 
> > value of the "select" attribute of a global xsl:param to the 
> > *string* XPath
> > expression. You can do this using the selectSingleNode() and then
> > setAttribute() methods. Then perform the transformation.
> 
> I can't do that, I'm not using MSXML.....! I'm using LibXSLT with 
> > AxKit on Mac OS X.
> 

This is not MSXML-specific. I think the setAttribute() method is a
standard W3C DOM method.

For example, here's how the same technique is implemented in the XPath
Visualizer for Mozilla:

 objStylesheetParam = style.evaluate("/*/*[name()='xsl:param']
                                              [@name='selectedNodes']",
	                             style, 
                                     null, 
                                     XPathResult.ANY_TYPE, 
                                     null)
                                         .iterateNext();

and further down in the code:

 objStylesheetParam.setAttribute("select", txtQuery);

 var txtResult = source.transformNode(style);


It should be possible to implement this technique for any XSLT
processor, given the specific API it uses. What is necessary is:

1. to be able to invoke a method that evaluates an XPath expression to
return the "xsl:param" element, 

2. then use the setAttribute() method on this element to dynamically
hardwire its value.

3. Only then invoke the xslt transformation.


Anyway, in our discussion about a persistent node id Mike Kay came with
a very good proposal. Using it one will not need any xx:evaluate()
extension function:

http://www.sonicsoftware.com/cgi-bin/dnewsweb/public/dnewsweb?cmd=article&group=xsl-list&item=14175&utag=




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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


Current Thread