org.custommonkey.xmlunit
Class HTMLDocumentBuilder

java.lang.Object
  extended by org.custommonkey.xmlunit.HTMLDocumentBuilder

public class HTMLDocumentBuilder
extends java.lang.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
 class HTMLDocumentBuilder.SwingEvent2SaxAdapter
          Adapts Swing HTML callback messages to Sax equivalents, passing them to a Sax-aware ContentHandler.
 
Field Summary
protected  HTMLDocumentBuilder.SwingEvent2SaxAdapter swingEvent2SaxAdapter
           
protected  TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder
           
 
Constructor Summary
HTMLDocumentBuilder(TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder)
          Constructor
 
Method Summary
 java.lang.String getTrace()
           
 org.w3c.dom.Document parse(java.io.Reader reader)
           
 org.w3c.dom.Document parse(java.lang.String htmlString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tolerantSaxDocumentBuilder

protected final TolerantSaxDocumentBuilder tolerantSaxDocumentBuilder

swingEvent2SaxAdapter

protected final HTMLDocumentBuilder.SwingEvent2SaxAdapter swingEvent2SaxAdapter
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

parse

public org.w3c.dom.Document parse(java.io.Reader reader)
                           throws org.xml.sax.SAXException,
                                  java.io.IOException
Returns:
a DOM document parsed from the Reader via an SwingEvent2SaxAdapter and TolerantSaxBuilder. Not thread-safe!
Throws:
org.xml.sax.SAXException
java.io.IOException
See Also:
TolerantSaxDocumentBuilder

parse

public org.w3c.dom.Document parse(java.lang.String htmlString)
                           throws org.xml.sax.SAXException,
                                  java.io.IOException
Returns:
a DOM document parsed from the String via an SwingEvent2SaxAdapter and TolerantSaxBuilder. Not thread-safe!
Throws:
org.xml.sax.SAXException
java.io.IOException
See Also:
TolerantSaxDocumentBuilder

getTrace

public java.lang.String getTrace()
Returns:
the trace of events and / or warnings encountered during parsing

XMLUnit is hosted by sourceforge.net