cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Harms" <jan.ha...@vivai.de>
Subject AW: convert String into Sax events into my own transformer
Date Wed, 05 Feb 2003 18:40:33 GMT
You┬┤ll need a XML-parser to do that. Something like that should do the trick...

import org.apache.avalon.excalibur.xml.Parser;
import org.xml.sax.InputSource;
import java.io.ByteArrayInputStream;
...
String my_string = ...
ByteArrayInputStream my_string_as_stream = new java.io.ByteArrayInputStream(my_string.getBytes());
InputSource input_source = new InputSource(my_string_as_stream);
Parser parser = (Parser) componentManager.lookup(Parser.ROLE);
parser.parse(input_source, xmlConsumer);
...

xmlConsumer is the transformers xmlConsumer attribute.

Your transformer must implement Composable in order to get the componentManager. 

Regards,

-Jan Harms

> -----Urspr├╝ngliche Nachricht-----
> Von: Lionel Crine [mailto:crine@4dconcept.fr]
> Gesendet: Mittwoch, 5. Februar 2003 17:35
> An: cocoon-users@xml.apache.org
> Betreff: convert String into Sax events into my own transformer
> 
> 
> I would like convert a String into SAX events into my transformer.
> 
> In my enddocument method i wrote :
> 
> super.character(my_String.toCharArray(), 0, myString.length());
> 
> But I don't want that because it spit text in my browser.
> I want my String to be decomposed into elements and text.
> 
> 
> Is there a way to do that ?
> 

---------------------------------------------------------------------
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