public class SAXContentHandler extends org.xml.sax.helpers.DefaultHandler implements LexicalHandler, DeclHandler, DTDHandler
SAXContentHandler
builds a dom4j tree via SAX events.
Constructor and Description |
---|
SAXContentHandler() |
SAXContentHandler(DocumentFactory documentFactory) |
SAXContentHandler(DocumentFactory documentFactory,
ElementHandler elementHandler) |
SAXContentHandler(DocumentFactory documentFactory,
ElementHandler elementHandler,
org.dom4j.io.ElementStack elementStack) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAttributes(Element element,
Attributes attributes)
Add all the attributes to the given elements
|
protected void |
addDeclaredNamespaces(Element element)
Add all namespaces declared before the startElement() SAX event to the
current element so that they are available to child elements and
attributes
|
protected void |
addDTDDeclaration(Object declaration)
Adds an internal DTD declaration to the list of declarations
|
protected void |
addExternalDTDDeclaration(Object declaration)
Adds an external DTD declaration to the list of declarations
|
void |
attributeDecl(String eName,
String aName,
String type,
String valueDefault,
String val)
Report an attribute type declaration.
|
void |
characters(char[] ch,
int start,
int end) |
void |
comment(char[] ch,
int start,
int end) |
protected void |
completeCurrentTextNode()
If the current text buffer contains any text then create a new text node
with it and add it to the current element
|
protected Document |
createDocument()
DOCUMENT ME!
|
protected org.dom4j.io.ElementStack |
createElementStack() |
void |
elementDecl(String name,
String model)
Report an element type declaration.
|
void |
endCDATA() |
void |
endDocument() |
void |
endDTD() |
void |
endElement(String namespaceURI,
String localName,
String qName) |
void |
endEntity(String name) |
void |
endPrefixMapping(String prefix) |
void |
error(SAXParseException exception)
This method is called when an error is detected during parsing such as a
validation error.
|
void |
externalEntityDecl(String name,
String publicId,
String sysId)
Report a parsed external entity declaration.
|
void |
fatalError(SAXParseException exception)
This method is called when a fatal error occurs during parsing.
|
Document |
getDocument()
DOCUMENT ME!
|
org.dom4j.io.ElementStack |
getElementStack() |
EntityResolver |
getEntityResolver() |
InputSource |
getInputSource() |
void |
internalEntityDecl(String name,
String value)
Report an internal entity declaration.
|
protected boolean |
isIgnorableEntity(String name)
a Strategy Method to determine if a given entity name is ignorable
|
boolean |
isIgnoreComments()
Returns whether we should ignore comments or not.
|
boolean |
isIncludeExternalDTDDeclarations()
DOCUMENT ME!
|
boolean |
isIncludeInternalDTDDeclarations()
DOCUMENT ME!
|
boolean |
isMergeAdjacentText()
Returns whether adjacent text nodes should be merged together.
|
boolean |
isStripWhitespaceText()
Sets whether whitespace between element start and end tags should be
ignored
|
void |
notationDecl(String name,
String publicId,
String systemId)
Receive notification of a notation declaration event.
|
void |
processingInstruction(String target,
String data) |
void |
setDocumentLocator(Locator documentLocator) |
void |
setElementStack(org.dom4j.io.ElementStack elementStack) |
void |
setEntityResolver(EntityResolver entityResolver) |
void |
setIgnoreComments(boolean ignoreComments)
Sets whether we should ignore comments or not.
|
void |
setIncludeExternalDTDDeclarations(boolean include)
Sets whether DTD external declarations should be expanded into the
DocumentType object or not.
|
void |
setIncludeInternalDTDDeclarations(boolean include)
Sets whether internal DTD declarations should be expanded into the
DocumentType object or not.
|
void |
setInputSource(InputSource inputSource) |
void |
setMergeAdjacentText(boolean mergeAdjacentText)
Sets whether or not adjacent text nodes should be merged together when
parsing.
|
void |
setStripWhitespaceText(boolean stripWhitespaceText)
Sets whether whitespace between element start and end tags should be
ignored.
|
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(String name,
String publicId,
String systemId) |
void |
startElement(String namespaceURI,
String localName,
String qualifiedName,
Attributes attributes) |
void |
startEntity(String name) |
void |
startPrefixMapping(String prefix,
String uri) |
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName)
Receive notification of an unparsed entity declaration event.
|
void |
warning(SAXParseException exception)
This method is called when a warning occurs during the parsing of the
document.
|
ignorableWhitespace, resolveEntity, skippedEntity
public SAXContentHandler()
public SAXContentHandler(DocumentFactory documentFactory)
public SAXContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler)
public SAXContentHandler(DocumentFactory documentFactory, ElementHandler elementHandler, org.dom4j.io.ElementStack elementStack)
public Document getDocument()
public void setDocumentLocator(Locator documentLocator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
processingInstruction
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void characters(char[] ch, int start, int end) throws SAXException
characters
in interface ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void warning(SAXParseException exception) throws SAXException
warning
in interface ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
exception
- DOCUMENT ME!SAXException
- DOCUMENT ME!public void error(SAXParseException exception) throws SAXException
error
in interface ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
exception
- DOCUMENT ME!SAXException
- DOCUMENT ME!public void fatalError(SAXParseException exception) throws SAXException
fatalError
in interface ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
exception
- DOCUMENT ME!SAXException
- DOCUMENT ME!public void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD
in interface LexicalHandler
SAXException
public void endDTD() throws SAXException
endDTD
in interface LexicalHandler
SAXException
public void startEntity(String name) throws SAXException
startEntity
in interface LexicalHandler
SAXException
public void endEntity(String name) throws SAXException
endEntity
in interface LexicalHandler
SAXException
public void startCDATA() throws SAXException
startCDATA
in interface LexicalHandler
SAXException
public void endCDATA() throws SAXException
endCDATA
in interface LexicalHandler
SAXException
public void comment(char[] ch, int start, int end) throws SAXException
comment
in interface LexicalHandler
SAXException
public void elementDecl(String name, String model) throws SAXException
The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all parameter entities are fully resolved and all whitespace is removed,and will include the enclosing parentheses. Other normalization (such as removing redundant parentheses or simplifying occurrence indicators) is at the discretion of the parser.
elementDecl
in interface DeclHandler
name
- The element type name.model
- The content model as a normalized string.SAXException
- The application may raise an exception.public void attributeDecl(String eName, String aName, String type, String valueDefault, String val) throws SAXException
Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group with the separator "|" and all whitespace removed, or the word "NOTATION" followed by a space followed by a parenthesized token group with all whitespace removed.
Any parameter entities in the attribute value will be expanded, but general entities will not.
attributeDecl
in interface DeclHandler
eName
- The name of the associated element.aName
- The name of the attribute.type
- A string representing the attribute type.valueDefault
- A string representing the attribute default ("#IMPLIED",
"#REQUIRED", or "#FIXED") or null if none of these applies.val
- A string representing the attribute's default value, or null
if there is none.SAXException
- The application may raise an exception.public void internalEntityDecl(String name, String value) throws SAXException
Only the effective (first) declaration for each entity will be reported. All parameter entities in the value will be expanded, but general entities will not.
internalEntityDecl
in interface DeclHandler
name
- The name of the entity. If it is a parameter entity, the name
will begin with '%'.value
- The replacement text of the entity.SAXException
- The application may raise an exception.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void externalEntityDecl(String name, String publicId, String sysId) throws SAXException
Only the effective (first) declaration for each entity will be reported.
externalEntityDecl
in interface DeclHandler
name
- The name of the entity. If it is a parameter entity, the name
will begin with '%'.publicId
- The declared public identifier of the entity, or null if none
was declared.sysId
- The declared system identifier of the entity.SAXException
- The application may raise an exception.internalEntityDecl(java.lang.String, java.lang.String)
,
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void notationDecl(String name, String publicId, String systemId) throws SAXException
It is up to the application to record the notation for later reference, if necessary.
At least one of publicId and systemId must be non-null. If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application through this event.
There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.
notationDecl
in interface DTDHandler
notationDecl
in class org.xml.sax.helpers.DefaultHandler
name
- The notation name.publicId
- The notation's public identifier, or null if none was given.systemId
- The notation's system identifier, or null if none was given.SAXException
- Any SAX exception, possibly wrapping another exception.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
AttributeList
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
Note that the notation name corresponds to a notation reported by the
notationDecl
event. It is up to the application to
record the entity for later reference, if necessary.
If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
unparsedEntityDecl
in interface DTDHandler
unparsedEntityDecl
in class org.xml.sax.helpers.DefaultHandler
name
- The unparsed entity's name.publicId
- The entity's public identifier, or null if none was given.systemId
- The entity's system identifier.notationName
- The name of the associated notation.SAXException
- Any SAX exception, possibly wrapping another exception.notationDecl(java.lang.String, java.lang.String, java.lang.String)
,
AttributeList
public org.dom4j.io.ElementStack getElementStack()
public void setElementStack(org.dom4j.io.ElementStack elementStack)
public EntityResolver getEntityResolver()
public void setEntityResolver(EntityResolver entityResolver)
public InputSource getInputSource()
public void setInputSource(InputSource inputSource)
public boolean isIncludeInternalDTDDeclarations()
public void setIncludeInternalDTDDeclarations(boolean include)
include
- whether or not DTD declarations should be expanded and
included into the DocumentType object.public boolean isIncludeExternalDTDDeclarations()
public void setIncludeExternalDTDDeclarations(boolean include)
include
- whether or not DTD declarations should be expanded and
included into the DocumentType object.public boolean isMergeAdjacentText()
public void setMergeAdjacentText(boolean mergeAdjacentText)
mergeAdjacentText
- New value of property mergeAdjacentText.public boolean isStripWhitespaceText()
public void setStripWhitespaceText(boolean stripWhitespaceText)
stripWhitespaceText
- New value of property stripWhitespaceText.public boolean isIgnoreComments()
public void setIgnoreComments(boolean ignoreComments)
ignoreComments
- whether we should ignore comments or not.protected void completeCurrentTextNode()
protected Document createDocument()
protected boolean isIgnorableEntity(String name)
name
- DOCUMENT ME!protected void addDeclaredNamespaces(Element element)
element
- DOCUMENT ME!protected void addAttributes(Element element, Attributes attributes)
element
- DOCUMENT ME!attributes
- DOCUMENT ME!protected void addDTDDeclaration(Object declaration)
declaration
- DOCUMENT ME!protected void addExternalDTDDeclaration(Object declaration)
declaration
- DOCUMENT ME!protected org.dom4j.io.ElementStack createElementStack()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.