cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross Burton <>
Subject Re: [C2] DOMStreamer in use?
Date Wed, 11 Oct 2000 06:57:48 GMT
"Bruce G. Robertson" wrote:
> I'm trying to implement a DOM transformer in C2, but it isn't working.
> Besides the SAX event handlers, which are dummies, the important bits of
> my work are:
> public class TestDOM extends DOMStreamer implements Transformer {

I wrote an AbstractDOMTransformer which worked quite well, but then I
lost it.  :-(  Damn,

It was something like this (he says, hasily looking at the
DOMBuilder/Streamer source code) 

public abstract class AbstractDOMTransformer extends DOMBuilder
implements Transfomer, DOMBuilder.Listener, Composer {

	public AbstractDOMTransformer() {
		// set the factory later, when we have a component manager to get a
parser from
		super(null, this);

	public void setComponentManager(ComponentManager manager) {
		Parser p = (Parser)manager.getComponent("parser);
		super.factory = (DOMFactory))parser;
	/** from DOMBuilder.Listener, called when a DOM is built */
	public void notify(Document doc) throws SAXException {
		// Call the user's transform method
		Document newdoc = transform(doc);
		// Now we stream the DOM tree out
		DOMStreamer s = new DOMStreamer(contentHandler, lexicalHandler);;
	 * Implement this method, applying transforms to the Document doc and
	 * the document to be serialized as SAX.
	protected abstract Document transform(Document doc) throws SAXException

Something like that worked for me.  There was a problem with DTD
declarations, but I have a feeling that was fixed.   The above code may
not compile, I've just got up, am about to got work work and wrote it
while briefly looking at the C2 source code...

Ill probably work some more on it tonight (Europe), so mail me any
changes please!

Ross Burton

View raw message