xsl-list
[Top] [All Lists]

Re: java methods in SAXON

2005-05-25 20:18:40
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(_at_)yahoo(_dot_)com> 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/


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>