org.custommonkey.xmlunit

Class HTMLDocumentBuilder

public class HTMLDocumentBuilder extends Object

Build a DOM document from HTML content converting from 'plain' HTML into 'XHTML' along the way with the help of a TolerantSaxDocumentBuilder and the Swing html parser classes. This allows XML assertions to be made against badly formed HTML.
Examples and more at xmlunit.sourceforge.net

See Also: TolerantSaxDocumentBuilder

Nested Class Summary
classHTMLDocumentBuilder.SwingEvent2SaxAdapter
Adapts Swing HTML callback messages to Sax equivalents, passing them to a Sax-aware ContentHandler.
Field Summary
protected HTMLDocumentBuilder.SwingEvent2SaxAdapterswingEvent2SaxAdapter
protected TolerantSaxDocumentBuildertolerantSaxDocumentBuilder
Constructor Summary
HTMLDocumentBuilder(TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder)
Constructor
Method Summary
StringgetTrace()
Documentparse(Reader reader)
Documentparse(String htmlString)

Field Detail

swingEvent2SaxAdapter

protected final HTMLDocumentBuilder.SwingEvent2SaxAdapter swingEvent2SaxAdapter

tolerantSaxDocumentBuilder

protected final TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder

Constructor Detail

HTMLDocumentBuilder

public HTMLDocumentBuilder(TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder)
Constructor

Parameters: tolerantSaxDocumentBuilder the instance that will receive SAX calls generated as the HTML is parsed and build up a DOM Document

Method Detail

getTrace

public String getTrace()

Returns: the trace of events and / or warnings encountered during parsing

parse

public Document parse(Reader reader)

Returns: a DOM document parsed from the Reader via an SwingEvent2SaxAdapter and TolerantSaxBuilder. Not thread-safe!

See Also: TolerantSaxDocumentBuilder

parse

public Document parse(String htmlString)

Returns: a DOM document parsed from the String via an SwingEvent2SaxAdapter and TolerantSaxBuilder. Not thread-safe!

See Also: TolerantSaxDocumentBuilder