File: python

package info (click to toggle)
libxml2 2.9.1%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 36,676 kB
  • sloc: ansic: 193,810; xml: 22,908; python: 21,399; sh: 11,299; makefile: 1,960; php: 364; perl: 67
file content (22 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

python <<EOF
import libxml2
import sys

doc = libxml2.parseDoc(
"""<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
<!ATTLIST test abc:attr CDATA #FIXED "def" >
]>
<test />
""")
elem = doc.getRootElement()
attr = elem.hasNsProp('attr', 'http://abc.org')
if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
    print("Failed to find defaulted attribute abc:attr")
    sys.exit(1)
doc.freeDoc()
EOF