public class TolerantSaxDocumentBuilder extends DefaultHandler implements LexicalHandler
ContentHandler
and
LexicalHandler
interfaces to build a DOM document in a tolerant
fashion -- it can cope with start tags without end tags, and end tags without
start tags for example.
Although this subverts the idea of XML being well-formed, it is intended
for use with HTML pages so that they can be transformed into DOM
trees, without being XHTML to start with.
Note that this class currently does not handle entity, DTD or CDATA tags.Constructor and Description |
---|
TolerantSaxDocumentBuilder(DocumentBuilder documentBuilder)
Constructor for specific JAXP parser
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] data,
int start,
int length)
ContentHandler method.
|
void |
comment(char[] ch,
int start,
int length)
LexicalHandler method
|
void |
endCDATA()
Unhandled LexicalHandler method
|
void |
endDocument()
ContentHandler method
|
void |
endDTD()
Unhandled LexicalHandler method
|
void |
endElement(String namespaceURI,
String localName,
String qName)
ContentHandler method
|
void |
endEntity(String name)
Unhandled LexicalHandler method
|
void |
endPrefixMapping(String prefix)
Unhandled ContentHandler method
|
Document |
getDocument() |
String |
getTrace() |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Unhandled ContentHandler method
|
void |
processingInstruction(String target,
String data)
ContentHandler method
|
void |
setDocumentLocator(Locator locator)
Unhandled ContentHandler method
|
void |
skippedEntity(String name)
Unhandled ContentHandler method
|
void |
startCDATA()
Unhandled LexicalHandler method
|
void |
startDocument()
ContentHandler method
|
void |
startDTD(String name,
String publicId,
String systemId)
Unhandled LexicalHandler method.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
ContentHandler method
|
void |
startEntity(String name)
Unhandled LexicalHandler method
|
void |
startPrefixMapping(String prefix,
String uri)
Unhandled ContentHandler method
|
error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning
public TolerantSaxDocumentBuilder(DocumentBuilder documentBuilder) throws ParserConfigurationException
documentBuilder
- the JAXP parser to use to construct an empty
DOM document that will be built up with SAX callsParserConfigurationException
public Document getDocument()
public String getTrace()
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
startDocument
in class DefaultHandler
SAXException
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
endDocument
in class DefaultHandler
SAXException
public void characters(char[] data, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class DefaultHandler
SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class DefaultHandler
SAXException
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
processingInstruction
in class DefaultHandler
SAXException
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
public void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
skippedEntity
in class DefaultHandler
SAXException
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultHandler
SAXException
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 length) throws SAXException
comment
in interface LexicalHandler
SAXException
Copyright © 2001–2017 XMLUnit. All rights reserved.