Package org.apache.batik.dom.util
Class SAXDocumentFactory
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.batik.dom.util.SAXDocumentFactory
- All Implemented Interfaces:
DocumentFactory
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,LexicalHandler
- Direct Known Subclasses:
SAXSVGDocumentFactory
This class contains methods for creating Document instances
from an URI using SAX2.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Whether a document descriptor must be generated.protected Node
The current node.protected DocumentType
The DTD to use when the document is created.protected Document
The created document.protected DocumentDescriptor
The created document descriptor.protected ErrorHandler
The error handler.protected DOMImplementation
The DOM implementation used to create the document.protected boolean
True if the parser is currently parsing a CDATA section.protected boolean
True if the parser is currently parsing a DTD.protected boolean
Whether the parser still hasn't read the document element's opening tag.protected boolean
Whether the document just parsed was standalone.protected boolean
Whether the parser is in validating mode.protected Locator
The locator.protected HashTableStack
The stack used to store the namespace URIs.protected XMLReader
The SAX2 parser object.protected String
The SAX2 parser classname.protected List
Various elements encountered prior to real document root element.protected StringBuffer
Contains collected string data.protected boolean
Indicates if stringBuffer has content, needed in case of zero sized "text" content.protected String
XML version of the document just parsed. -
Constructor Summary
ConstructorsConstructorDescriptionSAXDocumentFactory
(DOMImplementation impl, String parser) Creates a new SAXDocumentFactory object.SAXDocumentFactory
(DOMImplementation impl, String parser, boolean dd) Creates a new SAXDocumentFactory object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
characters
(char[] ch, int start, int length) SAX: ImplementsContentHandler.characters(char[],int,int)
.void
comment
(char[] ch, int start, int length) SAX: ImplementsLexicalHandler.comment(char[],int,int)
.createDocument
(String uri) Creates a Document instance.createDocument
(String uri, InputStream is) Creates a Document instance.createDocument
(String uri, Reader r) Creates a Document instance.createDocument
(String ns, String root, String uri) Creates a Document instance.createDocument
(String ns, String root, String uri, InputStream is) Creates a Document instance.createDocument
(String ns, String root, String uri, Reader r) Creates a Document instance.protected Document
createDocument
(String ns, String root, String uri, InputSource is) Creates a Document.createDocument
(String ns, String root, String uri, XMLReader r) Creates a Document instance.protected Document
Creates a Document.void
endCDATA()
SAX: ImplementsLexicalHandler.endCDATA()
.void
endDTD()
SAX: ImplementsLexicalHandler.endDTD()
.void
endElement
(String uri, String localName, String rawName) SAX: ImplementsContentHandler.endElement(String,String,String)
.void
SAX: ImplementsLexicalHandler.endEntity(String)
.void
SAX: ImplementsErrorHandler.error(SAXParseException)
.void
SAX: ImplementsErrorHandler.fatalError(SAXParseException)
.Returns the document descriptor associated with the latest created document.void
ignorableWhitespace
(char[] ch, int start, int length) SAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int)
.boolean
Returns true if the XML parser validates the XML stream, false otherwise.void
processingInstruction
(String target, String data) SAX: ImplementsContentHandler.processingInstruction(String,String)
.void
SAX: ImplementsContentHandler.setDocumentLocator(Locator)
.void
Sets a custom error handler.void
setValidating
(boolean isValidating) Sets whether or not the XML parser will validate the XML document depending on the specified parameter.void
SAX: ImplementsLexicalHandler.startCDATA()
.void
SAX: ImplementsContentHandler.startDocument()
.void
SAX: ImplementsLexicalHandler.startDTD(String,String,String)
.void
startElement
(String uri, String localName, String rawName, Attributes attributes) SAX: ImplementsContentHandler.startElement(String,String,String,Attributes)
.void
startEntity
(String name) SAX: ImplementsLexicalHandler.startEntity(String)
.void
SAX: ImplementsErrorHandler.warning(SAXParseException)
.Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
implementation
The DOM implementation used to create the document. -
parserClassName
The SAX2 parser classname. -
parser
The SAX2 parser object. -
document
The created document. -
documentDescriptor
The created document descriptor. -
createDocumentDescriptor
protected boolean createDocumentDescriptorWhether a document descriptor must be generated. -
currentNode
The current node. -
locator
The locator. -
stringBuffer
Contains collected string data. May be Text, CDATA or Comment. -
doctype
The DTD to use when the document is created. -
stringContent
protected boolean stringContentIndicates if stringBuffer has content, needed in case of zero sized "text" content. -
inDTD
protected boolean inDTDTrue if the parser is currently parsing a DTD. -
inCDATA
protected boolean inCDATATrue if the parser is currently parsing a CDATA section. -
inProlog
protected boolean inPrologWhether the parser still hasn't read the document element's opening tag. -
isValidating
protected boolean isValidatingWhether the parser is in validating mode. -
isStandalone
protected boolean isStandaloneWhether the document just parsed was standalone. -
xmlVersion
XML version of the document just parsed. -
namespaces
The stack used to store the namespace URIs. -
errorHandler
The error handler. -
preInfo
Various elements encountered prior to real document root element. List of PreInfo objects.
-
-
Constructor Details
-
SAXDocumentFactory
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
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 Details
-
createDocument
Creates a Document instance.- Specified by:
createDocument
in interfaceDocumentFactory
- 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
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) throws IOException Creates a Document instance.- Specified by:
createDocument
in interfaceDocumentFactory
- 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
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
Creates a Document instance.- Specified by:
createDocument
in interfaceDocumentFactory
- 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
Creates a Document instance.- Specified by:
createDocument
in interfaceDocumentFactory
- 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
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) throws IOException 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
Creates a Document.- Parameters:
is
- The document input source.- Throws:
IOException
- if an error occured while reading the document.
-
getDocumentDescriptor
Returns the document descriptor associated with the latest created document.- Specified by:
getDocumentDescriptor
in interfaceDocumentFactory
- Returns:
- null if no document or descriptor was previously generated.
-
setDocumentLocator
SAX: ImplementsContentHandler.setDocumentLocator(Locator)
.- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
setValidating
public void setValidating(boolean isValidating) Sets whether or not the XML parser will validate the XML document depending on the specified parameter.- Specified by:
setValidating
in interfaceDocumentFactory
- Parameters:
isValidating
- indicates that the XML parser will validate the XML document
-
isValidating
public boolean isValidating()Returns true if the XML parser validates the XML stream, false otherwise.- Specified by:
isValidating
in interfaceDocumentFactory
-
setErrorHandler
Sets a custom error handler. -
getDOMImplementation
-
fatalError
SAX: ImplementsErrorHandler.fatalError(SAXParseException)
.- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
error
SAX: ImplementsErrorHandler.error(SAXParseException)
.- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXException
-
warning
SAX: ImplementsErrorHandler.warning(SAXParseException)
.- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXException
-
startDocument
SAX: ImplementsContentHandler.startDocument()
.- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String rawName, Attributes attributes) throws SAXException SAX: ImplementsContentHandler.startElement(String,String,String,Attributes)
.- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
SAX: ImplementsContentHandler.endElement(String,String,String)
.- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
appendStringData
public void appendStringData() -
characters
SAX: ImplementsContentHandler.characters(char[],int,int)
.- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
ignorableWhitespace
SAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int)
.- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
processingInstruction
SAX: ImplementsContentHandler.processingInstruction(String,String)
.- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
startDTD
SAX: ImplementsLexicalHandler.startDTD(String,String,String)
.- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
SAX: ImplementsLexicalHandler.endDTD()
.- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
SAX: ImplementsLexicalHandler.startEntity(String)
.- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
SAX: ImplementsLexicalHandler.endEntity(String)
.- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
SAX: ImplementsLexicalHandler.startCDATA()
.- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
SAX: ImplementsLexicalHandler.endCDATA()
.- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
SAX: ImplementsLexicalHandler.comment(char[],int,int)
.- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-