VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/relaxng.py@ 105420

Last change on this file since 105420 was 105420, checked in by vboxsync, 7 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/env python3
2import setup_test
3import libxml2
4import sys
5
6# Memory debug specific
7libxml2.debugMemory(1)
8
9schema="""<?xml version="1.0"?>
10<element name="foo"
11 xmlns="http://relaxng.org/ns/structure/1.0"
12 xmlns:a="http://relaxng.org/ns/annotation/1.0"
13 xmlns:ex1="http://www.example.com/n1"
14 xmlns:ex2="http://www.example.com/n2">
15 <a:documentation>A foo element.</a:documentation>
16 <element name="ex1:bar1">
17 <empty/>
18 </element>
19 <element name="ex2:bar2">
20 <empty/>
21 </element>
22</element>
23"""
24instance="""<?xml version="1.0"?>
25<foo><pre1:bar1 xmlns:pre1="http://www.example.com/n1"/><pre2:bar2 xmlns:pre2="http://www.example.com/n2"/></foo>"""
26
27rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
28rngs = rngp.relaxNGParse()
29ctxt = rngs.relaxNGNewValidCtxt()
30doc = libxml2.parseDoc(instance)
31ret = doc.relaxNGValidateDoc(ctxt)
32if ret != 0:
33 print("error doing RelaxNG validation")
34 sys.exit(1)
35
36doc.freeDoc()
37del rngp
38del rngs
39del ctxt
40libxml2.relaxNGCleanupTypes()
41
42# Memory debug specific
43libxml2.cleanupParser()
44if libxml2.debugMemory(1) == 0:
45 print("OK")
46else:
47 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
48
Note: See TracBrowser for help on using the repository browser.

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