2011-02-06 101 views
0

嗨我正面临着Eclipse XSL插件的一个问题,我在我的xsl上使用扩展功能来生成xml作为输出。但我面对下面的错误:Eclipse xslt插件

17:55:38,998 INFO [main] Main - javax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl 
17:55:39,001 INFO [main] Main - java.endorsed.dirs=C:\allinone\JRepo\Java\newwork\workspace\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\endorsed 
17:55:39,006 INFO [main] Main - launchFile: C:\allinone\JRepo\Java\newwork\workspace\.metadata\.plugins\org.eclipse.wst.xsl.jaxp.launching\launch\launch.xml 
17:55:39,506 INFO [main] JAXPSAXProcessorInvoker - Transforming... 
(Location of error unknown)javax.xml.transform.TransformerException: Instance method call to method getFruitType requires an Object instance as first argument 
17:55:39,528 INFO [main] JAXPSAXProcessorInvoker - Done. 

XSL文件:

<?xml version="1.0" encoding="UTF-8"?> 
<!-- Access packaged method in a class file, assigning the classpath to the prefix.--> 

<xsl:stylesheet 
version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:fn="http://www.w3.org/2005/xpath-functions" 
xmlns:pf="com.altova.extfunc.PackagedfruitStatic"> 

<xsl:output indent="yes" exclude-result-prefixes="fn pf xsl fo xs"/> 

<xsl:template match="/"> 
<xsl:variable name="myLemon" select="'yellow'" /> 

<test> 
<staticMethod><xsl:value-of select="pf:getFruitType()"/></staticMethod> 
</test> 
</xsl:template> 

</xsl:stylesheet> 

Java类文件:

package com.altova.extfunc; 

public class PackagedfruitStatic { 
    //static variable 

    public static String getFruitType() 
    { 
     return " Static fruit"; 
    } 
} 

我配置的Xalan解析器Eclipse插件。顺便说一句我使用的是eclipse中最新的JAVA EE IDE(Helios)

回答

1

我怀疑这不是Eclipse问题,而是更多的类路径和XSLT问题。

  1. 确保类文件(PackagedfruitStatic.class)位于com/altova/extfunc,而含有这些子目录的基本目录是在classpath。 (另请注意,com.altova.extfunc用于Altova XSLT extensions。我认为你应该为你的Xalan扩展选择另一个包名)。

  2. exclude-result-prefixes属性不允许在xsl:output。把它在根元素(xsl:stylesheet

  3. 样式表指定version="2.0",但Xalan的XSLT处理器不支持XSLT 2.0。

+0

你是对的,它完全是一个类路径问题。我将源文件/ jar文件添加到类路径中,并在为该类插件提供的类路径中提供。 (Runas - > XSLT - > classpath – srinannapa 2011-02-07 11:20:14