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,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.LexicalHandler
- Direct Known Subclasses:
SAXSVGDocumentFactory
public class SAXDocumentFactory extends org.xml.sax.helpers.DefaultHandler implements org.xml.sax.ext.LexicalHandler, DocumentFactory
This class contains methods for creating Document instances from an URI using SAX2.- Version:
- $Id: SAXDocumentFactory.java 1851346 2019-01-15 13:41:00Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSAXDocumentFactory.CDataInfo(package private) static classSAXDocumentFactory.CommentInfoprotected static interfaceSAXDocumentFactory.PreInfo(package private) static classSAXDocumentFactory.ProcessingInstructionInfo(package private) static classSAXDocumentFactory.TextInfo
-
Field Summary
Fields Modifier and Type Field Description protected booleancreateDocumentDescriptorWhether a document descriptor must be generated.protected org.w3c.dom.NodecurrentNodeThe current node.protected org.w3c.dom.DocumentTypedoctypeThe DTD to use when the document is created.protected org.w3c.dom.DocumentdocumentThe created document.protected DocumentDescriptordocumentDescriptorThe created document descriptor.protected org.xml.sax.ErrorHandlererrorHandlerThe error handler.protected org.w3c.dom.DOMImplementationimplementationThe DOM implementation used to create the document.protected booleaninCDATATrue if the parser is currently parsing a CDATA section.protected booleaninDTDTrue if the parser is currently parsing a DTD.protected booleaninPrologWhether the parser still hasn't read the document element's opening tag.protected booleanisStandaloneWhether the document just parsed was standalone.protected booleanisValidatingWhether the parser is in validating mode.protected org.xml.sax.LocatorlocatorThe locator.protected HashTableStacknamespacesThe stack used to store the namespace URIs.protected org.xml.sax.XMLReaderparserThe SAX2 parser object.protected java.lang.StringparserClassNameThe SAX2 parser classname.protected java.util.ListpreInfoVarious elements encountered prior to real document root element.(package private) static javax.xml.parsers.SAXParserFactorysaxFactoryprotected java.lang.StringBufferstringBufferContains collected string data.protected booleanstringContentIndicates if stringBuffer has content, needed in case of zero sized "text" content.protected java.lang.StringxmlVersionXML version of the document just parsed.
-
Constructor Summary
Constructors Constructor Description SAXDocumentFactory(org.w3c.dom.DOMImplementation impl, java.lang.String parser)Creates a new SAXDocumentFactory object.SAXDocumentFactory(org.w3c.dom.DOMImplementation impl, java.lang.String parser, boolean dd)Creates a new SAXDocumentFactory object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendStringData()voidcharacters(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).org.w3c.dom.DocumentcreateDocument(java.lang.String uri)Creates a Document instance.org.w3c.dom.DocumentcreateDocument(java.lang.String uri, java.io.InputStream is)Creates a Document instance.org.w3c.dom.DocumentcreateDocument(java.lang.String uri, java.io.Reader r)Creates a Document instance.org.w3c.dom.DocumentcreateDocument(java.lang.String ns, java.lang.String root, java.lang.String uri)Creates a Document instance.org.w3c.dom.DocumentcreateDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, java.io.InputStream is)Creates a Document instance.org.w3c.dom.DocumentcreateDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, java.io.Reader r)Creates a Document instance.protected org.w3c.dom.DocumentcreateDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, org.xml.sax.InputSource is)Creates a Document.org.w3c.dom.DocumentcreateDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, org.xml.sax.XMLReader r)Creates a Document instance.protected org.w3c.dom.DocumentcreateDocument(org.xml.sax.InputSource is)Creates a Document.voidendCDATA()SAX: ImplementsLexicalHandler.endCDATA().voidendDTD()SAX: ImplementsLexicalHandler.endDTD().voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)SAX: ImplementsContentHandler.endElement(String,String,String).voidendEntity(java.lang.String name)SAX: ImplementsLexicalHandler.endEntity(String).voiderror(org.xml.sax.SAXParseException ex)SAX: ImplementsErrorHandler.error(SAXParseException).voidfatalError(org.xml.sax.SAXParseException ex)SAX: ImplementsErrorHandler.fatalError(SAXParseException).DocumentDescriptorgetDocumentDescriptor()Returns the document descriptor associated with the latest created document.org.w3c.dom.DOMImplementationgetDOMImplementation(java.lang.String ver)voidignorableWhitespace(char[] ch, int start, int length)SAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int).booleanisValidating()Returns true if the XML parser validates the XML stream, false otherwise.voidprocessingInstruction(java.lang.String target, java.lang.String data)SAX: ImplementsContentHandler.processingInstruction(String,String).voidsetDocumentLocator(org.xml.sax.Locator l)SAX: ImplementsContentHandler.setDocumentLocator(Locator).voidsetErrorHandler(org.xml.sax.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: ImplementsLexicalHandler.startCDATA().voidstartDocument()SAX: ImplementsContentHandler.startDocument().voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)SAX: ImplementsLexicalHandler.startDTD(String,String,String).voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)SAX: ImplementsContentHandler.startElement(String,String,String,Attributes).voidstartEntity(java.lang.String name)SAX: ImplementsLexicalHandler.startEntity(String).voidwarning(org.xml.sax.SAXParseException ex)SAX: ImplementsErrorHandler.warning(SAXParseException).
-
-
-
Field Detail
-
implementation
protected org.w3c.dom.DOMImplementation implementation
The DOM implementation used to create the document.
-
parserClassName
protected java.lang.String parserClassName
The SAX2 parser classname.
-
parser
protected org.xml.sax.XMLReader parser
The SAX2 parser object.
-
document
protected org.w3c.dom.Document document
The created document.
-
documentDescriptor
protected DocumentDescriptor documentDescriptor
The created document descriptor.
-
createDocumentDescriptor
protected boolean createDocumentDescriptor
Whether a document descriptor must be generated.
-
currentNode
protected org.w3c.dom.Node currentNode
The current node.
-
locator
protected org.xml.sax.Locator locator
The locator.
-
stringBuffer
protected java.lang.StringBuffer stringBuffer
Contains collected string data. May be Text, CDATA or Comment.
-
doctype
protected org.w3c.dom.DocumentType doctype
The DTD to use when the document is created.
-
stringContent
protected boolean stringContent
Indicates if stringBuffer has content, needed in case of zero sized "text" content.
-
inDTD
protected boolean inDTD
True if the parser is currently parsing a DTD.
-
inCDATA
protected boolean inCDATA
True if the parser is currently parsing a CDATA section.
-
inProlog
protected boolean inProlog
Whether the parser still hasn't read the document element's opening tag.
-
isValidating
protected boolean isValidating
Whether the parser is in validating mode.
-
isStandalone
protected boolean isStandalone
Whether the document just parsed was standalone.
-
xmlVersion
protected java.lang.String xmlVersion
XML version of the document just parsed.
-
namespaces
protected HashTableStack namespaces
The stack used to store the namespace URIs.
-
errorHandler
protected org.xml.sax.ErrorHandler errorHandler
The error handler.
-
preInfo
protected java.util.List preInfo
Various elements encountered prior to real document root element. List of PreInfo objects.
-
saxFactory
static javax.xml.parsers.SAXParserFactory saxFactory
-
-
Constructor Detail
-
SAXDocumentFactory
public SAXDocumentFactory(org.w3c.dom.DOMImplementation impl, java.lang.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(org.w3c.dom.DOMImplementation impl, java.lang.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
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String uri) throws java.io.IOExceptionCreates a Document instance.- Parameters:
uri- The document URI.- Throws:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, java.io.InputStream is) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String uri, java.io.InputStream is) throws java.io.IOExceptionCreates a Document instance.- Parameters:
uri- The document URI.is- The document input stream.- Throws:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, java.io.Reader r) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, org.xml.sax.XMLReader r) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an error occured while reading the document.
-
createDocument
public org.w3c.dom.Document createDocument(java.lang.String uri, java.io.Reader r) throws java.io.IOExceptionCreates a Document instance.- Parameters:
uri- The document URI.r- The document reader.- Throws:
java.io.IOException- if an error occured while reading the document.
-
createDocument
protected org.w3c.dom.Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, org.xml.sax.InputSource is) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an error occured while reading the document.
-
createDocument
protected org.w3c.dom.Document createDocument(org.xml.sax.InputSource is) throws java.io.IOExceptionCreates a Document.- Parameters:
is- The document input source.- Throws:
java.io.IOException- if an error occured while reading the document.
-
getDocumentDescriptor
public DocumentDescriptor 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
public void setDocumentLocator(org.xml.sax.Locator l)
SAX: ImplementsContentHandler.setDocumentLocator(Locator).- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler
-
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
public void setErrorHandler(org.xml.sax.ErrorHandler eh)
Sets a custom error handler.
-
getDOMImplementation
public org.w3c.dom.DOMImplementation getDOMImplementation(java.lang.String ver)
-
fatalError
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXExceptionSAX: ImplementsErrorHandler.fatalError(SAXParseException).- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
error
public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXExceptionSAX: ImplementsErrorHandler.error(SAXParseException).- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
warning
public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXExceptionSAX: ImplementsErrorHandler.warning(SAXParseException).- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Overrides:
warningin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.startDocument().- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.startElement(String,String,String,Attributes).- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName) throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.endElement(String,String,String).- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
appendStringData
public void appendStringData()
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.characters(char[],int,int).- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.ignorableWhitespace(char[],int,int).- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXExceptionSAX: ImplementsContentHandler.processingInstruction(String,String).- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.startDTD(String,String,String).- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.endDTD().- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.startEntity(String).- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.endEntity(String).- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.startCDATA().- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.endCDATA().- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionSAX: ImplementsLexicalHandler.comment(char[],int,int).- Specified by:
commentin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
-