srinannapa
srinannapa

Reputation: 3207

Eclipse xslt plugin

Hi I'm facing an issue with Eclipse XSL plugin , I'm using extensions feature on my xsl to generate xml as output. But i'm facing the below error:

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 file :

<?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 class file :

package com.altova.extfunc;

public class PackagedfruitStatic {
    //static variable

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

I Configured Xalan parser in eclipse plugin. BTW I'm using the latest JAVA EE IDE (Helios) from eclipse

Upvotes: 0

Views: 3594

Answers (1)

mzjn
mzjn

Reputation: 51002

I suspect that this is not an Eclipse problem, but more of a classpath and XSLT issue.

  1. Make sure that the class file (PackagedfruitStatic.class) is located in com/altova/extfunc, and that the base directory containing these subdirectories is in the classpath. (Also note that com.altova.extfunc is used for Altova XSLT extensions. I think you should choose another package name for your Xalan extensions).

  2. The exclude-result-prefixes attribute is not allowed on xsl:output. Put it on the root element (xsl:stylesheet)

  3. The stylesheet specifies version="2.0", but the Xalan XSLT processor does not support XSLT 2.0.

Upvotes: 1

Related Questions