[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Problem in calling external java function


Subject: RE: [xsl] Problem in calling external java function
From: "Narang, Prateek" <PNarang@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Sep 2004 16:27:40 +0530

Not sure it would fix u'r problem, but I think u also need
'extension-element-prefixes' attribute in <xsl:stylesheet>.

Regds
--prateek--

Prateek Narang
Professional Services
Innodata Isogen
4th Floor, Gateway Tower
R Block, DLF City, Phase-III
Gurgaon, Haryana - 122 002
Phone:  +(091) 124-2562801
Fax:      +(091) 124-2356001
Cell:      +(091)  9868350569

www.innodata-isogen.com


-----Original Message-----
From: Manpreet Singh [mailto:singhm@xxxxxxxxxxx]
Sent: Monday, September 20, 2004 4:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problem in calling external java function
Importance: High

Hi,
   The following is the xslt code calling a java class:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:test="C://tester"
exclude-result-prefixes="test">
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="b">
		<xsl:variable name="test1"
select="test:xyz.new('A;B;C',';')"/>
		<abc>
			<xsl:value-of
select="test:getNextToken($test1)"/>
		</abc>
	</xsl:template>
</xsl:stylesheet>


The following is the code for the class being called:

import java.util.StringTokenizer;

public class xyz {

  private StringTokenizer tokenizer;

  public CreateMultipleTargetInstance( String specimen, String token ) {
    tokenizer = new StringTokenizer ( specimen, token );
  }

  public String getNextToken() {
    if ( tokenizer.hasMoreTokens() ) {
      return tokenizer.nextToken();
    }
    else {
      return "";
    }
  }
}

When i call this class using the above xslt Through command prompt using
the following command:

java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -out
out.xml

i get the following error:

file:/C:abc.xsl;
 Line #9; Column #-1; XSLT Error
(javax.xml.transform.TransformerException):
java.lang.NoSuchMethodException: For extension function, could not find
constructor  tester.CreateMultipleTargetInstance([ExpressionContext,]
#STRING, #STRING).


The xslt is supposed to return me the first string before ";" i.e A.

...........ANYONE?

Regards
Manpreet


Current Thread
Keywords