Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在XSLT中调用Java函数_Java_Xslt_Xalan - Fatal编程技术网

在XSLT中调用Java函数

在XSLT中调用Java函数,java,xslt,xalan,Java,Xslt,Xalan,我有一个在xslt中使用java调用方法的案例研究 下面是我的XSLT:- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:test="java:com.package_name.com.Test"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template mat

我有一个在xslt中使用java调用方法的案例研究

下面是我的XSLT:-

 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:test="java:com.package_name.com.Test">
<xsl:output method="xml" omit-xml-declaration="yes"/>
 <xsl:template match="/" >
    <xsl:for-each select="info/data">
    <xsl:variable name="VALUE" select="number"/>
    <int>
         <xsl:value-of select="test:calculate($VALUE)"/>
    </int>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
我收到如下错误消息:

Type:INTEGER:5
                                    Text:CHARACTER:Transformation failure when processing Stylesheet deployed:./Test.xsl
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: The XSL processor reported a possibly fatal error.
Message: java.lang.IllegalArgumentException: name
    at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1017)
    at com.ibm.xsl.exmlt.StylesheetCache.preprocessStylesheet(StylesheetCache.java:763)
    at com.ibm.xsl.exmlt.StylesheetCache.getPreprocessedStylesheet(StylesheetCache.java:686)
    at com.ibm.xsl.exmlt.StylesheetSelector.getTransformer(StylesheetSelector.java:372)
    at com.ibm.xsl.exmlt.StylesheetSelector.performSelection(StylesheetSelector.java:681)
    at com.ibm.xsl.exmlt.EnhancedXMLTransform.transformDocument(EnhancedXMLTransform.java:615)
    at com.ibm.xsl.mqsi.XMLTransformData.transformData(XMLTransformData.java:555)
    at com.ibm.xsl.mqsi.XMLTransformNode.evaluate(XMLTransformNode.java:965)
    at com.ibm.broker.plugin.MbNode.evaluate(MbNode.java:1480)
Caused by: javax.xml.transform.TransformerException: The XSL processor reported a possibly fatal error.
Message: java.lang.IllegalArgumentException: name
    at com.ibm.xsl.exmlt.StylesheetSelector.fatalError(StylesheetSelector.java:1725)
    at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1009)
有人能告诉我如何在XSLT中调用java函数吗。 提前谢谢

问候,,
Rohit.

您能给我们看一下
calculate
方法的签名吗?它需要哪些参数,它们有哪些Java类型?这完全取决于您使用的XSLT处理器:您需要告诉我们。(啊,从堆栈跟踪的深度来看,它看起来像Xalan。我添加了一个标记。)calulate方法什么都不是,,,只是简单的if-else语句@MartinHonnen@rohit31dec91,我们需要查看
calculate
方法的参数数量和类型的定义,因此请编辑您的问题并显示这些信息。@MartinHonnen我添加了java的calulate函数。看看你能不能在某些方面纠正我。
Type:INTEGER:5
                                    Text:CHARACTER:Transformation failure when processing Stylesheet deployed:./Test.xsl
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: The XSL processor reported a possibly fatal error.
Message: java.lang.IllegalArgumentException: name
    at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1017)
    at com.ibm.xsl.exmlt.StylesheetCache.preprocessStylesheet(StylesheetCache.java:763)
    at com.ibm.xsl.exmlt.StylesheetCache.getPreprocessedStylesheet(StylesheetCache.java:686)
    at com.ibm.xsl.exmlt.StylesheetSelector.getTransformer(StylesheetSelector.java:372)
    at com.ibm.xsl.exmlt.StylesheetSelector.performSelection(StylesheetSelector.java:681)
    at com.ibm.xsl.exmlt.EnhancedXMLTransform.transformDocument(EnhancedXMLTransform.java:615)
    at com.ibm.xsl.mqsi.XMLTransformData.transformData(XMLTransformData.java:555)
    at com.ibm.xsl.mqsi.XMLTransformNode.evaluate(XMLTransformNode.java:965)
    at com.ibm.broker.plugin.MbNode.evaluate(MbNode.java:1480)
Caused by: javax.xml.transform.TransformerException: The XSL processor reported a possibly fatal error.
Message: java.lang.IllegalArgumentException: name
    at com.ibm.xsl.exmlt.StylesheetSelector.fatalError(StylesheetSelector.java:1725)
    at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1009)