org.jfor.jfor.tools
Class DomToSaxAdapter

java.lang.Object
  extended byorg.jfor.jfor.tools.ElementVisitor
      extended byorg.jfor.jfor.tools.DomToSaxAdapter

public class DomToSaxAdapter
extends ElementVisitor

Walks a DOM document and fires (some) SAX events to simulate parsing of the original document.
Written to use jfor with Cocoon 1.8.
Only SAX events that are used by the jfor Converter class are implemented.
Namespace URIs and local names are not implemented.

Author:
Bertrand Delacretaz bdelacretaz@codeconsult.ch

Constructor Summary
DomToSaxAdapter(org.w3c.dom.Document doc)
          create an adapter for the given DOM Document
 
Method Summary
protected  void endElement(org.w3c.dom.Element e)
          called at the end of the visit of an Element
 void simulateParsing(org.xml.sax.ContentHandler ch)
          walk the document and send SAX events to the given ContentHandler
protected  void startElement(org.w3c.dom.Element e)
          called at the start of the visit of an Element
protected  void visitCDATA(org.w3c.dom.CDATASection cds)
          called to visit a CDATASection node
protected  void visitComment(org.w3c.dom.Comment c)
          called to visit a Comment node
protected  void visitNode(org.w3c.dom.Node n)
          called to visit a Node that is not of the other types
protected  void visitText(org.w3c.dom.Text t)
          called to visit a Text node
 
Methods inherited from class org.jfor.jfor.tools.ElementVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomToSaxAdapter

public DomToSaxAdapter(org.w3c.dom.Document doc)
create an adapter for the given DOM Document

Method Detail

simulateParsing

public void simulateParsing(org.xml.sax.ContentHandler ch)
                     throws java.io.IOException,
                            org.xml.sax.SAXException
walk the document and send SAX events to the given ContentHandler

Throws:
java.io.IOException
org.xml.sax.SAXException

startElement

protected void startElement(org.w3c.dom.Element e)
                     throws java.io.IOException,
                            org.xml.sax.SAXException
called at the start of the visit of an Element

Specified by:
startElement in class ElementVisitor
Throws:
java.io.IOException
org.xml.sax.SAXException

endElement

protected void endElement(org.w3c.dom.Element e)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
called at the end of the visit of an Element

Specified by:
endElement in class ElementVisitor
Throws:
java.io.IOException
org.xml.sax.SAXException

visitText

protected void visitText(org.w3c.dom.Text t)
                  throws java.io.IOException,
                         org.xml.sax.SAXException
called to visit a Text node

Specified by:
visitText in class ElementVisitor
Throws:
java.io.IOException
org.xml.sax.SAXException

visitCDATA

protected void visitCDATA(org.w3c.dom.CDATASection cds)
                   throws java.io.IOException
called to visit a CDATASection node

Specified by:
visitCDATA in class ElementVisitor
Throws:
java.io.IOException

visitComment

protected void visitComment(org.w3c.dom.Comment c)
                     throws java.io.IOException
called to visit a Comment node

Specified by:
visitComment in class ElementVisitor
Throws:
java.io.IOException

visitNode

protected void visitNode(org.w3c.dom.Node n)
                  throws java.io.IOException
called to visit a Node that is not of the other types

Specified by:
visitNode in class ElementVisitor
Throws:
java.io.IOException