示例#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)))
示例#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)))
示例#3
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.failUnlessEqual('<p>123</p>', flatten(parseString(xml)))
示例#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
示例#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)))
示例#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
示例#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)))
示例#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
示例#9
0
文件: loaders.py 项目: calston/tums
 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
示例#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)))
示例#11
0
 def test_unicodeComment(self):
     xml = '<!-- \xc2\xa3 --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)).encode("utf-8"))
示例#12
0
 def test_badNamespace(self):
     xml = '<html foo:bar="wee"><abc:p>xyz</abc:p></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#13
0
 def test_unicodeComment(self):
     xml = '<!-- \xc2\xa3 --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#14
0
 def test_comment(self):
     xml = '<!-- comment &amp;&pound; --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#15
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.assertEqual(xml, flatten(parseString(xml)))
示例#16
0
 def test_cdata(self):
     xml = '<script type="text/javascript"><![CDATA[&lt;abc]]></script>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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))))
示例#18
0
 def test_cdata(self):
     xml = '''<script type="text/javascript"><![CDATA[&lt;abc]]></script>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#19
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#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))))
示例#21
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#22
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#23
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#24
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#25
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#26
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#27
0
 def test_comment(self):
     xml = '''<!-- comment &amp;&pound; --><html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#28
0
 def test_cdata(self):
     xml = '''<script type="text/javascript"><![CDATA[&lt;abc]]></script>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#29
0
 def test_unicodeComment(self):
     xml = '''<!-- \xc2\xa3 --><html></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#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)))
示例#31
0
 def test_xmlAttr(self):
     xml = '''<html xml:lang="en"></html>'''
     self.failUnlessEqual(norm(xml), norm(flatten(parseString(xml))))
示例#32
0
 def test_cdata(self):
     xml = '<script type="text/javascript"><![CDATA[&lt;abc]]></script>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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))))
示例#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))))
示例#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))))
示例#36
0
 def test_xmlAttr(self):
     xml = '<html xml:lang="en"></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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)))
示例#38
0
 def test_xmlAttr(self):
     xml = '<html xml:lang="en"></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#39
0
 def test_xmlAttr(self):
     xml = '''<html xml:lang="en"></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#40
0
 def test_comment(self):
     xml = '<!-- comment &amp;&pound; --><html></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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)))
示例#42
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#43
0
 def test_badNamespace(self):
     xml = '<html foo:bar="wee"><abc:p>xyz</abc:p></html>'
     self.assertEqual(xml, flatten(parseString(xml)))
示例#44
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#45
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.assertEqual(xml, flatten(parseString(xml)))
示例#46
0
 def test_entities(self):
     xml = """<p>&amp;</p>"""
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#47
0
 def test_processingInstruction(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
示例#48
0
 def test_comment(self):
     xml = '''<!-- comment &amp;&pound; --><html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#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))))
示例#50
0
 def test_unicodeComment(self):
     xml = '''<!-- \xc2\xa3 --><html></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#51
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
示例#52
0
 def test_badNamespace(self):
     xml = '''<html foo:bar="wee"><abc:p>xyz</abc:p></html>'''
     self.failUnlessEqual(xml, flatten(parseString(xml)))
示例#53
0
 def test_parseString(self):
     xml = '''<html></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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)))
示例#55
0
 def test_attrs(self):
     xml = '''<p class="foo"></p>'''
     self.assertEqual(xml, flatten(parseString(xml)))
示例#56
0
 def test_xmlns(self):
     xml = '''<html xmlns="http://www.w3.org/1999/xhtml"></html>'''
     self.assertEqual(xml, flatten(parseString(xml)))
示例#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))))