RE: [xsl] JD and Java Extension

Subject: RE: [xsl] JD and Java Extension
From: "Yates, Danny (ANTS)" <danny.yates@xxxxxxxxxx>
Date: Mon, 17 Feb 2003 14:10:44 -0000
Spencer Bruce wrote:
> > If you want to call a Java method from jd.xslt then you need a namespace
> > declaration to direct the processor to the java class.
> >
> > <xsl:stylesheet xmlns:math="java:java.lang.Math" ...>
> >          ...
> >          <xsl:value-of select="math:sin(3.14)"/>
> >          ...
> > </xsl:stylesheet>
> >
> > Feel free to mail me if you experience more problems.
> >
> > Johannes Döbler
> >
> 
> This works fine for a Java class from the standard library such as
> java.lang.Math
> 
> However in our case we have our own Java class called for example
> ExtensionTest.  The class has one public static method:
> 
> public static String test(String s)
> {
> return s;
> }
> 
> We then have a stylesheet such as:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>      version="1.0"
>      xmlns:java="ExtensionTest">
> 
> <xsl:template match="/">
>      <xsl:value-of select="java:test(.)" />
> </xsl:template>
> 
> </xsl:stylesheet>
> 

I've never done this, but just pattern matching on the reply you
quoted suggest that what you have written is not the same. Does
this work?

<xsl:stylesheet .... xmlns:ext="java:my.package.ExtensionTest">

  <xsl:template ... >
    <xsl:value-of select="ext:test('abc')"/>

Note that I used a string literal in the function call. Try this
before trying the next logical step of getting information out of
the document.

Rgds,

Dan.


***************************************************************************
This communication (including any attachments) contains confidential information.  If you are not the intended recipient and you have received this communication in error, you should destroy it without copying, disclosing or otherwise using its contents.  Please notify the sender immediately of the error.

Internet communications are not necessarily secure and may be intercepted or changed after they are sent.  Abbey National Treasury Services plc does not accept liability for any loss you may suffer as a result of interception or any liability for such changes.  If you wish to confirm the origin or content of this communication, please contact the sender by using an alternative means of communication.

This communication does not create or modify any contract and, unless otherwise stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 2 Triton Square, Regents Place, London NW1 3AN.  Registered in England under Company Registration Number: 2338548.  Regulated by the Financial Services Authority (FSA).
***************************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread