VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.4/python/tests/relaxng.py@ 66550

最後變更 在這個檔案從66550是 65950,由 vboxsync 提交於 8 年 前

libxml 2.9.4: fix export

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
檔案大小: 1.2 KB
 
1#!/usr/bin/python -u
2import libxml2
3import sys
4
5# Memory debug specific
6libxml2.debugMemory(1)
7
8schema="""<?xml version="1.0"?>
9<element name="foo"
10 xmlns="http://relaxng.org/ns/structure/1.0"
11 xmlns:a="http://relaxng.org/ns/annotation/1.0"
12 xmlns:ex1="http://www.example.com/n1"
13 xmlns:ex2="http://www.example.com/n2">
14 <a:documentation>A foo element.</a:documentation>
15 <element name="ex1:bar1">
16 <empty/>
17 </element>
18 <element name="ex2:bar2">
19 <empty/>
20 </element>
21</element>
22"""
23instance="""<?xml version="1.0"?>
24<foo><pre1:bar1 xmlns:pre1="http://www.example.com/n1"/><pre2:bar2 xmlns:pre2="http://www.example.com/n2"/></foo>"""
25
26rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
27rngs = rngp.relaxNGParse()
28ctxt = rngs.relaxNGNewValidCtxt()
29doc = libxml2.parseDoc(instance)
30ret = doc.relaxNGValidateDoc(ctxt)
31if ret != 0:
32 print("error doing RelaxNG validation")
33 sys.exit(1)
34
35doc.freeDoc()
36del rngp
37del rngs
38del ctxt
39libxml2.relaxNGCleanupTypes()
40
41# Memory debug specific
42libxml2.cleanupParser()
43if libxml2.debugMemory(1) == 0:
44 print("OK")
45else:
46 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
47 libxml2.dumpMemory()
48
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette