org.apache.batik.dom.util

Class SAXDocumentFactory

public class SAXDocumentFactory extends DefaultHandler implements LexicalHandler, DocumentFactory

This class contains methods for creating Document instances from an URI using SAX2.
Nested Class Summary
protected interfaceSAXDocumentFactory.PreInfo
Field Summary
protected booleancreateDocumentDescriptor
Whether a document descriptor must be generated.
protected NodecurrentNode
The current node.
protected Documentdocument
The created document.
protected DocumentDescriptordocumentDescriptor
The created document descriptor.
protected ErrorHandlererrorHandler
The error handler.
protected DOMImplementationimplementation
The DOM implementation used to create the document.
protected booleaninCDATA
True if the parser is currently parsing a CDATA section.
protected booleaninDTD
True if the parser is currently parsing a DTD.
protected booleaninProlog
Whether the parser still hasn't read the document element's opening tag.
protected booleanisStandalone
Whether the document just parsed was standalone.
protected booleanisValidating
Whether the parser is in validating mode.
protected Locatorlocator
The locator.
protected HashTableStacknamespaces
The stack used to store the namespace URIs.
protected XMLReaderparser
The SAX2 parser object.
protected StringparserClassName
The SAX2 parser classname.
protected ListpreInfo
Various elements encountered prior to real document root element.
protected StringBufferstringBuffer
Contains collected string data.
protected booleanstringContent
Indicates if stringBuffer has content, needed in case of zero sized "text" content.
protected StringxmlVersion
XML version of the document just parsed.
Constructor Summary
SAXDocumentFactory(DOMImplementation impl, String parser)
Creates a new SAXDocumentFactory object.
SAXDocumentFactory(DOMImplementation impl, String parser, boolean dd)
Creates a new SAXDocumentFactory object.
Method Summary
voidappendStringData()
voidcharacters(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ContentHandler#characters(char[],int,int).
voidcomment(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ext.LexicalHandler#comment(char[],int,int).
DocumentcreateDocument(String ns, String root, String uri)
Creates a Document instance.
DocumentcreateDocument(String uri)
Creates a Document instance.
DocumentcreateDocument(String ns, String root, String uri, InputStream is)
Creates a Document instance.
DocumentcreateDocument(String uri, InputStream is)
Creates a Document instance.
DocumentcreateDocument(String ns, String root, String uri, Reader r)
Creates a Document instance.
DocumentcreateDocument(String ns, String root, String uri, XMLReader r)
Creates a Document instance.
DocumentcreateDocument(String uri, Reader r)
Creates a Document instance.
protected DocumentcreateDocument(String ns, String root, String uri, InputSource is)
Creates a Document.
protected DocumentcreateDocument(InputSource is)
Creates a Document.
voidendCDATA()
SAX: Implements org.xml.sax.ext.LexicalHandler#endCDATA().
voidendDTD()
SAX: Implements org.xml.sax.ext.LexicalHandler#endDTD().
voidendElement(String uri, String localName, String rawName)
SAX: Implements org.xml.sax.ContentHandler#endElement(String,String,String).
voidendEntity(String name)
SAX: Implements org.xml.sax.ext.LexicalHandler#endEntity(String).
voiderror(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#error(SAXParseException).
voidfatalError(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#fatalError(SAXParseException).
DocumentDescriptorgetDocumentDescriptor()
Returns the document descriptor associated with the latest created document.
DOMImplementationgetDOMImplementation(String ver)
voidignorableWhitespace(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ContentHandler#ignorableWhitespace(char[],int,int).
booleanisValidating()
Returns true if the XML parser validates the XML stream, false otherwise.
voidprocessingInstruction(String target, String data)
SAX: Implements org.xml.sax.ContentHandler#processingInstruction(String,String).
voidsetDocumentLocator(Locator l)
SAX: Implements org.xml.sax.ContentHandler#setDocumentLocator(Locator).
voidsetErrorHandler(ErrorHandler eh)
Sets a custom error handler.
voidsetValidating(boolean isValidating)
Sets whether or not the XML parser will validate the XML document depending on the specified parameter.
voidstartCDATA()
SAX: Implements org.xml.sax.ext.LexicalHandler#startCDATA().
voidstartDocument()
SAX: Implements org.xml.sax.ContentHandler#startDocument().
voidstartDTD(String name, String publicId, String systemId)
SAX: Implements org.xml.sax.ext.LexicalHandler#startDTD(String,String,String).
voidstartElement(String uri, String localName, String rawName, Attributes attributes)
SAX: Implements org.xml.sax.ContentHandler#startElement(String,String,String,Attributes).
voidstartEntity(String name)
SAX: Implements org.xml.sax.ext.LexicalHandler#startEntity(String).
voidwarning(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#warning(SAXParseException).

Field Detail

createDocumentDescriptor

protected boolean createDocumentDescriptor
Whether a document descriptor must be generated.

currentNode

protected Node currentNode
The current node.

document

protected Document document
The created document.

documentDescriptor

protected DocumentDescriptor documentDescriptor
The created document descriptor.

errorHandler

protected ErrorHandler errorHandler
The error handler.

implementation

protected DOMImplementation implementation
The DOM implementation used to create the document.

inCDATA

protected boolean inCDATA
True if the parser is currently parsing a CDATA section.

inDTD

protected boolean inDTD
True if the parser is currently parsing a DTD.

inProlog

protected boolean inProlog
Whether the parser still hasn't read the document element's opening tag.

isStandalone

protected boolean isStandalone
Whether the document just parsed was standalone.

isValidating

protected boolean isValidating
Whether the parser is in validating mode.

locator

protected Locator locator
The locator.

namespaces

protected HashTableStack namespaces
The stack used to store the namespace URIs.

parser

protected XMLReader parser
The SAX2 parser object.

parserClassName

protected String parserClassName
The SAX2 parser classname.

preInfo

protected List preInfo
Various elements encountered prior to real document root element. List of PreInfo objects.

stringBuffer

protected StringBuffer stringBuffer
Contains collected string data. May be Text, CDATA or Comment.

stringContent

protected boolean stringContent
Indicates if stringBuffer has content, needed in case of zero sized "text" content.

xmlVersion

protected String xmlVersion
XML version of the document just parsed.

Constructor Detail

SAXDocumentFactory

public SAXDocumentFactory(DOMImplementation impl, String parser)
Creates a new SAXDocumentFactory object. No document descriptor will be created while generating a document.

Parameters: impl The DOM implementation to use for building the DOM tree. parser The SAX2 parser classname.

SAXDocumentFactory

public SAXDocumentFactory(DOMImplementation impl, String parser, boolean dd)
Creates a new SAXDocumentFactory object.

Parameters: impl The DOM implementation to use for building the DOM tree. parser The SAX2 parser classname. dd Whether a document descriptor must be generated.

Method Detail

appendStringData

public void appendStringData()

characters

public void characters(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ContentHandler#characters(char[],int,int).

comment

public void comment(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ext.LexicalHandler#comment(char[],int,int).

createDocument

public Document createDocument(String ns, String root, String uri)
Creates a Document instance.

Parameters: ns The namespace URI of the root element of the document. root The name of the root element of the document. uri The document URI.

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String uri)
Creates a Document instance.

Parameters: uri The document URI.

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String ns, String root, String uri, InputStream is)
Creates a Document instance.

Parameters: ns The namespace URI of the root element of the document. root The name of the root element of the document. uri The document URI. is The document input stream.

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String uri, InputStream is)
Creates a Document instance.

Parameters: uri The document URI. is The document input stream.

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String ns, String root, String uri, Reader r)
Creates a Document instance.

Parameters: ns The namespace URI of the root element of the document. root The name of the root element of the document. uri The document URI. r The document reader.

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String ns, String root, String uri, XMLReader r)
Creates a Document instance.

Parameters: ns The namespace URI of the root element of the document. root The name of the root element of the document. uri The document URI. r an XMLReaderInstance

Throws: IOException if an error occured while reading the document.

createDocument

public Document createDocument(String uri, Reader r)
Creates a Document instance.

Parameters: uri The document URI. r The document reader.

Throws: IOException if an error occured while reading the document.

createDocument

protected Document createDocument(String ns, String root, String uri, InputSource is)
Creates a Document.

Parameters: ns The namespace URI of the root element. root The name of the root element. uri The document URI. is The document input source.

Throws: IOException if an error occured while reading the document.

createDocument

protected Document createDocument(InputSource is)
Creates a Document.

Parameters: is The document input source.

Throws: IOException if an error occured while reading the document.

endCDATA

public void endCDATA()
SAX: Implements org.xml.sax.ext.LexicalHandler#endCDATA().

endDTD

public void endDTD()
SAX: Implements org.xml.sax.ext.LexicalHandler#endDTD().

endElement

public void endElement(String uri, String localName, String rawName)
SAX: Implements org.xml.sax.ContentHandler#endElement(String,String,String).

endEntity

public void endEntity(String name)
SAX: Implements org.xml.sax.ext.LexicalHandler#endEntity(String).

error

public void error(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#error(SAXParseException).

fatalError

public void fatalError(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#fatalError(SAXParseException).

getDocumentDescriptor

public DocumentDescriptor getDocumentDescriptor()
Returns the document descriptor associated with the latest created document.

Returns: null if no document or descriptor was previously generated.

getDOMImplementation

public DOMImplementation getDOMImplementation(String ver)

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
SAX: Implements org.xml.sax.ContentHandler#ignorableWhitespace(char[],int,int).

isValidating

public boolean isValidating()
Returns true if the XML parser validates the XML stream, false otherwise.

processingInstruction

public void processingInstruction(String target, String data)
SAX: Implements org.xml.sax.ContentHandler#processingInstruction(String,String).

setDocumentLocator

public void setDocumentLocator(Locator l)
SAX: Implements org.xml.sax.ContentHandler#setDocumentLocator(Locator).

setErrorHandler

public void setErrorHandler(ErrorHandler eh)
Sets a custom error handler.

setValidating

public void setValidating(boolean isValidating)
Sets whether or not the XML parser will validate the XML document depending on the specified parameter.

Parameters: isValidating indicates that the XML parser will validate the XML document

startCDATA

public void startCDATA()
SAX: Implements org.xml.sax.ext.LexicalHandler#startCDATA().

startDocument

public void startDocument()
SAX: Implements org.xml.sax.ContentHandler#startDocument().

startDTD

public void startDTD(String name, String publicId, String systemId)
SAX: Implements org.xml.sax.ext.LexicalHandler#startDTD(String,String,String).

startElement

public void startElement(String uri, String localName, String rawName, Attributes attributes)
SAX: Implements org.xml.sax.ContentHandler#startElement(String,String,String,Attributes).

startEntity

public void startEntity(String name)
SAX: Implements org.xml.sax.ext.LexicalHandler#startEntity(String).

warning

public void warning(SAXParseException ex)
SAX: Implements org.xml.sax.ErrorHandler#warning(SAXParseException).
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.