- From: Leif Warner <abimelech@gmail.com>
- Date: Wed, 22 Jul 2009 14:32:21 -0700
- To: XProc Dev <xproc-dev@w3.org>
- Message-ID: <54d4ec0f0907221432i10e2fd62q9c51fbb63e9cca7a@mail.gmail.com>
You could use the interface to Calabash I made for my online processor.The
API is just something like:
PipelineRunner piperunner = new PipelineRunner();
piperunner.run(InputStream in, OutputStream out)
where "in" is the xproc document, and out will be the "results" port.
The only modification I made to WritableDocument was to pass in the
OutputStream in the constructor, rather than having System.out hard-coded
in. I just copied that class definition, renamed it, but it still
implements the same interface, so I didn't need to re-compile Calabash for
that.
I could put it on github or email you stuff. Its open-source so I need to
put it up, anyways. And I'd like feedback on this, to see a standard api
evolve, hopefully to be included in Calabash at some point.
On Wed, Jul 22, 2009 at 3:32 AM, Florent Georges <fgeorges@fgeorges.org>wrote:
> 2009/7/22 Florent Georges wrote:
>
> > So WritableDocument encapsulates the Saxon serializer and its
> > option settings. But the only way, if I am right, to set the
> > actual destination is by giving a URI. Why not allowing a File,
> > an OutputStream or a Writer, as in an s9api's Serializer.
>
> FYI, I use a modified version of WritableDocument in which I
> changed the ctor from:
>
> public WritableDocument(XProcRuntime xproc, String uri,
> Serialization serial) {
> this.runtime = xproc;
> this.uri = uri;
>
> if (serial == null) {
> this.serial = new Serialization(xproc, null);
> this.serial.setIndent(xproc.getDebug()); // indent stdio
> by default when debugging
> } else {
> this.serial = serial;
> }
> }
>
> to:
>
> private WritableDocument(XProcRuntime xproc, Serialization s)
> {
> runtime = xproc;
> serial = s == null ? new Serialization(xproc, null) : s;
> serializer = new Serializer();
> }
>
> public WritableDocument(XProcRuntime xproc, File out, Serialization s)
> {
> this(xproc, s);
> serializer.setOutputFile(out);
> }
>
> public WritableDocument(XProcRuntime xproc, OutputStream out,
> Serialization s)
> {
> this(xproc, s);
> serializer.setOutputStream(out);
> }
>
> public WritableDocument(XProcRuntime xproc, Writer out, Serialization s)
> {
> this(xproc, s);
> serializer.setOutputWriter(out);
> }
>
> along a few other changes: I do not instantiate the Serializer in
> write() anymore, I don't set its output stream in write() neither.
>
> I don't feel comfortable to use a modified version of a
> Calabash class, but this way I can benefit from Calabash
> serialization options as well as using s9api services...
>
> Regards,
>
> --
> Florent Georges
> http://www.fgeorges.org/
>
>
Received on Wednesday, 22 July 2009 21:33:09 UTC