2

Is there any tool that can generate java code from XSLT?

UPD

I want to generate java source or byte code, which does the similar transformation, as the XSLT does. I want to run it on Android, so solution must be suitable for usage on mobile platform.

6
  • 2
    Wait a minute, you want to take a XSLT, and generate the java code that will perform the similar operation ? Commented Dec 9, 2010 at 10:15
  • 1
    Do you want to generate Java source code or byte code? Xalan XSLTC xml.apache.org/xalan-j/xsltc_usage.html can generate byte code. Commented Dec 9, 2010 at 12:12
  • 1
    Yes, I want to generate the java code that will perform the similar transformation. Commented Dec 9, 2010 at 12:25
  • 2 Martin Honnen: byte code is acceptable solution. Idea is to use generated code on Android, and translets generated by Xalans seems to be too heavy solution, they require too many dependency jars to run, unfortunately... But thanks for your answer anyway, it is proof of concept at least :) Commented Dec 9, 2010 at 12:34
  • What do you mean in this question: - making a lightweight XSLT parser - then that XSLTC will be good, or doing metaprogramming - then you should rather look at tools like Annotation Processing Tool, @AspectJ or Javassist Commented Dec 9, 2010 at 13:10

2 Answers 2

1

I want to generate java source or byte code, which does the similar transformation, as the XSLT does. I want to run it on Android, so solution must be suitable for usage on mobile platform.

Just take the open source version of Saxon (written entirely in Java).

Saxon 6.5.5 implements XSLT 1.0. Saxon 9.1.07 implements the basic version (not schema-aware) of XSLT 2.0.

Also, one could use the Java byte-code generated or even the Java source code generated.

Recently Michael Kay has been converting Saxon to Javascript, so we may expect soon to have Saxon-JS running on the client (browser) side as a de-facto standard client side XSLT 2.0 processor.

Sign up to request clarification or add additional context in comments.

Comments

0

I have done it using XML files to define objects and then using XSLT to transform to beans, forms, struts classes, DB tables etc but in my mind it is a long way to go for about the same amount of effort as writing the code using cut and paste... Sadly it is commercial so I can't share it :( A bit long in the tooth but XDoclet is also useful for code generation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.