RE: Transformer writing

2002-05-10 Thread Lai, Harry

Hi Ben,

The simplest approach I can think of would be to build a Transformer that
wraps your library.  Your Transformer would have to:

1. Convert SAX events to a stream on the input side
2. Pass that stream to your library
3. Get the output stream or Document from your library
4. Convert that stream/Document to SAX events on the output side (which is
how you
   would insert the results back into the pipe).

The biggest problem I see, though, is that you're going to take potentially
significant performance hits for steps 1 and 4.

Another possibility is that if the output of your library is the final
output that you want your pipeline to render, you could wrap your library in
a serializer (which outputs a stream instead of SAX events), which would
allow you to skip step 4 (i.e. you'd only do the stream-SAX conversion
once).

Harry


-Original Message-
From: Ben Skelton [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 10, 2002 11:55 AM
To: [EMAIL PROTECTED]
Subject: Transformer writing


Hallo,

I am trying to get my head around the cocoon internals. In particular I have

an old library which takes XML in an InputStream, performs some
(significant) 
processing and produces XML making it available in an OutputStream (a 
Document is also available).

Is it possible to insert this processing into a cocoon pipe? I have had a
look 
at the source code for Transformers, in particular CIncludeTransformer which

I see as the closest example. 

I could write a Transformer to parse the input into the Transformer, on the 
appropriate endElement, the object could go away and do something, but I 
can't see how to insert the results back into the pipe.

Does any one have a simple example of this, or an easy explanation they
would 
share? Are there any resources for extending cocoon available? - I see on 
Amazon that there'll be a couple of books published soon.

Many thanks
--Ben

-
Please check that your question has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faqs.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
Please check that your question has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faqs.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Transformer writing

2002-05-10 Thread Vadim Gritsenko

 From: Ben Skelton [mailto:[EMAIL PROTECTED]]
 
 Hallo,
 
 I am trying to get my head around the cocoon internals. In particular
I have
 an old library which takes XML in an InputStream, performs some
(significant)
 processing and produces XML making it available in an OutputStream (a
 Document is also available).
 
 Is it possible to insert this processing into a cocoon pipe? I have
had a look
 at the source code for Transformers, in particular CIncludeTransformer
which
 I see as the closest example.
 
 I could write a Transformer to parse the input into the Transformer,
on the
 appropriate endElement, the object could go away and do something, but
I
 can't see how to insert the results back into the pipe.

See DOMStreamer (.xml.dom package).

 
 Does any one have a simple example of this, or an easy explanation
they would
 share?

XMLDBTransformer in the scratchpad does something similar.

Vadim


 Are there any resources for extending cocoon available? - I see on
 Amazon that there'll be a couple of books published soon.
 
 Many thanks
 --Ben


-
Please check that your question has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faqs.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]