Beispiel #1
0
 def test_switchns(self):
     xml = (
         '<html xmlns="http://www.w3.org/1999/xhtml">'
         '<p>in default namespace</p>'
         '<foo:div xmlns:foo="http://www.w3.org/1999/xhtml">'
         '<foo:p>in foo namespace</foo:p></foo:div></html>')
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #2
0
 def test_otherns(self):
     xml = (
         '<html xmlns="http://www.w3.org/1999/xhtml" '
         'xmlns:xf="http://www.w3.org/2002/xforms"><p>'
         'in default namespace</p><xf:input><xf:label>'
         'in another namespace</xf:label></xf:input></html>')
     self.assertEqual(xml, flatten(parseString(xml)))
 def test_invisiblens(self):
     """
     Test that invisible tags do not get output with a namespace.
     """
     xml = ('<p xmlns:n="http://nevow.com/ns/nevow/0.1">'
            '<n:invisible>123</n:invisible></p>')
     self.failUnlessEqual('<p>123</p>', flatten(parseString(xml)))
Beispiel #4
0
 def load(self, ctx=None):
     if self._cache is None:
         doc = flatsax.parseString(self.template, self.ignoreDocType, self.ignoreComment)
         doc = flat.precompile(doc, ctx)
         if self.pattern is not None:
             doc = inevow.IQ(doc).onePattern(self.pattern)
         self._cache = doc
     return self._cache
Beispiel #5
0
 def test_invisiblens(self):
     """
     Test that invisible tags do not get output with a namespace.
     """
     xml = (
         '<p xmlns:n="http://nevow.com/ns/nevow/0.1">'
         '<n:invisible>123</n:invisible></p>')
     self.assertEqual('<p>123</p>', flatten(parseString(xml)))
Beispiel #6
0
 def load(self, ctx=None):
     if self._cache is None:
         doc = flatsax.parseString(self.template, self.ignoreDocType, self.ignoreComment)
         doc = flat.precompile(doc, ctx)
         if self.pattern is not None:
             doc = inevow.IQ(doc).onePattern(self.pattern)
         self._cache = doc
     return self._cache
Beispiel #7
0
    def test_commentWhereSpacingMatters(self):
        """Explicitly test that spacing in comments is maintained."""
        xml = """<head>
<!--[if IE]>
<style>
div.logo {
    margin-left: 10px;
}
</style>
<![endif]-->
</head>"""
        self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #8
0
 def load(self, ctx=None, preprocessors=()):
     """
     Get an instance, possibly cached from a previous call, of this document
     """
     if self._cache is None:
         doc = flatsax.parseString(self.template, self.ignoreDocType, self.ignoreComment)
         for proc in preprocessors:
             doc = proc(doc)
         doc = flat.precompile(doc, ctx)
         if self.pattern is not None:
             doc = inevow.IQ(doc).onePattern(self.pattern)
         self._cache = doc
     return self._cache
Beispiel #9
0
 def load(self, ctx=None, preprocessors=()):
     """
     Get an instance, possibly cached from a previous call, of this document
     """
     if self._cache is None:
         doc = flatsax.parseString(self.template, self.ignoreDocType,
                                   self.ignoreComment)
         for proc in preprocessors:
             doc = proc(doc)
         doc = flat.precompile(doc, ctx)
         if self.pattern is not None:
             doc = inevow.IQ(doc).onePattern(self.pattern)
         self._cache = doc
     return self._cache
Beispiel #10
0
    def test_commentWhereSpacingMatters(self):
        """
        Explicitly test that spacing in comments is maintained.
        """
        xml = """<head>
<!--[if IE]>
<style>
div.logo {
    margin-left: 10px;
}
</style>
<![endif]-->
</head>"""
        self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #11
0
 def test_unicodeComment(self):
     xml = '<!-- \xc2\xa3 --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)).encode("utf-8"))
Beispiel #12
0
 def test_badNamespace(self):
     xml = '<html foo:bar="wee"><abc:p>xyz</abc:p></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #13
0
 def test_unicodeComment(self):
     xml = '<!-- \xc2\xa3 --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #14
0
 def test_comment(self):
     xml = '<!-- comment &amp;&pound; --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #15
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #16
0
 def test_cdata(self):
     xml = '<script type="text/javascript"><![CDATA[&lt;abc]]></script>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #17
0
 def test_doctype(self):
     xml = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #18
0
 def test_cdata(self):
     xml = '''<script type="text/javascript"><![CDATA[&lt;abc]]></script>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #19
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #20
0
 def test_doctype(self):
     xml = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #21
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #22
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #23
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #24
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #25
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #26
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #27
0
 def test_comment(self):
     xml = '''<!-- comment &amp;&pound; --><html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #28
0
 def test_cdata(self):
     xml = '''<script type="text/javascript"><![CDATA[&lt;abc]]></script>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #29
0
 def test_unicodeComment(self):
     xml = '''<!-- \xc2\xa3 --><html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #30
0
 def test_otherns(self):
     xml = ('<html xmlns="http://www.w3.org/1999/xhtml" '
            'xmlns:xf="http://www.w3.org/2002/xforms"><p>'
            'in default namespace</p><xf:input><xf:label>'
            'in another namespace</xf:label></xf:input></html>')
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #31
0
 def test_xmlAttr(self):
     xml = '''<html xml:lang="en"></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #32
0
 def test_cdata(self):
     xml = '<script type="text/javascript"><![CDATA[&lt;abc]]></script>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #33
0
 def test_badNamespace(self):
     xml = '''<html foo:bar="wee"><abc:p>xyz</abc:p></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #34
0
 def test_switchns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"><p>in default namespace</p><foo:div xmlns:foo="http://www.w3.org/1999/xhtml"><foo:p>in foo namespace</foo:p></foo:div></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #35
0
 def test_otherns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"><p>in default namespace</p><xf:input><xf:label>in another namespace</xf:label></xf:input></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #36
0
 def test_xmlAttr(self):
     xml = '<html xml:lang="en"></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #37
0
 def test_switchns(self):
     xml = ('<html xmlns="http://www.w3.org/1999/xhtml">'
            '<p>in default namespace</p>'
            '<foo:div xmlns:foo="http://www.w3.org/1999/xhtml">'
            '<foo:p>in foo namespace</foo:p></foo:div></html>')
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #38
0
 def test_xmlAttr(self):
     xml = '<html xml:lang="en"></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #39
0
 def test_xmlAttr(self):
     xml = '''<html xml:lang="en"></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #40
0
 def test_comment(self):
     xml = '<!-- comment &amp;&pound; --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #41
0
 def test_switchns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"><p>in default namespace</p><foo:div xmlns:foo="http://www.w3.org/1999/xhtml"><foo:p>in foo namespace</foo:p></foo:div></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #42
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #43
0
 def test_badNamespace(self):
     xml = '<html foo:bar="wee"><abc:p>xyz</abc:p></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #44
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #45
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #46
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #47
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #48
0
 def test_comment(self):
     xml = '''<!-- comment &amp;&pound; --><html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #49
0
 def test_doctype(self):
     xml = (
         '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
         '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
         '<html></html>')
     self.assertEqual(norm(xml), norm(flatten(parseString(xml))))
Beispiel #50
0
 def test_unicodeComment(self):
     xml = '''<!-- \xc2\xa3 --><html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #51
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #52
0
 def test_badNamespace(self):
     xml = '''<html foo:bar="wee"><abc:p>xyz</abc:p></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #53
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #54
0
 def test_otherns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"><p>in default namespace</p><xf:input><xf:label>in another namespace</xf:label></xf:input></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
Beispiel #55
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #56
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
Beispiel #57
0
 def test_doctype(self):
     xml = (
         '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
         '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
         '<html></html>')
     self.assertEqual(norm(xml), norm(flatten(parseString(xml))))