You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Bradley Wagner <br...@hannonhill.com> on 2009/03/31 02:47:39 UTC

Embedding Java directly in XSLT using Extensions

Is it not possible to embed arbitrary Java code directly in an XSLT
stylesheet using Xalan Extensions the same way you can with JavaScript? I
was under the assumption that you could basically do the following:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
extension-element-prefixes="date-converter" version="1.0"
xmlns:date-converter="http://www.company.com/dateConverter/1.0/"
xmlns:xalan="http://xml.apache.org/xalan" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> <!-- Xalan component for date
conversion from CMS date format to RSS 2.0 pubDate format -->
<xalan:component prefix="date-converter"> <xalan:script lang="javaclass"
src="http://xml.apache.org/xalan/java"> package mine; public class
MyConverter { public int
convertDateJava(org.apache.xalan.extensions.ExpressionContext context, long
time) { Date date = new Date(time); return "" + date.getMonth()+1 + "/" +
date.getDay()+1 + "/" + date.getYear(); } } </xalan:script>
</xalan:component> </xsl:stylesheet>

but it's looking like you have to have some Java class or function already
on the classpath to call instead. Is this accurate? I guess this would make
more given that the Xalan is probably not compiling code at runtime. I guess
I'm just confirming at this point.

Thanks,
Bradley Wagner

Re: Embedding Java directly in XSLT using Extensions

Posted by Mukul Gandhi <ga...@gmail.com>.
On Tue, Mar 31, 2009 at 6:17 AM, Bradley Wagner
<br...@hannonhill.com> wrote:
> Is it not possible to embed arbitrary Java code directly in an XSLT
> stylesheet using Xalan Extensions the same way you can with JavaScript?

I think this is not possible with Xalan.


-- 
Regards,
Mukul Gandhi