在 XSL 中使用 Javascript 时出现错误

发布于 2024-09-10 11:21:48 字数 2321 浏览 3 评论 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 系统错误R org.apache.xalan.extensions.ObjectFactory$ConfigurationError: 提供者org.apache.bsf.BSFManager 未找到

请指教,我哪里出错了?

I've an XML document and I am creating another XML using XSL. I need to check some specific conditions and for that I want to use Javascript in my XSL. I tried it, however, couldn't get the desired result. As I could not change the XSL variables frequiently so i am trying to use 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> 

this gave me an error message-

[7/20/10 16:41:47:106 IST] 0000002e
SystemErr R
org.apache.xalan.extensions.ObjectFactory$ConfigurationError:
Provider org.apache.bsf.BSFManager
not found

Please advise, where am i going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱本泡沫多脆弱 2024-09-17 11:21:48

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

<script>
<![CDATA[
(function(){
  //...
})();
]]>
</script>

Try wrapping the javascript code in a CDATA section.

<script>
<![CDATA[
(function(){
  //...
})();
]]>
</script>
謸气贵蔟 2024-09-17 11:21:48

该错误表明您的类路径中需要 Apache Bean 脚本框架。您可以在此处获取它。

The error says that you need the Apache Bean Scripting Framework in your classpath. You can get it here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文