]> git.sesse.net Git - xml-template/commitdiff
Add full range of Python regression tests.
authorsgunderson@bigfoot.com <>
Wed, 6 Sep 2006 14:52:21 +0000 (16:52 +0200)
committersgunderson@bigfoot.com <>
Wed, 6 Sep 2006 14:52:21 +0000 (16:52 +0200)
python/attribute.py [new file with mode: 0644]
python/attribute2.py [new file with mode: 0644]
python/clone.py [new file with mode: 0644]
python/include.py [new file with mode: 0644]

diff --git a/python/attribute.py b/python/attribute.py
new file mode 100644 (file)
index 0000000..0127e80
--- /dev/null
@@ -0,0 +1,13 @@
+#! /usr/bin/python
+import xmltemplate
+
+doc = xmltemplate.process_file("../xml/clone.xml", {
+       'color': 'blue',
+       '#things': (
+               { "li": "Raindrops on roses",    "li/class": "even" },
+               { "li": "Whiskers on kittens",   "li/class": "odd" },
+               { "li": "Bright copper kettles", "li/class": "even" },
+               { "li": "Warm, woolen mittens",  "li/class": "odd" }
+       )
+})
+print doc.toxml()
diff --git a/python/attribute2.py b/python/attribute2.py
new file mode 100644 (file)
index 0000000..d7caca6
--- /dev/null
@@ -0,0 +1,13 @@
+#! /usr/bin/python
+import xmltemplate
+
+doc = xmltemplate.process_file("../xml/clone.xml", {
+       "color": "blue",
+       "#things": xmltemplate.alternate("li/class", (
+               { "li": "Raindrops on roses" },
+               { "li": "Whiskers on kittens" },
+               { "li": "Bright copper kettles" },
+               { "li": "Warm, woolen mittens"},
+       ), "odd", "even")
+});
+print doc.toxml()
diff --git a/python/clone.py b/python/clone.py
new file mode 100644 (file)
index 0000000..65e9519
--- /dev/null
@@ -0,0 +1,13 @@
+#! /usr/bin/python
+import xmltemplate
+
+doc = xmltemplate.process_file("../xml/clone.xml", {
+       'color': 'blue',
+       '#things': (
+               { 'li': 'Raindrops on roses' },
+               { 'li': 'Whiskers on kittens' },
+               { 'li': 'Bright copper kettles' },
+               { 'li': 'Warm, woolen mittens' }
+       )
+})
+print doc.toxml()
diff --git a/python/include.py b/python/include.py
new file mode 100644 (file)
index 0000000..0c87fba
--- /dev/null
@@ -0,0 +1,12 @@
+#! /usr/bin/python
+import xmltemplate
+
+doc = xmltemplate.process_file("../xml/included.xml", {
+       "color": "red"
+}, False)
+master = xmltemplate.process_file("../xml/master.xml", {
+       "title": "Main HTML title",
+       "h1": "Nice heading here",
+       "contents": doc
+});
+print master.toxml()