Re: Calabash: Java API

2009/7/21 David A. Lee wrote:

> The core calabash code uses Saxon S9 TinyTree documents for in
> and out which you can create using about any kind of standard
> input including JAXP using the Saxon S9 API.

  Yes, we can get the result as XDM with ReadablePipe.read(), and
that's what Calabash does in its main driver.  WritableDocument
is used, if I am correct, as a bridge between Calabash and Saxon
by configuring the Saxon Serializer with the serialization
options from Calabash:

    // the serialization options for the 'result' port
    Serialization serial = pipeline.getSerialization("result");

    // the destination URI and the writable document helper
    String uri = "...";
    WritableDocument wd = new WritableDocument(runtime, uri, serial);

    // the 'result' port
    ReadablePipe rpipe = pipeline.readFrom("result");

    // looping over its documents
    while ( rpipe.moreDocuments() ) {
        XdmNode result = rpipe.read();
        wd.write(result);
    }

  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.

  Besides a String standing for a URI seems quite fragile
regarding a File object, while it will always use the file
scheme...

  At least, that's how I understand the code after a first look.
The conclusion I came to is to duplicate most of the code of
WritableDocument.write(), which translates the serialization
options from Calabash to Saxon, in order to be able to use
directly a Saxon's Serializer...

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/

Received on Wednesday, 22 July 2009 09:11:44 UTC