[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: the difference between xsl:variable and xsl:param

Subject: RE: the difference between xsl:variable and xsl:param
From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Feb 2002 16:07:18 -0000
difference between xml and xsl

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.