users@jaxb.java.net

Re: XJC API for runtime code generation

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Sat, 12 Jul 2008 07:13:06 +0200

Hi.

> I'm trying to get XJC to generate the src code for an XSD model at runtime
> using the XJC api, using just input streams as we don't want disk access.
> This is to facilite the data loading of XSD based models into Drools at
> runtime. We will compile the src at runtime using an embedded compiler and
> add it to the Drools classloader. I've already done something similar for a
> Smooks data loadaer
> http://blog.athico.com/2008/07/drools-smooks-data-loader.html. I've looked
> over the maven plugin for XJC, changing it from a File based utility to
> InputStreams, although now stuck. I've included the test code below, along
> with the error and the xsd. If anyone can help, or point me to some code
> that already does this, would be very much appreciated.

I've attached the code example I used to generate/compile code.
Unfortunatelly, it still uses files so I don't know if it's very
helpful for you.

Instead of streams I'd try something like commons-vfs to use file
objects in a virtual file system (could be in-memory or temporal dir
or whatever).

The error you're posting is quite a low-level parsing error. Quite
probable due to some mistake in stream handling, quite probable that
it disappears with commons-vfs.

Bye.
/lexi