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
diff --git a/python/generator.py b/python/generator.py
index 95212d6..fc80417 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -273,6 +273,9 @@
     '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 @@
     "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 @@
     "inputBuffer": "xmlFreeParserInputBuffer",
     "xmlReg": "xmlRegFreeRegexp",
     "xmlTextReader": "xmlFreeTextReader",
+    "relaxNgSchema": "xmlRelaxNGFree",
+    "relaxNgParserCtxt": "xmlRelaxNGFreeParserCtxt",
+    "relaxNgValidCtxt": "xmlRelaxNGFreeValidCtxt",
 }
 
 functions_noexcept = {
@@ -655,6 +664,7 @@
 
 reference_keepers = {
     "xmlTextReader": [('inputBuffer', 'input')],
+    "relaxNgValidCtxt": [('relaxNgSchema', 'schema')],
 }
 
 function_classes = {}
diff --git a/python/libxml2class.txt b/python/libxml2class.txt
index 72607a4..8f1e863 100644
--- a/python/libxml2class.txt
+++ b/python/libxml2class.txt
@@ -128,6 +128,8 @@
 
 # functions from module relaxng
 relaxNGCleanupTypes()
+relaxNGNewMemParserCtxt()
+relaxNGNewParserCtxt()
 
 # functions from module tree
 compressMode()
@@ -464,6 +466,9 @@
     encodeSpecialChars()
     parameterEntity()
 
+    # functions from module relaxng
+    relaxNGValidateDoc()
+
     # functions from module tree
     copyDoc()
     createIntSubset()
@@ -628,6 +633,16 @@
 
     # 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 @@
 
     # functions from module xmlreader
     newTextReader()
+Class relaxNgParserCtxt()
+
+    # functions from module relaxng
+    relaxNGFreeParserCtxt()
+    relaxNGParse()
 
 
 Class outputBuffer(ioWriteWrapper)
diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h
index d1c5dc9..260e6b4 100644
--- a/python/libxml_wrap.h
+++ b/python/libxml_wrap.h
@@ -132,6 +132,32 @@
 #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_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 */
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 55a9acb..761046a 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -24,7 +24,8 @@
     reader2.py	\
     reader3.py	\
     ctxterror.py\
-    readererr.py
+    readererr.py\
+    relaxng.py
 
 XMLS=		\
     tst.xml	\
diff --git a/python/tests/relaxng.py b/python/tests/relaxng.py
new file mode 100755
index 0000000..2c83635
--- /dev/null
+++ b/python/tests/relaxng.py
@@ -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()
+
diff --git a/python/types.c b/python/types.c
index 37c9e60..a971791 100644
--- a/python/types.c
+++ b/python/types.c
@@ -587,3 +587,57 @@
     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 */