mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-02-04 09:16:22 +00: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:
parent
6581e1b881
commit
591b4be0fe
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
|
||||
* relaxng.c: found the validation problem I had with interleave
|
||||
|
@ -273,6 +273,9 @@ py_types = {
|
||||
'xmlRegexpPtr': ('O', "xmlReg", "xmlRegexpPtr", "xmlRegexpPtr"),
|
||||
'xmlTextReaderLocatorPtr': ('O', "xmlTextReaderLocator", "xmlTextReaderLocatorPtr", "xmlTextReaderLocatorPtr"),
|
||||
'xmlTextReaderPtr': ('O', "xmlTextReader", "xmlTextReaderPtr", "xmlTextReaderPtr"),
|
||||
'xmlRelaxNGPtr': ('O', "relaxNgSchema", "xmlRelaxNGPtr", "xmlRelaxNGPtr"),
|
||||
'xmlRelaxNGParserCtxtPtr': ('O', "relaxNgParserCtxt", "xmlRelaxNGParserCtxtPtr", "xmlRelaxNGParserCtxtPtr"),
|
||||
'xmlRelaxNGValidCtxtPtr': ('O', "relaxNgValidCtxt", "xmlRelaxNGValidCtxtPtr", "xmlRelaxNGValidCtxtPtr"),
|
||||
}
|
||||
|
||||
py_return_types = {
|
||||
@ -615,6 +618,9 @@ classes_type = {
|
||||
"xmlRegexpPtr": ("._o", "xmlReg(_obj=%s)", "xmlReg"),
|
||||
"xmlTextReaderLocatorPtr": ("._o", "xmlTextReaderLocator(_obj=%s)", "xmlTextReaderLocator"),
|
||||
"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 = {
|
||||
@ -645,6 +651,9 @@ classes_destructors = {
|
||||
"inputBuffer": "xmlFreeParserInputBuffer",
|
||||
"xmlReg": "xmlRegFreeRegexp",
|
||||
"xmlTextReader": "xmlFreeTextReader",
|
||||
"relaxNgSchema": "xmlRelaxNGFree",
|
||||
"relaxNgParserCtxt": "xmlRelaxNGFreeParserCtxt",
|
||||
"relaxNgValidCtxt": "xmlRelaxNGFreeValidCtxt",
|
||||
}
|
||||
|
||||
functions_noexcept = {
|
||||
@ -655,6 +664,7 @@ functions_noexcept = {
|
||||
|
||||
reference_keepers = {
|
||||
"xmlTextReader": [('inputBuffer', 'input')],
|
||||
"relaxNgValidCtxt": [('relaxNgSchema', 'schema')],
|
||||
}
|
||||
|
||||
function_classes = {}
|
||||
|
@ -128,6 +128,8 @@ setEntityLoader()
|
||||
|
||||
# functions from module relaxng
|
||||
relaxNGCleanupTypes()
|
||||
relaxNGNewMemParserCtxt()
|
||||
relaxNGNewParserCtxt()
|
||||
|
||||
# functions from module tree
|
||||
compressMode()
|
||||
@ -464,6 +466,9 @@ Class xmlDoc(xmlNode)
|
||||
encodeSpecialChars()
|
||||
parameterEntity()
|
||||
|
||||
# functions from module relaxng
|
||||
relaxNGValidateDoc()
|
||||
|
||||
# functions from module tree
|
||||
copyDoc()
|
||||
createIntSubset()
|
||||
@ -628,6 +633,16 @@ Class xmlEntity(xmlNode)
|
||||
|
||||
# functions from module parserInternals
|
||||
handleEntity()
|
||||
Class relaxNgSchema()
|
||||
|
||||
# functions from module relaxng
|
||||
relaxNGDump()
|
||||
relaxNGFree()
|
||||
relaxNGNewValidCtxt()
|
||||
Class relaxNgValidCtxt()
|
||||
|
||||
# functions from module relaxng
|
||||
relaxNGFreeValidCtxt()
|
||||
Class xpathParserContext()
|
||||
# accessors
|
||||
context()
|
||||
@ -797,6 +812,11 @@ Class inputBuffer(ioReadWrapper)
|
||||
|
||||
# functions from module xmlreader
|
||||
newTextReader()
|
||||
Class relaxNgParserCtxt()
|
||||
|
||||
# functions from module relaxng
|
||||
relaxNGFreeParserCtxt()
|
||||
relaxNGParse()
|
||||
|
||||
|
||||
Class outputBuffer(ioWriteWrapper)
|
||||
|
@ -132,6 +132,32 @@ typedef struct {
|
||||
#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
|
||||
(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_longWrap(long val);
|
||||
@ -163,3 +189,8 @@ PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
|
||||
PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
|
||||
|
||||
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 \
|
||||
reader3.py \
|
||||
ctxterror.py\
|
||||
readererr.py
|
||||
readererr.py\
|
||||
relaxng.py
|
||||
|
||||
XMLS= \
|
||||
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);
|
||||
}
|
||||
|
||||
#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
|
||||
*
|
||||
* [14] Expr ::= OrExpr
|
||||
@ -10610,7 +10610,7 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
xmlXPathCompExprPtr
|
||||
|
Loading…
x
Reference in New Issue
Block a user