mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
fixed doc comment problems adding RelaxNG wrappers added a specific test
* xpath.c: fixed doc comment problems * python/generator.py python/libxml_wrap.h python/types.c: adding RelaxNG wrappers * python/tests/Makefile.am python/tests/relaxng.py: added a specific test of those early Python RelaxNG bindings Daniel
This commit is contained in:
10
ChangeLog
10
ChangeLog
@ -1,4 +1,12 @@
|
|||||||
Sun Feb 9 15:18:43 CET 2003 Igor Zlatkovic <igor@zlatkovic.com>
|
Mon Feb 10 00:30:01 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xpath.c: fixed doc comment problems
|
||||||
|
* python/generator.py python/libxml_wrap.h python/types.c: adding
|
||||||
|
RelaxNG wrappers
|
||||||
|
* python/tests/Makefile.am python/tests/relaxng.py: added a specific
|
||||||
|
test of those early Python RelaxNG bindings
|
||||||
|
|
||||||
|
Sun Feb 9 15:18:43 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* libxml.spec.in: fixes a libtool problem on AMD 64bits builds
|
* libxml.spec.in: fixes a libtool problem on AMD 64bits builds
|
||||||
* relaxng.c: found the validation problem I had with interleave
|
* relaxng.c: found the validation problem I had with interleave
|
||||||
|
@ -273,6 +273,9 @@ py_types = {
|
|||||||
'xmlRegexpPtr': ('O', "xmlReg", "xmlRegexpPtr", "xmlRegexpPtr"),
|
'xmlRegexpPtr': ('O', "xmlReg", "xmlRegexpPtr", "xmlRegexpPtr"),
|
||||||
'xmlTextReaderLocatorPtr': ('O', "xmlTextReaderLocator", "xmlTextReaderLocatorPtr", "xmlTextReaderLocatorPtr"),
|
'xmlTextReaderLocatorPtr': ('O', "xmlTextReaderLocator", "xmlTextReaderLocatorPtr", "xmlTextReaderLocatorPtr"),
|
||||||
'xmlTextReaderPtr': ('O', "xmlTextReader", "xmlTextReaderPtr", "xmlTextReaderPtr"),
|
'xmlTextReaderPtr': ('O', "xmlTextReader", "xmlTextReaderPtr", "xmlTextReaderPtr"),
|
||||||
|
'xmlRelaxNGPtr': ('O', "relaxNgSchema", "xmlRelaxNGPtr", "xmlRelaxNGPtr"),
|
||||||
|
'xmlRelaxNGParserCtxtPtr': ('O', "relaxNgParserCtxt", "xmlRelaxNGParserCtxtPtr", "xmlRelaxNGParserCtxtPtr"),
|
||||||
|
'xmlRelaxNGValidCtxtPtr': ('O', "relaxNgValidCtxt", "xmlRelaxNGValidCtxtPtr", "xmlRelaxNGValidCtxtPtr"),
|
||||||
}
|
}
|
||||||
|
|
||||||
py_return_types = {
|
py_return_types = {
|
||||||
@ -615,6 +618,9 @@ classes_type = {
|
|||||||
"xmlRegexpPtr": ("._o", "xmlReg(_obj=%s)", "xmlReg"),
|
"xmlRegexpPtr": ("._o", "xmlReg(_obj=%s)", "xmlReg"),
|
||||||
"xmlTextReaderLocatorPtr": ("._o", "xmlTextReaderLocator(_obj=%s)", "xmlTextReaderLocator"),
|
"xmlTextReaderLocatorPtr": ("._o", "xmlTextReaderLocator(_obj=%s)", "xmlTextReaderLocator"),
|
||||||
"xmlTextReaderPtr": ("._o", "xmlTextReader(_obj=%s)", "xmlTextReader"),
|
"xmlTextReaderPtr": ("._o", "xmlTextReader(_obj=%s)", "xmlTextReader"),
|
||||||
|
'xmlRelaxNGPtr': ('._o', "relaxNgSchema(_obj=%s)", "relaxNgSchema"),
|
||||||
|
'xmlRelaxNGParserCtxtPtr': ('._o', "relaxNgParserCtxt(_obj=%s)", "relaxNgParserCtxt"),
|
||||||
|
'xmlRelaxNGValidCtxtPtr': ('._o', "relaxNgValidCtxt(_obj=%s)", "relaxNgValidCtxt"),
|
||||||
}
|
}
|
||||||
|
|
||||||
converter_type = {
|
converter_type = {
|
||||||
@ -645,6 +651,9 @@ classes_destructors = {
|
|||||||
"inputBuffer": "xmlFreeParserInputBuffer",
|
"inputBuffer": "xmlFreeParserInputBuffer",
|
||||||
"xmlReg": "xmlRegFreeRegexp",
|
"xmlReg": "xmlRegFreeRegexp",
|
||||||
"xmlTextReader": "xmlFreeTextReader",
|
"xmlTextReader": "xmlFreeTextReader",
|
||||||
|
"relaxNgSchema": "xmlRelaxNGFree",
|
||||||
|
"relaxNgParserCtxt": "xmlRelaxNGFreeParserCtxt",
|
||||||
|
"relaxNgValidCtxt": "xmlRelaxNGFreeValidCtxt",
|
||||||
}
|
}
|
||||||
|
|
||||||
functions_noexcept = {
|
functions_noexcept = {
|
||||||
@ -655,6 +664,7 @@ functions_noexcept = {
|
|||||||
|
|
||||||
reference_keepers = {
|
reference_keepers = {
|
||||||
"xmlTextReader": [('inputBuffer', 'input')],
|
"xmlTextReader": [('inputBuffer', 'input')],
|
||||||
|
"relaxNgValidCtxt": [('relaxNgSchema', 'schema')],
|
||||||
}
|
}
|
||||||
|
|
||||||
function_classes = {}
|
function_classes = {}
|
||||||
|
@ -128,6 +128,8 @@ setEntityLoader()
|
|||||||
|
|
||||||
# functions from module relaxng
|
# functions from module relaxng
|
||||||
relaxNGCleanupTypes()
|
relaxNGCleanupTypes()
|
||||||
|
relaxNGNewMemParserCtxt()
|
||||||
|
relaxNGNewParserCtxt()
|
||||||
|
|
||||||
# functions from module tree
|
# functions from module tree
|
||||||
compressMode()
|
compressMode()
|
||||||
@ -464,6 +466,9 @@ Class xmlDoc(xmlNode)
|
|||||||
encodeSpecialChars()
|
encodeSpecialChars()
|
||||||
parameterEntity()
|
parameterEntity()
|
||||||
|
|
||||||
|
# functions from module relaxng
|
||||||
|
relaxNGValidateDoc()
|
||||||
|
|
||||||
# functions from module tree
|
# functions from module tree
|
||||||
copyDoc()
|
copyDoc()
|
||||||
createIntSubset()
|
createIntSubset()
|
||||||
@ -628,6 +633,16 @@ Class xmlEntity(xmlNode)
|
|||||||
|
|
||||||
# functions from module parserInternals
|
# functions from module parserInternals
|
||||||
handleEntity()
|
handleEntity()
|
||||||
|
Class relaxNgSchema()
|
||||||
|
|
||||||
|
# functions from module relaxng
|
||||||
|
relaxNGDump()
|
||||||
|
relaxNGFree()
|
||||||
|
relaxNGNewValidCtxt()
|
||||||
|
Class relaxNgValidCtxt()
|
||||||
|
|
||||||
|
# functions from module relaxng
|
||||||
|
relaxNGFreeValidCtxt()
|
||||||
Class xpathParserContext()
|
Class xpathParserContext()
|
||||||
# accessors
|
# accessors
|
||||||
context()
|
context()
|
||||||
@ -797,6 +812,11 @@ Class inputBuffer(ioReadWrapper)
|
|||||||
|
|
||||||
# functions from module xmlreader
|
# functions from module xmlreader
|
||||||
newTextReader()
|
newTextReader()
|
||||||
|
Class relaxNgParserCtxt()
|
||||||
|
|
||||||
|
# functions from module relaxng
|
||||||
|
relaxNGFreeParserCtxt()
|
||||||
|
relaxNGParse()
|
||||||
|
|
||||||
|
|
||||||
Class outputBuffer(ioWriteWrapper)
|
Class outputBuffer(ioWriteWrapper)
|
||||||
|
@ -132,6 +132,32 @@ typedef struct {
|
|||||||
#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
|
#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
|
||||||
(PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
|
(PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
|
||||||
|
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
xmlRelaxNGPtr obj;
|
||||||
|
} PyrelaxNgSchema_Object;
|
||||||
|
|
||||||
|
#define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
|
||||||
|
(((PyrelaxNgSchema_Object *)(v))->obj))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
xmlRelaxNGParserCtxtPtr obj;
|
||||||
|
} PyrelaxNgParserCtxt_Object;
|
||||||
|
|
||||||
|
#define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
|
||||||
|
(((PyrelaxNgParserCtxt_Object *)(v))->obj))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PyObject_HEAD
|
||||||
|
xmlRelaxNGValidCtxtPtr obj;
|
||||||
|
} PyrelaxNgValidCtxt_Object;
|
||||||
|
|
||||||
|
#define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
|
||||||
|
(((PyrelaxNgValidCtxt_Object *)(v))->obj))
|
||||||
|
|
||||||
|
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||||
|
|
||||||
PyObject * libxml_intWrap(int val);
|
PyObject * libxml_intWrap(int val);
|
||||||
PyObject * libxml_longWrap(long val);
|
PyObject * libxml_longWrap(long val);
|
||||||
@ -163,3 +189,8 @@ PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
|
|||||||
PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
|
PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
|
||||||
|
|
||||||
xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
|
xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
|
||||||
|
PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
|
||||||
|
PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
|
||||||
|
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||||
|
@ -24,7 +24,8 @@ PYTESTS= \
|
|||||||
reader2.py \
|
reader2.py \
|
||||||
reader3.py \
|
reader3.py \
|
||||||
ctxterror.py\
|
ctxterror.py\
|
||||||
readererr.py
|
readererr.py\
|
||||||
|
relaxng.py
|
||||||
|
|
||||||
XMLS= \
|
XMLS= \
|
||||||
tst.xml \
|
tst.xml \
|
||||||
|
48
python/tests/relaxng.py
Executable file
48
python/tests/relaxng.py
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/python -u
|
||||||
|
import libxml2
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Memory debug specific
|
||||||
|
libxml2.debugMemory(1)
|
||||||
|
|
||||||
|
schema="""<?xml version="1.0"?>
|
||||||
|
<element name="foo"
|
||||||
|
xmlns="http://relaxng.org/ns/structure/1.0"
|
||||||
|
xmlns:a="http://relaxng.org/ns/annotation/1.0"
|
||||||
|
xmlns:ex1="http://www.example.com/n1"
|
||||||
|
xmlns:ex2="http://www.example.com/n2">
|
||||||
|
<a:documentation>A foo element.</a:documentation>
|
||||||
|
<element name="ex1:bar1">
|
||||||
|
<empty/>
|
||||||
|
</element>
|
||||||
|
<element name="ex2:bar2">
|
||||||
|
<empty/>
|
||||||
|
</element>
|
||||||
|
</element>
|
||||||
|
"""
|
||||||
|
instance="""<?xml version="1.0"?>
|
||||||
|
<foo><pre1:bar1 xmlns:pre1="http://www.example.com/n1"/><pre2:bar2 xmlns:pre2="http://www.example.com/n2"/></foo>"""
|
||||||
|
|
||||||
|
rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
|
||||||
|
rngs = rngp.relaxNGParse()
|
||||||
|
ctxt = rngs.relaxNGNewValidCtxt()
|
||||||
|
doc = libxml2.parseDoc(instance)
|
||||||
|
ret = doc.relaxNGValidateDoc(ctxt)
|
||||||
|
if ret != 0:
|
||||||
|
print "error doing RelaxNG validation"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
doc.freeDoc()
|
||||||
|
del rngp
|
||||||
|
del rngs
|
||||||
|
del ctxt
|
||||||
|
libxml2.relaxNGCleanupTypes()
|
||||||
|
|
||||||
|
# Memory debug specific
|
||||||
|
libxml2.cleanupParser()
|
||||||
|
if libxml2.debugMemory(1) == 0:
|
||||||
|
print "OK"
|
||||||
|
else:
|
||||||
|
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
|
||||||
|
libxml2.dumpMemory()
|
||||||
|
|
@ -587,3 +587,57 @@ libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
PyObject *
|
||||||
|
libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt)
|
||||||
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("libxml_xmlRelaxNGPtrWrap: ctxt = %p\n", ctxt);
|
||||||
|
#endif
|
||||||
|
if (ctxt == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return (Py_None);
|
||||||
|
}
|
||||||
|
ret =
|
||||||
|
PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
||||||
|
(char *) "xmlRelaxNGPtr", NULL);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt)
|
||||||
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("libxml_xmlRelaxNGParserCtxtPtrWrap: ctxt = %p\n", ctxt);
|
||||||
|
#endif
|
||||||
|
if (ctxt == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return (Py_None);
|
||||||
|
}
|
||||||
|
ret =
|
||||||
|
PyCObject_FromVoidPtrAndDesc((void *) ctxt,
|
||||||
|
(char *) "xmlRelaxNGParserCtxtPtr", NULL);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
PyObject *
|
||||||
|
libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid)
|
||||||
|
{
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("libxml_xmlRelaxNGValidCtxtPtrWrap: valid = %p\n", valid);
|
||||||
|
#endif
|
||||||
|
if (valid == NULL) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
return (Py_None);
|
||||||
|
}
|
||||||
|
ret =
|
||||||
|
PyCObject_FromVoidPtrAndDesc((void *) valid,
|
||||||
|
(char *) "xmlRelaxNGValidCtxtPtr", NULL);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||||
|
4
xpath.c
4
xpath.c
@ -8176,7 +8176,7 @@ xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlXPathCompExpr:
|
* xmlXPathCompileExpr:
|
||||||
* @ctxt: the XPath Parser context
|
* @ctxt: the XPath Parser context
|
||||||
*
|
*
|
||||||
* [14] Expr ::= OrExpr
|
* [14] Expr ::= OrExpr
|
||||||
@ -10610,7 +10610,7 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
|||||||
*
|
*
|
||||||
* Compile an XPath expression
|
* Compile an XPath expression
|
||||||
*
|
*
|
||||||
* Returns the xmlXPathObjectPtr resulting from the evaluation or NULL.
|
* Returns the xmlXPathCompExprPtr resulting from the compilation or NULL.
|
||||||
* the caller has to free the object.
|
* the caller has to free the object.
|
||||||
*/
|
*/
|
||||||
xmlXPathCompExprPtr
|
xmlXPathCompExprPtr
|
||||||
|
Reference in New Issue
Block a user