Subject: RE: [xsl] the difference between xsl:variable and xsl:param From: "林 子芯" <minikittygo@xxxxxxxxxxx> Date: Wed, 13 Feb 2002 16:32:27 +0000 |
xml:variable,From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: RE: [xsl] the difference between xsl:variable and xsl:param Date: Tue, 12 Feb 2002 16:07:18 -0000
>Hi, can everyone tell me the difference between xml:param and
>i got pretty confused over the use of the two. Secondly, can anyone tellme
>how to pass a variable to an xsl (e.g. <xsl:templatestylesheet
>match=".//c="?variable"/> where as ?variable is pass down to the
>through javascript. unfortunately i have no idea where to start oversuch
->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?)object
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
ids.
cheers
andrew
_________________________________________________________________ 在您的行動裝置上傳送接收 Hotmail 郵件,請移至 http://mobile.msn.com。;
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] the difference between xs, Corey_Haines | Thread | RE: [xsl] the difference between xs, Andrew Welch |
RE: [xsl] determining position of a, Bryan Rasmussen | Date | RE: [xsl] xsl-fo question, Bryan Rasmussen |
Month |