public class SAXHandler extends DefaultHandler implements LexicalHandler, DeclHandler
This class doesn't depend on SAXBuilder, so it can be used in any other place, e.g., javax.xml.transform.sax.SAXResult.
SAXBuilder| Modifier and Type | Field and Description |
|---|---|
protected List<Namespace> |
_declNamespaces
The namespaces in between startPrefixMapping and endPrefixMapping.
|
protected Document |
_doc
The Document being created.
|
protected IDOMFactory |
_factory
The iDOM factory.
|
protected boolean |
_inCData
Indicator of whether we are in a CDATA.
|
protected boolean |
_inDTD
Indicator of whether we are in a DTD.
|
protected Locator |
_loc
Locator.
|
protected Stack<Group> |
_stack
The Group stack.
|
| Constructor and Description |
|---|
SAXHandler()
Constructor.
|
SAXHandler(IDOMFactory factory)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToCurrentGroup(Item vtx)
Adds the item to the current group; also attach the locator.
|
protected void |
attachLocator(Item vtx)
Attaches the locator to the item.
|
void |
attributeDecl(String eName,
String aName,
String type,
String valueDefault,
String value) |
void |
characters(char[] ch,
int start,
int length) |
void |
comment(char[] ch,
int start,
int length) |
protected InputSource |
defaultResolveEntity(String publicId,
String systemId)
The default entity resolver.
|
void |
elementDecl(String name,
String model) |
void |
endCDATA() |
void |
endDocument() |
void |
endDTD() |
void |
endElement(String nsURI,
String lname,
String tname) |
void |
endEntity(String name) |
void |
endPrefixMapping(String prefix) |
void |
error(SAXParseException ex) |
void |
externalEntityDecl(String name,
String pubId,
String sysId) |
void |
fatalError(SAXParseException ex) |
Document |
getDocument()
Gets the document being created.
|
EntityResolver |
getEntityResolver()
Gets the org.xml.sax.EntityResolver.
|
ErrorHandler |
getErrorHandler()
Gets the org.xml.sax.ErrorHandler.
|
IDOMFactory |
getIDOMFactory()
Gets the iDOM factory.
|
protected Group |
getTopGroup()
Returns the top group, or null if not available.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
void |
internalEntityDecl(String name,
String value) |
boolean |
isCoalescing()
Indicates whether or not the factory is configured to produce parsers
which converts CDATA to Text and appends it to the adjacent (if any)
Text node.
|
boolean |
isExpandEntityReferences()
Tests whether to expand entity reference nodes.
|
boolean |
isIgnoringComments()
Indicates whether or not the factory is configured to produce parsers
which ignores comments.
|
boolean |
isIgnoringElementContentWhitespace()
Tests whether to ignore whitespaces in element content.
|
void |
notationDecl(String name,
String publicID,
String systemID) |
protected void |
popGroup()
Pops out the current group, and the one under it becomes the
new current group.
|
void |
processingInstruction(String target,
String data) |
protected void |
pushGroup(Group group)
Adds a new group to the current group as a child,
and pushes the new group to be the new current group.
|
InputSource |
resolveEntity(String publicId,
String systemId) |
void |
setCoalescing(boolean coalescing)
Specifies that the parser produced by this code will convert
CDATA to Text and append it to the adjacent (if any) text.
|
void |
setDocumentLocator(Locator locator) |
void |
setEntityResolver(EntityResolver er)
Specifies the org.xml.sax.EntityResolver to be used to resolve
entities present in the XML document to be parsed.
|
void |
setErrorHandler(ErrorHandler eh)
Specifies the org.xml.sax.ErrorHandler to be used to report errors
present in the XML document to be parsed.
|
void |
setExpandEntityReferences(boolean expand)
Sets whether to expand entities during parsing.
|
void |
setIDOMFactory(IDOMFactory factory)
Sets the iDOM factory.
|
void |
setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will ignore comments.
|
void |
setIgnoringElementContentWhitespace(boolean ignore)
Sets whether the parser should eliminate whitespace in
element content.
|
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(String name,
String pubId,
String sysId) |
void |
startElement(String nsURI,
String lname,
String tname,
Attributes attrs) |
void |
startEntity(String name) |
void |
startPrefixMapping(String prefix,
String uri) |
void |
unparsedEntityDecl(String name,
String pubId,
String sysId,
String notationName) |
void |
warning(SAXParseException ex) |
skippedEntityprotected IDOMFactory _factory
protected Document _doc
protected Locator _loc
protected boolean _inDTD
protected boolean _inCData
protected Stack<Group> _stack
public SAXHandler(IDOMFactory factory)
factory - the iDOM factory; null for DefaultIDOMFactory.public SAXHandler()
public final boolean isIgnoringElementContentWhitespace()
public final void setIgnoringElementContentWhitespace(boolean ignore)
For this setting to take effect requires that validation be turned on.
Default: false.
ignore - Whether to ignore whitespaces in element content.public final boolean isExpandEntityReferences()
public final void setExpandEntityReferences(boolean expand)
EntityReference objects.
Default: true.
expand - whether entity expansion should occur.public final boolean isCoalescing()
Default: false.
public final void setCoalescing(boolean coalescing)
Default: false.
public final boolean isIgnoringComments()
Default: false.
public final void setIgnoringComments(boolean ignoreComments)
Default: false.
public final void setErrorHandler(ErrorHandler eh)
Default: null -- to use the default implementation and behavior.
public final ErrorHandler getErrorHandler()
public final void setEntityResolver(EntityResolver er)
Default: null -- to use the default implementation and behavior.
public final EntityResolver getEntityResolver()
public final Document getDocument()
public final IDOMFactory getIDOMFactory()
public final void setIDOMFactory(IDOMFactory factory)
protected final void attachLocator(Item vtx)
protected final Group getTopGroup()
protected final void addToCurrentGroup(Item vtx)
protected final void pushGroup(Group group)
protected final void popGroup()
public void externalEntityDecl(String name, String pubId, String sysId) throws SAXException
externalEntityDecl in interface DeclHandlerSAXExceptionpublic void internalEntityDecl(String name, String value) throws SAXException
internalEntityDecl in interface DeclHandlerSAXExceptionpublic void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
attributeDecl in interface DeclHandlerSAXExceptionpublic void elementDecl(String name, String model) throws SAXException
elementDecl in interface DeclHandlerSAXExceptionpublic void startDTD(String name, String pubId, String sysId) throws SAXException
startDTD in interface LexicalHandlerSAXExceptionpublic void endDTD()
throws SAXException
endDTD in interface LexicalHandlerSAXExceptionpublic void startEntity(String name) throws SAXException
startEntity in interface LexicalHandlerSAXExceptionpublic void endEntity(String name) throws SAXException
endEntity in interface LexicalHandlerSAXExceptionpublic void startCDATA()
throws SAXException
startCDATA in interface LexicalHandlerSAXExceptionpublic void endCDATA()
throws SAXException
endCDATA in interface LexicalHandlerSAXExceptionpublic void comment(char[] ch,
int start,
int length)
throws SAXException
comment in interface LexicalHandlerSAXExceptionpublic void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class DefaultHandlerSAXExceptionpublic void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class DefaultHandlerSAXExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class DefaultHandlerpublic void processingInstruction(String target, String data) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class DefaultHandlerSAXExceptionpublic void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class DefaultHandlerSAXExceptionpublic void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping in interface ContentHandlerendPrefixMapping in class DefaultHandlerSAXExceptionpublic void startElement(String nsURI, String lname, String tname, Attributes attrs) throws SAXException
startElement in interface ContentHandlerstartElement in class DefaultHandlerSAXExceptionpublic void endElement(String nsURI, String lname, String tname) throws SAXException
endElement in interface ContentHandlerendElement in class DefaultHandlerSAXExceptionpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class DefaultHandlerSAXExceptionpublic void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class DefaultHandlerSAXExceptionpublic void notationDecl(String name, String publicID, String systemID) throws SAXException
notationDecl in interface DTDHandlernotationDecl in class DefaultHandlerSAXExceptionpublic void unparsedEntityDecl(String name, String pubId, String sysId, String notationName) throws SAXException
unparsedEntityDecl in interface DTDHandlerunparsedEntityDecl in class DefaultHandlerSAXExceptionpublic InputSource resolveEntity(String publicId, String systemId) throws SAXException
resolveEntity in interface EntityResolverresolveEntity in class DefaultHandlerSAXExceptionprotected InputSource defaultResolveEntity(String publicId, String systemId) throws SAXException
setEntityResolver(org.xml.sax.EntityResolver) is not called.
This implementation searches the class path under /metainfo/xml.
For example, http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd is asked. It searches from classpath for /metainfo/xml/java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd and /metainfo/xml/portlet-app_1_0.xsd
SAXExceptionpublic void warning(SAXParseException ex) throws SAXException
warning in interface ErrorHandlerwarning in class DefaultHandlerSAXExceptionpublic void error(SAXParseException ex) throws SAXException
error in interface ErrorHandlererror in class DefaultHandlerSAXExceptionpublic void fatalError(SAXParseException ex) throws SAXException
fatalError in interface ErrorHandlerfatalError in class DefaultHandlerSAXExceptionCopyright © 2018. All rights reserved.