com.novell.xml.sax
Class SAXtoDOM

java.lang.Object
  extended bycom.novell.xml.sax.SAXtoDOM
All Implemented Interfaces:
DocumentCommentHandler, DocumentHandler, DTDHandler
Direct Known Subclasses:
SAXtoDOMStrip

public class SAXtoDOM
extends Object
implements DocumentCommentHandler, DTDHandler

This class constructs a DOM tree from a series of SAX events


Field Summary
protected  Node currentNode
           
protected  int currentNodePosition
           
protected  Document document
           
protected  boolean level2DOM
           
protected  Locator locator
           
protected  NamespaceStack namespaceStack
           
protected  boolean novellDOM
           
 
Constructor Summary
SAXtoDOM(Document document)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void comment(String data)
          Handle a comment
 void endDocument()
          Receive notification of the end of a document.
 void endElement(String name)
          Receive notification of the end of an element.
protected  DocumentType ensureDocType()
          Return the DocumentType object for the document, creating if doesn't yet exist
 Document getResult()
          Return the result document.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
 void notationDecl(String name, String publicId, String systemId)
          Receive notification of a notation declaration event.
 void processingInstruction(String target, String data)
          Receive notification of a processing instruction.
 void setDocumentLocator(Locator locator)
          Receive an object for locating the origin of SAX document events.
protected  void setLocatorInfo(NodeImpl node)
          Save the Locator information for the current document event in the NodeImpl instance and set the document order value for the node instance.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(String name, AttributeList atts)
          Receive notification of the beginning of an element.
 void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
          Receive notification of an unparsed entity declaration event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

protected Document document

currentNode

protected Node currentNode

currentNodePosition

protected int currentNodePosition

novellDOM

protected boolean novellDOM

level2DOM

protected boolean level2DOM

locator

protected Locator locator

namespaceStack

protected NamespaceStack namespaceStack
Constructor Detail

SAXtoDOM

public SAXtoDOM(Document document)
Method Detail

getResult

public Document getResult()
Return the result document. This is the same object as was passed to the constructor.

Returns:
The Document object used with this object.

setDocumentLocator

public void setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events.

Specified by:
setDocumentLocator in interface DocumentHandler
Parameters:
locator - An object that can return the location of any SAX document event.
See Also:
Locator

startDocument

public void startDocument()
                   throws SAXException
Receive notification of the beginning of a document.

Specified by:
startDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

endDocument

public void endDocument()
                 throws SAXException
Receive notification of the end of a document.

Specified by:
endDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

startElement

public void startElement(String name,
                         AttributeList atts)
                  throws SAXException
Receive notification of the beginning of an element.

Specified by:
startElement in interface DocumentHandler
Parameters:
name - The element type name.
atts - The attributes attached to the element, if any.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
endElement(java.lang.String), AttributeList

endElement

public void endElement(String name)
                throws SAXException
Receive notification of the end of an element.

Specified by:
endElement in interface DocumentHandler
Parameters:
name - The element type name
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Receive notification of character data.

Specified by:
characters in interface DocumentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ignorableWhitespace(char[], int, int), Locator

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Receive notification of ignorable whitespace in element content.

Specified by:
ignorableWhitespace in interface DocumentHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
characters(char[], int, int)

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Receive notification of a processing instruction.

Specified by:
processingInstruction in interface DocumentHandler
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

comment

public void comment(String data)
             throws SAXException
Handle a comment

Specified by:
comment in interface DocumentCommentHandler
Parameters:
data - The comment data, that is, everything between the tags.
Throws:
SAXException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
                  throws SAXException
Receive notification of a notation declaration event.

Specified by:
notationDecl in interface DTDHandler
Parameters:
name - The notation name.
publicId - The notation's public identifier, or null if none was given.
systemId - The notation's system identifier, or null if none was given.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String), AttributeList

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
                        throws SAXException
Receive notification of an unparsed entity declaration event.

Specified by:
unparsedEntityDecl in interface DTDHandler
Parameters:
name - The unparsed entity's name.
publicId - The entity's public identifier, or null if none was given.
systemId - The entity's system identifier (it must always have one).
notationName - The name of the associated notation.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
notationDecl(java.lang.String, java.lang.String, java.lang.String), AttributeList

ensureDocType

protected DocumentType ensureDocType()
Return the DocumentType object for the document, creating if doesn't yet exist

Returns:
The DocumentType object for the document

setLocatorInfo

protected void setLocatorInfo(NodeImpl node)
Save the Locator information for the current document event in the NodeImpl instance and set the document order value for the node instance. Note: The passed node should already be inserted into the tree so that NodeImpl.getBaseURI() returns the base uri correctly from an ancestor node.

Parameters:
node - The NodeImpl instance