예제 #1
0
 def _get_complex_structure(self):        
     tree = Tree()
     tree.instruct('xml')
     #tree.cdata(r"<b>I am some text.</b>")
     tree.declare('DOCTYPE', __.author, __.SYSTEM,  'SomeDTD.dtd')
     with tree.node('author') as author:
         author.node('name', 'Terry Pratchett')
         author.node('genre', 'Fantasy/Comedy')
         author.comment("Only 2 books listed")
         with author.node('novels', count=2) as novels:
             novels.node('novel', 'Small Gods', year=1992)
             novels.node('novel', 'The Fifth Elephant', year=1999)
     return tree
예제 #2
0
 def _get_complex_structure(self):
     tree = Tree()
     tree.instruct('xml')
     #tree.cdata(r"<b>I am some text.</b>")
     tree.declare('DOCTYPE', __.author, __.SYSTEM, 'SomeDTD.dtd')
     with tree.node('author') as author:
         author.node('name', 'Terry Pratchett')
         author.node('genre', 'Fantasy/Comedy')
         author.comment("Only 2 books listed")
         with author.node('novels', count=2) as novels:
             novels.node('novel', 'Small Gods', year=1992)
             novels.node('novel', 'The Fifth Elephant', year=1999)
     return tree
예제 #3
0
 def test_render_declaration_no_values(self):
     tree = Tree()
     tree.declare('ELEMENT')
     self.assertIn(tree(), r'<!ELEMENT>')
예제 #4
0
 def test_render_declaration(self):
     tree = Tree()
     tree.declare('ELEMENT', __.Value, 'A value here.')
     self.assertIn(tree(), r'<!ELEMENT Value "A value here.">')
예제 #5
0
 def test_render_declaration_no_values(self):
     tree = Tree()
     tree.declare('ELEMENT')
     self.assertIn(tree(), r'<!ELEMENT>')
예제 #6
0
 def test_render_declaration(self):
     tree = Tree()
     tree.declare('ELEMENT', __.Value, 'A value here.')
     self.assertIn(tree(), r'<!ELEMENT Value "A value here.">')