> -----Original Message-----
> From: Konstantin Piroumian [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 04, 2003 11:42 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Custom transformer 
> 
> 
> From: "Lionel Crine" <[EMAIL PROTECTED]>
> 
> > I have an xml document :
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsp:page xmlns:xsp="http://apache.org/xsp";
> > xmlns:my_NS="http://www.my_NS.com/my_NS/query/1.0";>
> >
> >
> > <my_NS:document>
> >    <my_NS:query VERSION="2.0" RESULTSPACE="R1">
> >      <my_NS:property NAME = "DocType">
> >        <my_NS:elem>DOCUMENT</my_NS:elem>
> >      </my_NS:property>
> >    </my_NS:query>
> > </my_NS:document>
> >
> > </xsp:page>
> >
> >
> > In my transformer I need to get all that si between "<my_NS:document>
> > </my_NS:document>" tag and put it in a string or a String buffer.
> >
> > Which method can do that for me ?
> 
> You should implement almost all the methods of ContentHandler interface,
> such as:
> startDocument()
> startElement()
> characters()
> endElement()
> endDocument()
> 
> etc. and store everything you need into a String buffer.
> 
> For an example you can take a look at classes in
> src/java/org/apache/cocoon/transformation/helper/ package.

If you inherit from the AbstractSAXTransformer, you only have
to invoke startSerializedXMLRecording() before the first element
arrives that you want to have included in your string.

And at the end invoke endSerializedXMLRecording() and you get
all the XML inbetween as a string.

Have a look at some other transformers using the AbstractSAXTransformer
for samples.

Carsten

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

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

Reply via email to