用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>
然后在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>
相关文章推荐
- 用js向xsl 加入变量
- 对JS变量作用域的通俗理解
- JS变量提升问题(及一些作用域面试题)
- MyEclipse加入jquery.js文件missing semicolon的错误
- js中的变量提升
- php与js变量传递
- 如何在js代码中调用java,并将js的变量赋值给java
- js变量类型及其声明方式
- JS几种变量交换方式以及性能分析对比
- js小结:函数&变量
- JS实现设为首页与加入收藏
- U 跳转中加入变量参数的写法
- js抛物线动画——加入购物车动效
- 设为首页 加入收藏的js代码
- [js]变量声明、函数声明、函数定义式、形参之间的执行顺序
- JS获取URL中的变量
- jsp处理表单及JS和JAVA变量互传
- JS字符串替换函数全部替换方法 JS 正则表达式如何使用变量
- Python在字符串中加入变量
- 【小问题】js连接符,+;变量的保存。