Re: [xsl] java methods in SAXON

Subject: Re: [xsl] java methods in SAXON
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 25 May 2005 20:18:40 -0700 (PDT)
It is POSSIBLE ..

Following is an example -

XSLT file
---------
<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:ext="java:MyUtil"
                version="2.0">
 
 <xsl:output method="text" /> 
 
 <xsl:template match="/">
   1: <xsl:value-of select="ext:get(0)"
/><xsl:text>&#xa;</xsl:text>
   2: <xsl:value-of select="ext:get(1)"
/><xsl:text>&#xa;</xsl:text>
   3: <xsl:value-of select="ext:get(2)"
/><xsl:text>&#xa;</xsl:text>   
   4: <xsl:value-of select="ext:xyz()"
/><xsl:text>&#xa;</xsl:text>
   5: <xsl:value-of select="ext:tab()" separator=","
/><xsl:text>&#xa;</xsl:text>
   6: <xsl:value-of select="ext:tab()[1]" /> -
<xsl:value-of select="ext:tab()[2]" /> - <xsl:value-of
select="ext:tab()[3]" />
 </xsl:template>
 
</xsl:stylesheet>

Java class
----------
public class MyUtil {

  public static String[] tab = {"first", "second",
"third"};

  public static String xyz = "hi...";

  public static String get(int i) {
	return tab[i];
  }

  public static void set(int i, String s) {
  	tab[i] = s;
  }

}

Please put Java class into the JVM's classpath .. 

Regards,
Mukul

--- Santosh N <ss1722@xxxxxxxxx> wrote:
> Hi,
> 
> Is it possible to call a java a method from xslt if
> i am using SAXON
> parser.
> 
> Guess this is possible in XALAN.
> 
> Thanks
> Santosh  
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Small Business - Try our new Resources site
> http://smallbusiness.yahoo.com/resources/
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new Resources site
http://smallbusiness.yahoo.com/resources/

Current Thread