tags:

views:

812

answers:

3

I have something like this:

$('#output').xslt({xml: 'x',xslUrl: 'Test.xsl'});

How do I pass a parameter to the Test.xsl file and retreive the same url in the xsl file?

I am using the jquery libraries: jquery.1.1.3.js and jquery.xslt.js

Or is there any way I could send a parameter to my xsl file via js or jQuery ?

A: 

From reading the documentation, it simply doesn't look like parameters / external inputs are supported.

Marc Gravell
but the library uses xslProcessor() and u can add a parameter via this function .. so there must be a way out
this doesnt work as i cant retrieve the parameter in my xsl file ...
+1  A: 

Add the URL to the XML file you are transforming with the XSL stylesheet.

Arkain
+1  A: 

Solution: Used another jQuery library which provided an option to pass parameters to the XSL file:

  • jquery-1.3.2.min.js
  • jquery.transform.js

Code:

$.transform({
  datatype : "xml",
  el       : "#output",
  async    : false, 
  xmlstr   : [ xmlDoc ], 
  xsl      : 'Test.xsl', 
  xslParams: {
    abc: "value",
    pqr: "valu2"
  }
});

Using xslParams I can pass the parameters. Using <xsl:param> I can retrieve the parameters in my XSL:

<xsl:param name="abc" />

This <xsl:param> must be globally declared in your XSL.