This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: the difference between xsl:variable and xsl:param
- From: "Andrew Welch" <andrew at thebristoldirectory dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 12 Feb 2002 16:07:18 -0000
- Subject: RE: [xsl] the difference between xsl:variable and xsl:param
- Reply-to: xsl-list at lists dot mulberrytech dot com
>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@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of 林 子芯
Sent: Tuesday, February 12, 2002 11:44 AM
To: xsl-list@lists.mulberrytech.com
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