0

我有一个 XML 文档,并且正在使用 XSL 创建另一个 XML。我需要检查一些特定条件,为此我想在我的 XSL 中使用 Javascript。但是我试过了,没有得到想要的结果。由于我无法频繁更改 XSL 变量,因此我尝试使用 Javascript。

XSL-

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:es="http://ucmservice"
    version="1.0" xmlns="http://filenet.com/namespaces/wcm/apps/1.0" xmlns:java="http://xml.apache.org/xalan/java" xmlns:js="urn:custom-javascript" xmlns:lxslt="http://xml.apache.org/xslt"
        xmlns:totalSys="TotalSystem"  extension-element-prefixes="totalSys">

  <lxslt:component prefix="totalSys" functions="checkFirstProp">
  <lxslt:script lang="javascript">

            var firstPropVal = "";
            var secondPropVal = "";
            var completedFirstPropVal= new Array();
            var completedSecondPropVal= new Array();
            var firstDecisionFlag = 0; 
            function checkFirstProp(xmlValue)
            {
                firstDecisionFlag = 0;

                if(firstPropVal.length == 0)
                {
                        firstPropVal = xmlValue;
                        firstDecisionFlag = 1; 
                 }
                 else
                 {
                    if(firstPropVal != xmlValue)
                    {
                         firstPropVal = xmlValue; 
                         firstDecisionFlag = 2; 
                    }
                  }

                  return firstDecisionFlag; 
            }

       </lxslt:script>
    </lxslt:component> 
    <xsl:template match="/">
     <xsl:apply-templates select="XMLTag"/>
    </xsl:template>
    <xsl:template match="XMLTag">        
        <xsl:variable name="firstPropDecisionFlag">
            <xsl:value-of select="totalSys:checkFirstProp(param)"/> 
        </xsl:variable>

        <xsl:if test="$firstPropDecisionFlag=2">
            {
                task
            } 
        </xsl:if>
       </xsl:template>
          bvk</xsl:stylesheet> 

这给了我一条错误消息-

[7/20/10 16:41:47:106 IST] 0000002e SystemErr R org.apache.xalan.extensions.ObjectFactory$ConfigurationErrororg.apache.bsf.BSFManager 未找到提供程序

请指教,我哪里出错了?

4

2 回答 2

0

尝试将 javascript 代码包装在一个CDATA部分中。

<script>
<![CDATA[
(function(){
  //...
})();
]]>
</script>
于 2010-07-20T13:00:42.913 回答
0

该错误表明您的类路径中需要 Apache Bean 脚本框架。你可以在这里得到它。

于 2010-07-20T13:02:18.203 回答