I'd been wanting to create the *simplest* class possible to enable me to transform xsl files within a java application.
I looked around for a really simple example of this process. After a bit of digging around, I "ripped" these bits from the very comprehensive TraxExamples.java file provided within saxon-resources8-9.zip (the original file authored by Scott Boag) and now I have a class containing something like this:
The "void main" bit:
For this to work, you can get the real handleException method from the TraxExamples.java, or for the minimal amount of code to make it work (and not necessarily to make it too useful):
Using eclipse, all the imports were pulled in via Source > Organize Imports (Ctrl + Shift + O)
Does the trick for me :)
14 comments:
I spent atleast an hour trying to find out how to tell java I wanted to use the saxon processor and I landed on your blog. Thanks a lot. Cheers
Thanks!
Good work, thanks!
Also, in eclipse remember to add the saxon.jar to runtime classpath. (couldn't figure out why it wasn't working until I realized...)
Thanks for this excellent example.
An excellent simple example that works for me, thanks very much! :-)
Hi, i am converting html file to xml using xslt and saxon.How to modify the above code..please help.
I was just about to rollback two days of work when I saw this. Thanks you are a life saver. Or at least a time saver. :)
/Victor
Nice article, thanks!
Thank, nice post!!! It really helps me.
Thanks, nice post!!! It really helps me.
Do you know how to extract attributes values from an element. For example:
Thanks in advance for your help.
So long.
Thank you. It very helpful for me.
Post a Comment