您的位置:首页 > Web前端 > JavaScript

用js向xsl 加入变量

2007-03-02 10:41 260 查看
操作方式就是用js向xsl 加入变量
然后在xsl文件中使用该变量参数
---------------------------------------------
eg:
1、在js中如下:
xmlDoc = new ActiveXObject('Msxml2.DOMDocument.3.0')
xmlDoc.async = false;
xmlDoc.load("../xml/context.xml")

//要声明为自由格式的样式
xslDoc = new ActiveXObject('MSXML2.FreeThreadedDOMDocument.3.0')
xslDoc.async = false;
xslDoc.load("../xml/context.xsl")

var oXSLT = new ActiveXObject("MSXML2.XSLTemplate.3.0");
oXSLT.stylesheet = xslDoc;
var oXSLProc = oXSLT.createProcessor();
oXSLProc.input = xmlDoc;
//document.all.hidGUID.value为页面中一个变量
oXSLProc.addParameter("testvalue", document.all.hidGUID.value);
oXSLProc.transform();
//输出信息
oXSLProc.output;
2、在xsl中下如:
<xsl:param name="testvalue"/>
<xsl:template match="entity">
<xsl:if test="description!=($testvalue)">
......
</xsl:if>
</xsl:template>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: