用js向xsl 加入变量

操作方式就是用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>

posted on 2007-03-02 10:41  freeliver54  阅读(1238)  评论(2编辑  收藏  举报

导航