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 booleanWhether a document descriptor must be generated.protected NodeThe current node.protected DocumentTypeThe DTD to use when the document is created.protected DocumentThe created document.protected DocumentDescriptorThe created document descriptor.protected ErrorHandlerThe error handler.protected DOMImplementationThe DOM implementation used to create the document.protected booleanTrue if the parser is currently parsing a CDATA section.protected booleanTrue if the parser is currently parsing a DTD.protected booleanWhether the parser still hasn't read the document element's opening tag.protected booleanWhether the document just parsed was standalone.protected booleanWhether the parser is in validating mode.protected LocatorThe locator.protected HashTableStackThe stack used to store the namespace URIs.protected XMLReaderThe SAX2 parser object.protected StringThe SAX2 parser classname.protected ListVarious elements encountered prior to real document root element.protected StringBufferContains collected string data.protected booleanIndicates if stringBuffer has content, needed in case of zero sized "text" content.protected StringXML 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 TypeMethodDescriptionvoidvoidcharacters(char[] ch, int start, int length) SAX: ImplementsContentHandler.characters(char[],int,int).voidcomment(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 DocumentcreateDocument(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 DocumentCreates a Document.voidendCDATA()SAX: ImplementsLexicalHandler.endCDATA().voidendDTD()SAX: ImplementsLexicalHandler.endDTD().voidendElement(String uri, String localName, String rawName) SAX: ImplementsContentHandler.endElement(String,String,String).voidSAX: ImplementsLexicalHandler.endEntity(String).voidSAX: ImplementsErrorHandler.error(SAXParseException).voidSAX: ImplementsErrorHandler.fatalError(SAXParseException).Returns the document descriptor associated with the latest created document.voidignorableWhitespace(char[] ch, int start, int length) SAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int).booleanReturns true if the XML parser validates the XML stream, false otherwise.voidprocessingInstruction(String target, String data) SAX: ImplementsContentHandler.processingInstruction(String,String).voidSAX: ImplementsContentHandler.setDocumentLocator(Locator).voidSets a custom error handler.voidsetValidating(boolean isValidating) Sets whether or not the XML parser will validate the XML document depending on the specified parameter.voidSAX: ImplementsLexicalHandler.startCDATA().voidSAX: ImplementsContentHandler.startDocument().voidSAX: ImplementsLexicalHandler.startDTD(String,String,String).voidstartElement(String uri, String localName, String rawName, Attributes attributes) SAX: ImplementsContentHandler.startElement(String,String,String,Attributes).voidstartEntity(String name) SAX: ImplementsLexicalHandler.startEntity(String).voidSAX: ImplementsErrorHandler.warning(SAXParseException).Methods inherited from class DefaultHandler
endDocument, endPrefixMapping, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDeclMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:
createDocumentin 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:
createDocumentin 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:
createDocumentin 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:
createDocumentin 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:
getDocumentDescriptorin interfaceDocumentFactory- Returns:
- null if no document or descriptor was previously generated.
-
setDocumentLocator
SAX: ImplementsContentHandler.setDocumentLocator(Locator).- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin 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:
setValidatingin 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:
isValidatingin interfaceDocumentFactory
-
setErrorHandler
Sets a custom error handler. -
getDOMImplementation
-
fatalError
SAX: ImplementsErrorHandler.fatalError(SAXParseException).- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
error
SAX: ImplementsErrorHandler.error(SAXParseException).- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-
warning
SAX: ImplementsErrorHandler.warning(SAXParseException).- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException
-
startDocument
SAX: ImplementsContentHandler.startDocument().- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin 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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
SAX: ImplementsContentHandler.endElement(String,String,String).- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
appendStringData
public void appendStringData() -
characters
SAX: ImplementsContentHandler.characters(char[],int,int).- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
ignorableWhitespace
SAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int).- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Throws:
SAXException
-
processingInstruction
SAX: ImplementsContentHandler.processingInstruction(String,String).- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Throws:
SAXException
-
startDTD
SAX: ImplementsLexicalHandler.startDTD(String,String,String).- Specified by:
startDTDin interfaceLexicalHandler- Throws:
SAXException
-
endDTD
SAX: ImplementsLexicalHandler.endDTD().- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
startEntity
SAX: ImplementsLexicalHandler.startEntity(String).- Specified by:
startEntityin interfaceLexicalHandler- Throws:
SAXException
-
endEntity
SAX: ImplementsLexicalHandler.endEntity(String).- Specified by:
endEntityin interfaceLexicalHandler- Throws:
SAXException
-
startCDATA
SAX: ImplementsLexicalHandler.startCDATA().- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endCDATA
SAX: ImplementsLexicalHandler.endCDATA().- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
SAX: ImplementsLexicalHandler.comment(char[],int,int).- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-