File: test_domu.py

package info (click to toggle)
qm 1.1.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,628 kB
  • ctags: 10,249
  • sloc: python: 41,482; ansic: 20,611; xml: 12,837; sh: 485; makefile: 226
file content (43 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Test the dom.utils module

from xml.dom import core, utils

# Build a test DOM tree
from xml.dom.builder import Builder
b = Builder()
b.startElement("top")
b.text("     ")
b.text("\n\n\n\n\n")
b.text("real text")
b.text("     ")
b.text("more text")
b.startElement('subthing')
b.text("  text     with        spaces ")
b.endElement('subthing')
b.text("\n\n\n\n\n")
b.endElement('top')

t = b.document
t2 = t.cloneNode(1)

print 'strip_whitespace test'
print t.toxml()
utils.strip_whitespace(t, utils.WS_LEFT)
print '=========='
print t.toxml()

print '======================'

print 'collapse_whitespace test'
print t2.toxml()
utils.collapse_whitespace(t2, utils.WS_INTERNAL)

print '=========='
print t2.toxml()
print

t2.documentElement.normalize()
utils.collapse_whitespace(t2, utils.WS_INTERNAL)
print t2.toxml()