如何使用jQuery将参数从URL传递到XSL样式表?
我有这样的东西:
$('#output').xslt({xml: 'x',xslUrl: 'Test.xsl'});
如何将参数传递给Test.xsl文件并检索xsl文件中的相同网址?
How do I pass a parameter to the Test.xsl file and retreive the same url in the xsl file?
我正在使用jquery库:jquery.1.1.3.js
和 jquery.xslt.js
I am using the jquery libraries: jquery.1.1.3.js
and jquery.xslt.js
或者我可以通过js或jQuery将参数发送到xsl文件吗?
Or is there any way I could send a parameter to my xsl file via js or jQuery ?
解决方案:使用了另一个jQuery库,该库提供了将参数传递给XSL文件的选项:
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
jquery-1.3.2.min.js
jquery.transform.js
代码:
$.transform({
datatype : "xml",
el : "#output",
async : false,
xmlstr : [ xmlDoc ],
xsl : 'Test.xsl',
xslParams: {
abc: "value",
pqr: "valu2"
}
});
使用xslParams
我可以传递参数.使用<xsl:param>
,我可以在XSL中检索参数:
Using xslParams
I can pass the parameters. Using <xsl:param>
I can retrieve the parameters in my XSL:
<xsl:param name="abc" />
此<xsl:param>
必须在您的XSL中全局声明.
This <xsl:param>
must be globally declared in your XSL.