4Suite API Documentation

Module Ft.Xml.Lib.TreeCompare

Comparison functions for XML and HTML documents (mainly used in the test suites)
Copyright 2005 Fourthought, Inc. (USA).
Detailed license and copyright information: http://4suite.org/COPYRIGHT
Project home, documentation, distributions: http://4suite.org/
Classes:
Functions:
Globals:

Classes

class SGMLParserEventGenerator(sgmllib.SGMLParser)
An HTML parser that meets our needs better than Python's htmllib.HTMLParser, and that works with Python 2.1.
Used by CompareHTML().

Methods

__init__(self, verbose=0)
Overrides: __init__ from class SGMLParser
close(self)
Overrides: close from class SGMLParser
flush(self)
handle_comment(self, data)
Overrides: handle_comment from class SGMLParser
handle_data(self, data)
Overrides: handle_data from class SGMLParser
unknown_charref(self, ref)
Overrides: unknown_charref from class SGMLParser
unknown_endtag(self, tag)
Overrides: unknown_endtag from class SGMLParser
unknown_entityref(self, ref)
Overrides: unknown_entityref from class SGMLParser
unknown_starttag(self, tagname, attrs)
Overrides: unknown_starttag from class SGMLParser

Methods inherited from class sgmllib.SGMLParser

error, feed, finish_endtag, finish_shorttag, finish_starttag, get_starttag_text, goahead, handle_charref, handle_decl, handle_endtag, handle_entityref, handle_pi, handle_starttag, parse_endtag, parse_pi, parse_starttag, report_unbalanced, reset, setliteral, setnomoretags

Methods inherited from class markupbase.ParserBase

getpos, parse_comment, parse_declaration, parse_marked_section, unknown_decl, updatepos

Members

CHARREF_EVENT = 7
COMMENT_EVENT = 2
END_TAG_EVENT = 4
ENTITYREF_EVENT = 6
START_TAG_EVENT = 3
TEXT_EVENT = 1

Members inherited from class sgmllib.SGMLParser

entitydefs

Functions

CompareHTML(html1, html2, ignoreWhitespace=0)
A cmp()-like function that compares two HTML strings by parsing with sgmllib.SGMLParser and comparing events until a mismatch is found. It has the side effect of reporting differences to stdout.
ignoreWhitespace controls whether whitespace differences in text
events are ignored.
HtmlTreeCompare(expected, compared)
Compare two HTML strings. The result is similar to the builtin cmp() function such that non-zero indicates non equal and zero means equal.
IsXmlSpace(S)
IsXmlSpace(S) -> bool
Return True if there are only whitespace characters in S, False otherwise.
NoWsTreeCompare(expected, compared)
Equivalent to calling TreeCompare() with ignoreWhitespace=1.
NodeCompare(node1, node2, ignoreWhitespace=0, ignoreComments=0, ignoreNsDecls=0)
A function that compares two XML DOM nodes by traversing their attributes and descendants recursively until a mismatch is found. It has the side effect of reporting differences to stdout. Returns true if the nodes compare equal.
ignoreWhitespace controls whether whitespace differences in text
nodes are ignored.

ignoreComments controls whether comment nodes are ignored.

ignoreNsDecls controls whether namespace declarations are ignored.
TreeCompare(expected, compared, ignoreWhitespace=0, baseUri=None, readExtDtd=True, ignoreNsDecls=0, asEntity=False)
A cmp()-like function that compares two XML or HTML strings and has the side effect of reporting differences to stdout. Returns false if the nodes compare equal.
XML strings are parsed into a Domlette and compared node-by-node.
HTML strings are parsed with an SGML parser and are compared
event-by-event. The markup type is guessed based on clues in the
expected string.

ignoreWhitespace controls whether whitespace differences in text
nodes are ignored.

'file:' URIs based on the current working directory are generated
for each document. The baseUri argument is an optional absolute URI
to use as the basis of the generated URIs, if a 'file' URI is
undesirable.

readExtDtd controls whether the external DTD subset is read
when parsing XML. It does not affect the reading of external
entities declared in the internal DTD subset.

ignoreNsDecls controls whether namespace declarations are ignored
when comparing XML documents.
XmlStrStrip(S)
XmlStrStrip(S) -> unicode
Return a copy of the string S with leading and trailing whitespace removed.
XmlTreeCompare(expected, compared)

Globals

BASIC_RESOLVER = <Ft.Lib.Uri.FtUriResolver instance>
FORBIDDEN_END_ELEMENTS = ['img', 'area', 'basefont', 'frame', 'isindex', 'meta', 'param', 'hr', 'base', 'link', 'br', 'input', 'col']
READ_EXTERNAL_DTD = True
XMLNS_NAMESPACE = u'http://www.w3.org/2000/xmlns/'
g_doctypeTest = <_sre.SRE_Pattern object>
g_htmlTest = <_sre.SRE_Pattern object>
g_xmlEmptyTagPattern = <_sre.SRE_Pattern object>
g_xmlTest = <_sre.SRE_Pattern object>