Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jfor.jfor.tools
Class DomToSaxAdapter  view DomToSaxAdapter download DomToSaxAdapter.java

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.


Field Summary
private  org.w3c.dom.Document m_doc
           
private  org.xml.sax.ContentHandler m_handler
           
 
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
private static org.xml.sax.Attributes saxAttributes(org.w3c.dom.NamedNodeMap domAttr)
          convert DOM attributes to SAX
 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
 

Field Detail

m_handler

private org.xml.sax.ContentHandler m_handler

m_doc

private final org.w3c.dom.Document m_doc
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


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

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

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

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

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

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

saxAttributes

private static org.xml.sax.Attributes saxAttributes(org.w3c.dom.NamedNodeMap domAttr)
convert DOM attributes to SAX