cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <>
Subject Re: toDOM and toSAX of XMLFragment
Date Tue, 23 Jan 2001 14:50:46 GMT

Ulrich Mayring a écrit :
> Hello,
> how are the implementations of the toDOM and toSAX methods supposed to
> look like? I see that they receive a Node or a ContentHandler
> respectively and return nothing - what are they supposed to do?
> Ulrich
> --
> Ulrich Mayring
> DENIC eG, Systementwicklung

An XMLFragment is an object that can be represented as a XML document
fragment. The toDOM() method (used by C1) should append the XML
representation of the object as children of the given node, and the
toSAX() method (used by C2) should generate the XML representation as
SAX events.

A typical XMLFragment implementation could look like this :

  public class FragmentTest implements XMLFragment
    public void toDOM(Node node)
      Document doc = node.getOwnerDocument();
      Element e = doc.createElement("foo");

    public void toSAX(ContentHandler handler)
      AttributesImpl attr = new AttributesImpl();

      String content = "bar";
      handler.characters(content.toCharArray(), 0, content.length());


Both methods result in <foo>bar</foo> to be inserted in the resulting

Hope this helps.
Sylvain Wallez
Anyware Technologies

View raw message