| Subject: RE: [xsl] the difference between xsl:variable and xsl:param From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 12 Feb 2002 16:07:18 -0000 | 
>Hi, can everyone tell me the difference between xml:param and xml:variable,
>i got pretty confused over the use of the two. Secondly, can anyone tell me
>how to pass a variable to an xsl (e.g. <xsl:template
>match=".//c="?variable"/> where as ?variable is pass down to the stylesheet
>through javascript. unfortunately i have no idea where to start over such
>script. can anyone tell whether this is possible and if so, can somebody
>give me a starting point over this.
Hi,
(btw, this is becoming a faq but I cant find it on dave's or jeni's sites -
does it warrant being added?)
yes, its possible pass parameters into stylesheets using javascript.
Using msxml4:
  function load()
  {
     xml  = new ActiveXObject("Msxml2.DOMDocument.4.0");
     xml.async = false;
     xml.load("youXMLfile.xml");
     xsl = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
     xsl.async = false;
     xsl.load("yourXSLfile.xsl");
     template = new ActiveXObject("Msxml2.XSLTemplate.4.0");
     template.stylesheet = xsl;
     processor = template.createProcessor();
     processor.input = xml;
     processor.addParameter("param1", "someValue");
     processor.addParameter("param2", "someOtherValue");
     processor.transform();
     document.write(processor.output);
  }
You then need to add the xsl:params as a top level elements in your
stylesheet to receive the parameters.  So in this case:
<xsl:stylesheet xmlns:xsl="http:.....
<xsl:param name="param1"/>
<xsl:param name="param2"/>
Notice the name must match the first parameter in addParameter().  You can
then access the parameter using the dollar sign - $param1.
If you are using msxml3 or lower, remember to alter the '.4.0' on the object
ids.
cheers
andrew
-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of 林 子芯
Sent: Tuesday, February 12, 2002 11:44 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] the difference between xsl:variable and xsl:param
Hi, can everyone tell me the difference between xml:param and xml:variable,
i got pretty confused over the use of the two. Secondly, can anyone tell me
how to pass a variable to an xsl (e.g. <xsl:template
match=".//c="?variable"/> where as ?variable is pass down to the stylesheet
through javascript. unfortunately i have no idea where to start over such
script. can anyone tell whether this is possible and if so, can somebody
give me a starting point over this.
  Many thanks
Regards
Kit
_________________________________________________________________
MSN 相簿提供您最簡單的方式分享並列印您的相片,請移至
http://photos.msn.com/support/worldwide.aspx。;
 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 | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] the difference between xs, Trevor Nash | Thread | Re: [xsl] the difference between xs, Oliver Becker | 
| [xsl] RE: xsl mathematical calculat, Andrew Welch | Date | [xsl] concatenation of sibling name, Saverio Perugini | 
| Month |