File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libxml2 / python / tests / attribs.py
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 19:53:34 2014 UTC (10 years, 3 months ago) by misho
Branches: libxml2, MAIN
CVS tags: v2_9_1p0, v2_9_1, HEAD
libxml2 2.9.1

    1: #!/usr/bin/python -u
    2: import sys
    3: import libxml2
    4: 
    5: # Memory debug specific
    6: libxml2.debugMemory(1)
    7: 
    8: #
    9: # Testing XML document serialization
   10: #
   11: doc = libxml2.parseDoc(
   12: """<?xml version="1.0" encoding="iso-8859-1"?>
   13: <!DOCTYPE test [
   14: <!ELEMENT test (#PCDATA) >
   15: <!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
   16: <!ATTLIST test abc:attr CDATA #FIXED "def" >
   17: ]>
   18: <test />
   19: """)
   20: elem = doc.getRootElement()
   21: attr = elem.hasNsProp('attr', 'http://abc.org')
   22: if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
   23:     print("Failed to find defaulted attribute abc:attr")
   24:     sys.exit(1)
   25: 
   26: doc.freeDoc()
   27: 
   28: # Memory debug specific
   29: libxml2.cleanupParser()
   30: if libxml2.debugMemory(1) == 0:
   31:     print("OK")
   32: else:
   33:     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
   34:     libxml2.dumpMemory()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>