cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject RE: XObject
Date Fri, 01 Dec 2000 23:32:18 GMT
"Torsten Curdt" <tcurdt@dff.st> wrote:
>Ok, lets say there an XObject interface
>*somewhere* ;) in the codebase.
>
>This *was* the old one:
>
>   import org.w3c.dom.Node;
>   import org.xml.sax.DocumentHandler;
>
>   public interface XObject {
>     public void toSAX(DocumentHandler handler);
>     public void toDOM(Node node);
>   }
>
>And if got it right the new one could
>look similiar to this:
>
>   import org.w3c.dom.Node;
>   import org.xml.sax.ContentHandler;
>
>   public interface XObject {
>     public void toSAX(ContentHandler handler);
>     public void toDOM(Node node);
>   }
>
>I was wondering how an implementation might
>look like. Maybe something like this?
>
>   public class test implements XObject{
>     public void toDOM(Node node){
>	Document doc = node.getOwnerDocument();
>	Element e = doc.createElement("test");
>	e.appendChild(doc.createTextNode("content"));
>       node.appendChild(e);
>     }
>
>     public void toSAX(ContentHandler handler){
>       AttributesImpl attr = new AttributesImpl();
>	String content = "content";
>
>       handler.startElement("","test","test",attr);
>	attr.clear();
>
>       handler.characters(content.toCharArray(), 0, content.length());
>
>       handler.endElement("","test","test",attr);
>	}
>   }
>
>toSAX and toDOM should both give:
>
>   <test>content</test>
>
>Correct!? (Haven't tested yet)

Yup. (I don't know SAX but that looks okay.)

And C1 would support both old and new XObjects (outputting a non-fatal error 
to the log if handed the old one - yes C1 does use bogstandard servlet 
logging) but C2 would only support the new one.

Come on, let's vote on this.

+1 :-)





_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com


Mime
View raw message