예제 #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_instruction(self):
     tree = Tree()
     tree.instruct('process', do="Good")
     self.assertIn(tree(), '<?process do="Good"?>')
예제 #4
0
 def test_render_instruction_xml(self):
     tree = Tree()
     tree.instruct('xml')
     self.assertIn(tree(), '<?xml version="1.0" encoding="UTF-8"?>')
예제 #5
0
 def _get_test_tree(self):
     tree = Tree()
     tree.instruct()
     tree.node('name', 'Bob')
     tree.node('age', 12)
     return tree
예제 #6
0
 def _get_test_tree(self):
     tree = Tree()
     tree.instruct()
     tree.node('name', 'Bob')
     tree.node('age', 12)
     return tree
예제 #7
0
 def test_render_instruction(self):
     tree = Tree()
     tree.instruct('process', do="Good")
     self.assertIn(tree(), '<?process do="Good"?>')
예제 #8
0
 def test_render_instruction_xml(self):
     tree = Tree()
     tree.instruct('xml')
     self.assertIn(tree(), '<?xml version="1.0" encoding="UTF-8"?>')