本文整理汇总了Python中nevow.flat.flatsax.parseString函数的典型用法代码示例。如果您正苦于以下问题:Python parseString函数的具体用法?Python parseString怎么用?Python parseString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_switchns
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: test_otherns
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: test_invisiblens
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)))
示例4: load
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
示例5: test_commentWhereSpacingMatters
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)))
示例6: test_parseString
def test_parseString(self):
xml = '''<html></html>'''
self.assertEqual(xml, flatten(parseString(xml)))
示例7: test_cdata
def test_cdata(self):
xml = '<script type="text/javascript"><![CDATA[<abc]]></script>'
self.assertEqual(xml, flatten(parseString(xml)))
示例8: test_comment
def test_comment(self):
xml = '<!-- comment &£ --><html></html>'
self.assertEqual(xml, flatten(parseString(xml)))
示例9: test_doctype
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))))
示例10: test_entities
def test_entities(self):
xml = """<p>&</p>"""
self.assertEqual(xml, flatten(parseString(xml)))
示例11: test_unicodeComment
def test_unicodeComment(self):
xml = '<!-- \xc2\xa3 --><html></html>'
self.assertEqual(xml, flatten(parseString(xml)))
示例12: test_badNamespace
def test_badNamespace(self):
xml = '<html foo:bar="wee"><abc:p>xyz</abc:p></html>'
self.assertEqual(xml, flatten(parseString(xml)))
示例13: test_xmlAttr
def test_xmlAttr(self):
xml = '<html xml:lang="en"></html>'
self.assertEqual(xml, flatten(parseString(xml)))
示例14: test_processingInstruction
def test_processingInstruction(self):
xml = '''<html></html>'''
self.assertEqual(xml, flatten(parseString(xml)))
示例15: test_attrs
def test_attrs(self):
xml = '''<p class="foo"></p>'''
self.assertEqual(xml, flatten(parseString(xml)))