mentics
mentics

Reputation: 6999

Rule or Scripting Languages that can be converted to both Java and XSLT

Is there any rule or scripting language out there for which exists one or more Java libraries to convert it to both Java and XSLT?

For converting to Java, it can either generate Java source, or java bytecode. It needs to be easy to call from Java and "lightweight"/high performance.

For XSLT... generating the equivalent of a function or template or something that manipulates values coming in and returns a result.

By conversion, I mean someone writes code in some language (rule/script/whatever). I then run some "conversion" on that code and I get Java code (source or bytecode). I run some other "conversion" on that same code and I get XSLT code.

Since I'm guessing the XSLT case is the more difficult to solve, here's a simplified possible example:

Input rule/script language:

// Some language psuedocode
output(concat(value1, value2, value3))

Output XSLT:

<xsl:value-of select="concat($value1, $value2, $value3)"/>

Upvotes: 0

Views: 138

Answers (3)

J&#246;rn Horstmann
J&#246;rn Horstmann

Reputation: 34014

Xalan XSLTC supports compiling xslt to java bytecode, so if xslt conforms to your definition of scripting language that would be a possibility. The compilation to xslt would just be the identity transformation :)

Upvotes: 0

Lukasz
Lukasz

Reputation: 7662

You can always try to use antlr and implement your own parser/converter.

Upvotes: 0

Ali
Ali

Reputation: 12664

Groovy comes to mind, you can actually type java if you want, or use their much more efficient syntax.

It's also been extended to Grails which is Groovy on Rails effectively. SpringSource backs both and are high performance and light weight. They will compile to Java byte-code.

There is this link about using Groovy with XSLT you mention you want to "convert" the script to XSTL, not sure what you mean here but you can certainly use XSLT with groovy.

If you need to create some sort of template to generate java code, html, text, spreadsheets, almost anything there is Apache Velocity which is a templating language / engine to reference objects defined in java code.

BeanShell is an other one, the syntax is just like java it's a scripting language and in my experience anything you can do in java you can do in BeanShell.

Upvotes: 1

Related Questions