cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@s-und-n.de>
Subject RE: Custom transformer
Date Tue, 04 Feb 2003 10:49:10 GMT


> -----Original Message-----
> From: Konstantin Piroumian [mailto:kpiroumian@apache.org]
> Sent: Tuesday, February 04, 2003 11:42 AM
> To: cocoon-users@xml.apache.org
> Subject: Re: Custom transformer 
> 
> 
> From: "Lionel Crine" <crine@4dconcept.fr>
> 
> > 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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message