Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 35488 invoked from network); 1 Dec 2000 23:32:44 -0000 Received: from f156.law4.hotmail.com (HELO hotmail.com) (216.33.149.156) by locus.apache.org with SMTP; 1 Dec 2000 23:32:44 -0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 1 Dec 2000 15:32:18 -0800 Received: from 148.88.0.10 by lw4fd.law4.hotmail.msn.com with HTTP; Fri, 01 Dec 2000 23:32:18 GMT X-Originating-IP: [148.88.0.10] From: "Robin Green" To: cocoon-dev@xml.apache.org Subject: RE: XObject Date: Fri, 01 Dec 2000 23:32:18 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 01 Dec 2000 23:32:18.0835 (UTC) FILETIME=[F2179630:01C05BEE] X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N "Torsten Curdt" 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: > > content > >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