applied patch from Marcus Boerger to route relaxng and schemas error

* error.c relaxng.c xmlreader.c xmlschemas.c include/libxml/relaxng.h
  include/libxml/xmlschemas.h: applied patch from Marcus Boerger
  to route relaxng and schemas error messages when using the reader
  through the structured interface if activated.
* elfgcchack.h doc/* testapi.c: rebuilt since this add  new APIs
  to test.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 9752ebd..9a65bb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Jul 14 01:03:03 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+	* error.c relaxng.c xmlreader.c xmlschemas.c include/libxml/relaxng.h
+	  include/libxml/xmlschemas.h: applied patch from Marcus Boerger
+	  to route relaxng and schemas error messages when using the reader
+	  through the structured interface if activated.
+	* elfgcchack.h doc/* testapi.c: rebuilt since this add  new APIs
+	  to test.
+
 Wed Jul 13 18:35:47 CEST 2005 Daniel Veillard <daniel@veillard.com>
 
 	* HTMLparser.c: applied UTF-8 script parsing bug #310229 fix from
diff --git a/doc/APIchunk15.html b/doc/APIchunk15.html
index 02fc03a..c60930d 100644
--- a/doc/APIchunk15.html
+++ b/doc/APIchunk15.html
@@ -399,9 +399,11 @@
 <a href="html/libxml-relaxng.html#xmlRelaxNGGetValidErrors">xmlRelaxNGGetValidErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaGetValidErrors">xmlSchemaGetValidErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
 <a href="html/libxml-debugXML.html#xmlShellCmd">xmlShellCmd</a><br />
 <a href="html/libxml-parserInternals.html#xmlSwitchEncoding">xmlSwitchEncoding</a><br />
 <a href="html/libxml-parserInternals.html#xmlSwitchInputEncoding">xmlSwitchInputEncoding</a><br />
diff --git a/doc/APIchunk24.html b/doc/APIchunk24.html
index 2d52d0d..39466f3 100644
--- a/doc/APIchunk24.html
+++ b/doc/APIchunk24.html
@@ -670,7 +670,9 @@
 <a href="html/libxml-xmlschemastypes.html#xmlSchemaNewNOTATIONValue">xmlSchemaNewNOTATIONValue</a><br />
 <a href="html/libxml-xmlschemastypes.html#xmlSchemaNewQNameValue">xmlSchemaNewQNameValue</a><br />
 <a href="html/libxml-xmlschemastypes.html#xmlSchemaNewStringValue">xmlSchemaNewStringValue</a><br />
-</dd><dt>structured</dt><dd><a href="html/libxml-xmlerror.html#xmlSetStructuredErrorFunc">xmlSetStructuredErrorFunc</a><br />
+</dd><dt>structured</dt><dd><a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
+<a href="html/libxml-xmlerror.html#xmlSetStructuredErrorFunc">xmlSetStructuredErrorFunc</a><br />
 </dd><dt>structures</dt><dd><a href="html/libxml-tree.html#xmlFreeDoc">xmlFreeDoc</a><br />
 <a href="html/libxml-tree.html#xmlFreeNs">xmlFreeNs</a><br />
 <a href="html/libxml-tree.html#xmlFreeNsList">xmlFreeNsList</a><br />
diff --git a/doc/APIchunk6.html b/doc/APIchunk6.html
index b2179c0..1433661 100644
--- a/doc/APIchunk6.html
+++ b/doc/APIchunk6.html
@@ -165,6 +165,7 @@
 <a href="html/libxml-relaxng.html#xmlRelaxNGParse">xmlRelaxNGParse</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidateDoc">xmlRelaxNGValidateDoc</a><br />
 </dd><dt>RelaxNG</dt><dd><a href="html/libxml-relaxng.html#xmlRelaxNGCleanupTypes">xmlRelaxNGCleanupTypes</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGDump">xmlRelaxNGDump</a><br />
diff --git a/doc/APIchunk7.html b/doc/APIchunk7.html
index 825348d..b37c70c 100644
--- a/doc/APIchunk7.html
+++ b/doc/APIchunk7.html
@@ -158,36 +158,6 @@
 </dd><dt>Semi</dt><dd><a href="html/libxml-relaxng.html#xmlRelaxParserSetFlag">xmlRelaxParserSetFlag</a><br />
 </dd><dt>Send</dt><dd><a href="html/libxml-nanoftp.html#xmlNanoFTPQuit">xmlNanoFTPQuit</a><br />
 </dd><dt>Serialize</dt><dd><a href="html/libxml-tree.html#xmlAttrSerializeTxtContent">xmlAttrSerializeTxtContent</a><br />
-</dd><dt>Set</dt><dd><a href="html/libxml-HTMLparser.html#htmlHandleOmittedElem">htmlHandleOmittedElem</a><br />
-<a href="html/libxml-xmlerror.html#initGenericErrorDefaultFunc">initGenericErrorDefaultFunc</a><br />
-<a href="html/libxml-SAX.html#setNamespace">setNamespace</a><br />
-<a href="html/libxml-xlink.html#xlinkSetDefaultDetect">xlinkSetDefaultDetect</a><br />
-<a href="html/libxml-xlink.html#xlinkSetDefaultHandler">xlinkSetDefaultHandler</a><br />
-<a href="html/libxml-tree.html#xmlDocSetRootElement">xmlDocSetRootElement</a><br />
-<a href="html/libxml-entities.html#xmlInitializePredefinedEntities">xmlInitializePredefinedEntities</a><br />
-<a href="html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault</a><br />
-<a href="html/libxml-parser.html#xmlLineNumbersDefault">xmlLineNumbersDefault</a><br />
-<a href="html/libxml-tree.html#xmlNodeSetBase">xmlNodeSetBase</a><br />
-<a href="html/libxml-tree.html#xmlNodeSetLang">xmlNodeSetLang</a><br />
-<a href="html/libxml-tree.html#xmlNodeSetName">xmlNodeSetName</a><br />
-<a href="html/libxml-tree.html#xmlNodeSetSpacePreserve">xmlNodeSetSpacePreserve</a><br />
-<a href="html/libxml-parser.html#xmlPedanticParserDefault">xmlPedanticParserDefault</a><br />
-<a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
-<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
-<a href="html/libxml-SAX2.html#xmlSAXDefaultVersion">xmlSAXDefaultVersion</a><br />
-<a href="html/libxml-xmlsave.html#xmlSaveSetAttrEscape">xmlSaveSetAttrEscape</a><br />
-<a href="html/libxml-xmlsave.html#xmlSaveSetEscape">xmlSaveSetEscape</a><br />
-<a href="html/libxml-xmlschemas.html#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a><br />
-<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
-<a href="html/libxml-tree.html#xmlSetBufferAllocationScheme">xmlSetBufferAllocationScheme</a><br />
-<a href="html/libxml-parserInternals.html#xmlSetEntityReferenceFunc">xmlSetEntityReferenceFunc</a><br />
-<a href="html/libxml-tree.html#xmlSetNsProp">xmlSetNsProp</a><br />
-<a href="html/libxml-tree.html#xmlSetProp">xmlSetProp</a><br />
-<a href="html/libxml-parser.html#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a><br />
-<a href="html/libxml-xmlwriter.html#xmlTextWriterSetIndent">xmlTextWriterSetIndent</a><br />
-<a href="html/libxml-xmlwriter.html#xmlTextWriterSetIndentString">xmlTextWriterSetIndentString</a><br />
-<a href="html/libxml-xinclude.html#xmlXIncludeSetFlags">xmlXIncludeSetFlags</a><br />
-<a href="html/libxml-xpointer.html#xmlXPtrEvalRangePredicate">xmlXPtrEvalRangePredicate</a><br />
 </dd><dt>Sets</dt><dd><a href="html/libxml-HTMLtree.html#htmlSetMetaEncoding">htmlSetMetaEncoding</a><br />
 <a href="html/libxml-tree.html#xmlBufferSetAllocationScheme">xmlBufferSetAllocationScheme</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidOptions">xmlSchemaSetValidOptions</a><br />
diff --git a/doc/APIfiles.html b/doc/APIfiles.html
index 94d55f0..97c24b1 100644
--- a/doc/APIfiles.html
+++ b/doc/APIfiles.html
@@ -941,6 +941,7 @@
 <a href="html/libxml-relaxng.html#xmlRelaxNGPtr">xmlRelaxNGPtr</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidCtxt">xmlRelaxNGValidCtxt</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidErr">xmlRelaxNGValidErr</a><br />
@@ -2700,6 +2701,7 @@
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidOptions">xmlSchemaSetValidOptions</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidCtxt">xmlSchemaValidCtxt</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidCtxtGetOptions">xmlSchemaValidCtxtGetOptions</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a><br />
diff --git a/doc/APIfunctions.html b/doc/APIfunctions.html
index ce0d0c5..787a706 100644
--- a/doc/APIfunctions.html
+++ b/doc/APIfunctions.html
@@ -792,6 +792,7 @@
 <a href="html/libxml-xmlregexp.html#xmlRegNewExecCtxt">xmlRegNewExecCtxt</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidityErrorFunc">xmlRelaxNGValidityErrorFunc</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidityWarningFunc">xmlRelaxNGValidityWarningFunc</a><br />
 <a href="html/libxml-SAX2.html#xmlSAX2AttributeDecl">xmlSAX2AttributeDecl</a><br />
@@ -831,6 +832,7 @@
 <a href="html/libxml-xmlsave.html#xmlSaveToIO">xmlSaveToIO</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidateStream">xmlSchemaValidateStream</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidityErrorFunc">xmlSchemaValidityErrorFunc</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidityWarningFunc">xmlSchemaValidityWarningFunc</a><br />
@@ -1759,6 +1761,7 @@
 </p><h2>Type xmlRelaxNGValidCtxtPtr:</h2><p><a href="html/libxml-relaxng.html#xmlRelaxNGFreeValidCtxt">xmlRelaxNGFreeValidCtxt</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGGetValidErrors">xmlRelaxNGGetValidErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidateDoc">xmlRelaxNGValidateDoc</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidateFullElement">xmlRelaxNGValidateFullElement</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidatePopElement">xmlRelaxNGValidatePopElement</a><br />
@@ -1860,6 +1863,7 @@
 <a href="html/libxml-xmlschemas.html#xmlSchemaSAXPlug">xmlSchemaSAXPlug</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidOptions">xmlSchemaSetValidOptions</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidCtxtGetOptions">xmlSchemaValidCtxtGetOptions</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidateDoc">xmlSchemaValidateDoc</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaValidateFile">xmlSchemaValidateFile</a><br />
@@ -1898,7 +1902,9 @@
 <a href="html/libxml-pattern.html#xmlStreamPop">xmlStreamPop</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPush">xmlStreamPush</a><br />
 <a href="html/libxml-pattern.html#xmlStreamPushAttr">xmlStreamPushAttr</a><br />
-</p><h2>Type xmlStructuredErrorFunc:</h2><p><a href="html/libxml-xmlerror.html#xmlSetStructuredErrorFunc">xmlSetStructuredErrorFunc</a><br />
+</p><h2>Type xmlStructuredErrorFunc:</h2><p><a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
+<a href="html/libxml-xmlerror.html#xmlSetStructuredErrorFunc">xmlSetStructuredErrorFunc</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderSetStructuredErrorHandler">xmlTextReaderSetStructuredErrorHandler</a><br />
 <a href="html/libxml-globals.html#xmlThrDefSetStructuredErrorFunc">xmlThrDefSetStructuredErrorFunc</a><br />
 </p><h2>Type xmlTextReaderErrorFunc:</h2><p><a href="html/libxml-xmlreader.html#xmlTextReaderSetErrorHandler">xmlTextReaderSetErrorHandler</a><br />
diff --git a/doc/APIsymbols.html b/doc/APIsymbols.html
index 756863f..e7c1a3e 100644
--- a/doc/APIsymbols.html
+++ b/doc/APIsymbols.html
@@ -2455,6 +2455,7 @@
 <a href="html/libxml-relaxng.html#xmlRelaxNGPtr">xmlRelaxNGPtr</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a><br />
+<a href="html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidCtxt">xmlRelaxNGValidCtxt</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a><br />
 <a href="html/libxml-relaxng.html#xmlRelaxNGValidErr">xmlRelaxNGValidErr</a><br />
@@ -2607,6 +2608,7 @@
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a><br />
 <a href="html/libxml-xmlschemas.html#xmlSchemaSetValidOptions">xmlSchemaSetValidOptions</a><br />
+<a href="html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a><br />
 <a href="html/libxml-schemasInternals.html#xmlSchemaType">xmlSchemaType</a><br />
 <a href="html/libxml-schemasInternals.html#xmlSchemaTypeLink">xmlSchemaTypeLink</a><br />
 <a href="html/libxml-schemasInternals.html#xmlSchemaTypeLinkPtr">xmlSchemaTypeLinkPtr</a><br />
diff --git a/doc/html/libxml-relaxng.html b/doc/html/libxml-relaxng.html
index 942aac3..637f27f 100644
--- a/doc/html/libxml-relaxng.html
+++ b/doc/html/libxml-relaxng.html
@@ -37,6 +37,7 @@
 <pre class="programlisting"><a href="libxml-relaxng.html#xmlRelaxNGPtr">xmlRelaxNGPtr</a>	<a href="#xmlRelaxNGParse">xmlRelaxNGParse</a>		(<a href="libxml-relaxng.html#xmlRelaxNGParserCtxtPtr">xmlRelaxNGParserCtxtPtr</a> ctxt)</pre>
 <pre class="programlisting">void	<a href="#xmlRelaxNGSetParserErrors">xmlRelaxNGSetParserErrors</a>	(<a href="libxml-relaxng.html#xmlRelaxNGParserCtxtPtr">xmlRelaxNGParserCtxtPtr</a> ctxt, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityErrorFunc">xmlRelaxNGValidityErrorFunc</a> err, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityWarningFunc">xmlRelaxNGValidityWarningFunc</a> warn, <br />					 void * ctx)</pre>
 <pre class="programlisting">void	<a href="#xmlRelaxNGSetValidErrors">xmlRelaxNGSetValidErrors</a>	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityErrorFunc">xmlRelaxNGValidityErrorFunc</a> err, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityWarningFunc">xmlRelaxNGValidityWarningFunc</a> warn, <br />					 void * ctx)</pre>
+<pre class="programlisting">void	<a href="#xmlRelaxNGSetValidStructuredErrors">xmlRelaxNGSetValidStructuredErrors</a>	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />						 <a href="libxml-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br />						 void * ctx)</pre>
 <pre class="programlisting">int	<a href="#xmlRelaxNGValidateDoc">xmlRelaxNGValidateDoc</a>		(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc)</pre>
 <pre class="programlisting">int	<a href="#xmlRelaxNGValidateFullElement">xmlRelaxNGValidateFullElement</a>	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> elem)</pre>
 <pre class="programlisting">int	<a href="#xmlRelaxNGValidatePopElement">xmlRelaxNGValidatePopElement</a>	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> elem)</pre>
@@ -135,7 +136,9 @@
 </pre><p>Set the callback functions used to handle errors for a validation context</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a Relax-NG validation context</td></tr><tr><td><span class="term"><i><tt>err</tt></i>:</span></td><td>the error callback</td></tr><tr><td><span class="term"><i><tt>warn</tt></i>:</span></td><td>the warning callback</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>contextual data for the callbacks</td></tr></tbody></table></div><h3><a name="xmlRelaxNGSetValidErrors" id="xmlRelaxNGSetValidErrors"></a>Function: xmlRelaxNGSetValidErrors</h3><pre class="programlisting">void	xmlRelaxNGSetValidErrors	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityErrorFunc">xmlRelaxNGValidityErrorFunc</a> err, <br />					 <a href="libxml-relaxng.html#xmlRelaxNGValidityWarningFunc">xmlRelaxNGValidityWarningFunc</a> warn, <br />					 void * ctx)<br />
 </pre><p>Set the error and warning callback informations</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a Relax-NG validation context</td></tr><tr><td><span class="term"><i><tt>err</tt></i>:</span></td><td>the error function</td></tr><tr><td><span class="term"><i><tt>warn</tt></i>:</span></td><td>the warning function</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the functions context</td></tr></tbody></table></div><h3><a name="xmlRelaxNGValidateDoc" id="xmlRelaxNGValidateDoc"></a>Function: xmlRelaxNGValidateDoc</h3><pre class="programlisting">int	xmlRelaxNGValidateDoc		(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a Relax-NG validation context</td></tr><tr><td><span class="term"><i><tt>err</tt></i>:</span></td><td>the error function</td></tr><tr><td><span class="term"><i><tt>warn</tt></i>:</span></td><td>the warning function</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the functions context</td></tr></tbody></table></div><h3><a name="xmlRelaxNGSetValidStructuredErrors" id="xmlRelaxNGSetValidStructuredErrors"></a>Function: xmlRelaxNGSetValidStructuredErrors</h3><pre class="programlisting">void	xmlRelaxNGSetValidStructuredErrors	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />						 <a href="libxml-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br />						 void * ctx)<br />
+</pre><p>Set the structured error callback</p>
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a Relax-NG validation context</td></tr><tr><td><span class="term"><i><tt>serror</tt></i>:</span></td><td>the structured error function</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the functions context</td></tr></tbody></table></div><h3><a name="xmlRelaxNGValidateDoc" id="xmlRelaxNGValidateDoc"></a>Function: xmlRelaxNGValidateDoc</h3><pre class="programlisting">int	xmlRelaxNGValidateDoc		(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc)<br />
 </pre><p>Validate a document tree in memory.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a Relax-NG validation context</td></tr><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>a parsed document tree</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 if the document is valid, a positive error code number otherwise and -1 in case of internal or API error.</td></tr></tbody></table></div><h3><a name="xmlRelaxNGValidateFullElement" id="xmlRelaxNGValidateFullElement"></a>Function: xmlRelaxNGValidateFullElement</h3><pre class="programlisting">int	xmlRelaxNGValidateFullElement	(<a href="libxml-relaxng.html#xmlRelaxNGValidCtxtPtr">xmlRelaxNGValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> elem)<br />
 </pre><p>Validate a full subtree when xmlRelaxNGValidatePushElement() returned 0 and the content of the node has been expanded.</p>
diff --git a/doc/html/libxml-xmlschemas.html b/doc/html/libxml-xmlschemas.html
index 201b09b..1277171 100644
--- a/doc/html/libxml-xmlschemas.html
+++ b/doc/html/libxml-xmlschemas.html
@@ -40,6 +40,7 @@
 <pre class="programlisting">void	<a href="#xmlSchemaSetParserErrors">xmlSchemaSetParserErrors</a>	(<a href="libxml-xmlschemas.html#xmlSchemaParserCtxtPtr">xmlSchemaParserCtxtPtr</a> ctxt, <br />					 <a href="libxml-xmlschemas.html#xmlSchemaValidityErrorFunc">xmlSchemaValidityErrorFunc</a> err, <br />					 <a href="libxml-xmlschemas.html#xmlSchemaValidityWarningFunc">xmlSchemaValidityWarningFunc</a> warn, <br />					 void * ctx)</pre>
 <pre class="programlisting">void	<a href="#xmlSchemaSetValidErrors">xmlSchemaSetValidErrors</a>		(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-xmlschemas.html#xmlSchemaValidityErrorFunc">xmlSchemaValidityErrorFunc</a> err, <br />					 <a href="libxml-xmlschemas.html#xmlSchemaValidityWarningFunc">xmlSchemaValidityWarningFunc</a> warn, <br />					 void * ctx)</pre>
 <pre class="programlisting">int	<a href="#xmlSchemaSetValidOptions">xmlSchemaSetValidOptions</a>	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 int options)</pre>
+<pre class="programlisting">void	<a href="#xmlSchemaSetValidStructuredErrors">xmlSchemaSetValidStructuredErrors</a>	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />						 <a href="libxml-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br />						 void * ctx)</pre>
 <pre class="programlisting">int	<a href="#xmlSchemaValidCtxtGetOptions">xmlSchemaValidCtxtGetOptions</a>	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt)</pre>
 <pre class="programlisting">int	<a href="#xmlSchemaValidateDoc">xmlSchemaValidateDoc</a>		(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc)</pre>
 <pre class="programlisting">int	<a href="#xmlSchemaValidateFile">xmlSchemaValidateFile</a>		(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 const char * filename, <br />					 int options)</pre>
@@ -145,7 +146,9 @@
 </pre><p>Set the error and warning callback informations</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a schema validation context</td></tr><tr><td><span class="term"><i><tt>err</tt></i>:</span></td><td>the error function</td></tr><tr><td><span class="term"><i><tt>warn</tt></i>:</span></td><td>the warning function</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the functions context</td></tr></tbody></table></div><h3><a name="xmlSchemaSetValidOptions" id="xmlSchemaSetValidOptions"></a>Function: xmlSchemaSetValidOptions</h3><pre class="programlisting">int	xmlSchemaSetValidOptions	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 int options)<br />
 </pre><p>Sets the options to be used during the validation.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a schema validation context</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of <a href="libxml-xmlschemas.html#xmlSchemaValidOption">xmlSchemaValidOption</a></td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of an API error.</td></tr></tbody></table></div><h3><a name="xmlSchemaValidCtxtGetOptions" id="xmlSchemaValidCtxtGetOptions"></a>Function: xmlSchemaValidCtxtGetOptions</h3><pre class="programlisting">int	xmlSchemaValidCtxtGetOptions	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a schema validation context</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a combination of <a href="libxml-xmlschemas.html#xmlSchemaValidOption">xmlSchemaValidOption</a></td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of an API error.</td></tr></tbody></table></div><h3><a name="xmlSchemaSetValidStructuredErrors" id="xmlSchemaSetValidStructuredErrors"></a>Function: xmlSchemaSetValidStructuredErrors</h3><pre class="programlisting">void	xmlSchemaSetValidStructuredErrors	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />						 <a href="libxml-xmlerror.html#xmlStructuredErrorFunc">xmlStructuredErrorFunc</a> serror, <br />						 void * ctx)<br />
+</pre><p>Set the structured error callback</p>
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a schema validation context</td></tr><tr><td><span class="term"><i><tt>serror</tt></i>:</span></td><td>the structured error function</td></tr><tr><td><span class="term"><i><tt>ctx</tt></i>:</span></td><td>the functions context</td></tr></tbody></table></div><h3><a name="xmlSchemaValidCtxtGetOptions" id="xmlSchemaValidCtxtGetOptions"></a>Function: xmlSchemaValidCtxtGetOptions</h3><pre class="programlisting">int	xmlSchemaValidCtxtGetOptions	(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt)<br />
 </pre><p>Get the validation context options.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>a schema validation context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the option combination or -1 on error.</td></tr></tbody></table></div><h3><a name="xmlSchemaValidateDoc" id="xmlSchemaValidateDoc"></a>Function: xmlSchemaValidateDoc</h3><pre class="programlisting">int	xmlSchemaValidateDoc		(<a href="libxml-xmlschemas.html#xmlSchemaValidCtxtPtr">xmlSchemaValidCtxtPtr</a> ctxt, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc)<br />
 </pre><p>Validate a document tree in memory.</p>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index d100603..07ba179 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -1033,17 +1033,18 @@
      <exports symbol='xmlRelaxNGSetValidErrors' type='function'/>
      <exports symbol='xmlRelaxNGNewParserCtxt' type='function'/>
      <exports symbol='xmlRelaxNGGetParserErrors' type='function'/>
-     <exports symbol='xmlRelaxNGSetParserErrors' type='function'/>
+     <exports symbol='xmlRelaxNGValidatePopElement' type='function'/>
      <exports symbol='xmlRelaxNGNewValidCtxt' type='function'/>
      <exports symbol='xmlRelaxNGNewMemParserCtxt' type='function'/>
      <exports symbol='xmlRelaxNGDump' type='function'/>
-     <exports symbol='xmlRelaxNGValidityErrorFunc' type='function'/>
+     <exports symbol='xmlRelaxNGSetParserErrors' type='function'/>
      <exports symbol='xmlRelaxNGParse' type='function'/>
-     <exports symbol='xmlRelaxNGValidatePushElement' type='function'/>
      <exports symbol='xmlRelaxNGValidateFullElement' type='function'/>
-     <exports symbol='xmlRelaxNGValidatePopElement' type='function'/>
+     <exports symbol='xmlRelaxNGValidityErrorFunc' type='function'/>
+     <exports symbol='xmlRelaxNGValidatePushElement' type='function'/>
      <exports symbol='xmlRelaxNGFree' type='function'/>
      <exports symbol='xmlRelaxNGValidateDoc' type='function'/>
+     <exports symbol='xmlRelaxNGSetValidStructuredErrors' type='function'/>
      <exports symbol='xmlRelaxNGFreeParserCtxt' type='function'/>
      <exports symbol='xmlRelaxNGGetValidErrors' type='function'/>
      <exports symbol='xmlRelaxNGInitTypes' type='function'/>
@@ -2883,7 +2884,7 @@
      <exports symbol='xmlSchemaValidateStream' type='function'/>
      <exports symbol='xmlSchemaGetParserErrors' type='function'/>
      <exports symbol='xmlSchemaValidateOneElement' type='function'/>
-     <exports symbol='xmlSchemaDump' type='function'/>
+     <exports symbol='xmlSchemaSetValidStructuredErrors' type='function'/>
      <exports symbol='xmlSchemaSetValidErrors' type='function'/>
      <exports symbol='xmlSchemaValidCtxtGetOptions' type='function'/>
      <exports symbol='xmlSchemaValidateFile' type='function'/>
@@ -2894,6 +2895,7 @@
      <exports symbol='xmlSchemaSetValidOptions' type='function'/>
      <exports symbol='xmlSchemaSetParserErrors' type='function'/>
      <exports symbol='xmlSchemaValidityWarningFunc' type='function'/>
+     <exports symbol='xmlSchemaDump' type='function'/>
      <exports symbol='xmlSchemaFreeValidCtxt' type='function'/>
      <exports symbol='xmlSchemaNewValidCtxt' type='function'/>
     </file>
@@ -12233,6 +12235,14 @@
       <arg name='warn' type='xmlRelaxNGValidityWarningFunc' info='the warning function'/>
       <arg name='ctx' type='void *' info='the functions context'/>
     </function>
+    <function name='xmlRelaxNGSetValidStructuredErrors' file='relaxng' module='relaxng'>
+      <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+      <info>Set the structured error callback</info>
+      <return type='void'/>
+      <arg name='ctxt' type='xmlRelaxNGValidCtxtPtr' info='a Relax-NG validation context'/>
+      <arg name='serror' type='xmlStructuredErrorFunc' info='the structured error function'/>
+      <arg name='ctx' type='void *' info='the functions context'/>
+    </function>
     <function name='xmlRelaxNGValidateDoc' file='relaxng' module='relaxng'>
       <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
       <info>Validate a document tree in memory.</info>
@@ -13038,6 +13048,14 @@
       <arg name='ctxt' type='xmlSchemaValidCtxtPtr' info='a schema validation context'/>
       <arg name='options' type='int' info='a combination of xmlSchemaValidOption'/>
     </function>
+    <function name='xmlSchemaSetValidStructuredErrors' file='xmlschemas' module='xmlschemas'>
+      <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
+      <info>Set the structured error callback</info>
+      <return type='void'/>
+      <arg name='ctxt' type='xmlSchemaValidCtxtPtr' info='a schema validation context'/>
+      <arg name='serror' type='xmlStructuredErrorFunc' info='the structured error function'/>
+      <arg name='ctx' type='void *' info='the functions context'/>
+    </function>
     <function name='xmlSchemaValPredefTypeNode' file='xmlschemastypes' module='xmlschemastypes'>
       <cond>defined(LIBXML_SCHEMAS_ENABLED)</cond>
       <info>Check that a value conforms to the lexical space of the predefined type. if true a value is computed and returned in @val.</info>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index 52dc716..6fea832 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -2449,6 +2449,7 @@
     <reference name='xmlRelaxNGPtr' href='html/libxml-relaxng.html#xmlRelaxNGPtr'/>
     <reference name='xmlRelaxNGSetParserErrors' href='html/libxml-relaxng.html#xmlRelaxNGSetParserErrors'/>
     <reference name='xmlRelaxNGSetValidErrors' href='html/libxml-relaxng.html#xmlRelaxNGSetValidErrors'/>
+    <reference name='xmlRelaxNGSetValidStructuredErrors' href='html/libxml-relaxng.html#xmlRelaxNGSetValidStructuredErrors'/>
     <reference name='xmlRelaxNGValidCtxt' href='html/libxml-relaxng.html#xmlRelaxNGValidCtxt'/>
     <reference name='xmlRelaxNGValidCtxtPtr' href='html/libxml-relaxng.html#xmlRelaxNGValidCtxtPtr'/>
     <reference name='xmlRelaxNGValidErr' href='html/libxml-relaxng.html#xmlRelaxNGValidErr'/>
@@ -2601,6 +2602,7 @@
     <reference name='xmlSchemaSetParserErrors' href='html/libxml-xmlschemas.html#xmlSchemaSetParserErrors'/>
     <reference name='xmlSchemaSetValidErrors' href='html/libxml-xmlschemas.html#xmlSchemaSetValidErrors'/>
     <reference name='xmlSchemaSetValidOptions' href='html/libxml-xmlschemas.html#xmlSchemaSetValidOptions'/>
+    <reference name='xmlSchemaSetValidStructuredErrors' href='html/libxml-xmlschemas.html#xmlSchemaSetValidStructuredErrors'/>
     <reference name='xmlSchemaType' href='html/libxml-schemasInternals.html#xmlSchemaType'/>
     <reference name='xmlSchemaTypeLink' href='html/libxml-schemasInternals.html#xmlSchemaTypeLink'/>
     <reference name='xmlSchemaTypeLinkPtr' href='html/libxml-schemasInternals.html#xmlSchemaTypeLinkPtr'/>
@@ -5848,6 +5850,7 @@
       <ref name='xmlRelaxNGPtr'/>
       <ref name='xmlRelaxNGSetParserErrors'/>
       <ref name='xmlRelaxNGSetValidErrors'/>
+      <ref name='xmlRelaxNGSetValidStructuredErrors'/>
       <ref name='xmlRelaxNGValidCtxt'/>
       <ref name='xmlRelaxNGValidCtxtPtr'/>
       <ref name='xmlRelaxNGValidErr'/>
@@ -6000,6 +6003,7 @@
       <ref name='xmlSchemaSetParserErrors'/>
       <ref name='xmlSchemaSetValidErrors'/>
       <ref name='xmlSchemaSetValidOptions'/>
+      <ref name='xmlSchemaSetValidStructuredErrors'/>
       <ref name='xmlSchemaType'/>
       <ref name='xmlSchemaTypeLink'/>
       <ref name='xmlSchemaTypeLinkPtr'/>
@@ -8340,6 +8344,7 @@
       <ref name='xmlRegNewExecCtxt'/>
       <ref name='xmlRelaxNGSetParserErrors'/>
       <ref name='xmlRelaxNGSetValidErrors'/>
+      <ref name='xmlRelaxNGSetValidStructuredErrors'/>
       <ref name='xmlRelaxNGValidityErrorFunc'/>
       <ref name='xmlRelaxNGValidityWarningFunc'/>
       <ref name='xmlSAX2AttributeDecl'/>
@@ -8379,6 +8384,7 @@
       <ref name='xmlSaveToIO'/>
       <ref name='xmlSchemaSetParserErrors'/>
       <ref name='xmlSchemaSetValidErrors'/>
+      <ref name='xmlSchemaSetValidStructuredErrors'/>
       <ref name='xmlSchemaValidateStream'/>
       <ref name='xmlSchemaValidityErrorFunc'/>
       <ref name='xmlSchemaValidityWarningFunc'/>
@@ -9515,6 +9521,7 @@
       <ref name='xmlRelaxNGFreeValidCtxt'/>
       <ref name='xmlRelaxNGGetValidErrors'/>
       <ref name='xmlRelaxNGSetValidErrors'/>
+      <ref name='xmlRelaxNGSetValidStructuredErrors'/>
       <ref name='xmlRelaxNGValidateDoc'/>
       <ref name='xmlRelaxNGValidateFullElement'/>
       <ref name='xmlRelaxNGValidatePopElement'/>
@@ -9654,6 +9661,7 @@
       <ref name='xmlSchemaSAXPlug'/>
       <ref name='xmlSchemaSetValidErrors'/>
       <ref name='xmlSchemaSetValidOptions'/>
+      <ref name='xmlSchemaSetValidStructuredErrors'/>
       <ref name='xmlSchemaValidCtxtGetOptions'/>
       <ref name='xmlSchemaValidateDoc'/>
       <ref name='xmlSchemaValidateFile'/>
@@ -9716,6 +9724,8 @@
       <ref name='xmlStreamPushAttr'/>
     </type>
     <type name='xmlStructuredErrorFunc'>
+      <ref name='xmlRelaxNGSetValidStructuredErrors'/>
+      <ref name='xmlSchemaSetValidStructuredErrors'/>
       <ref name='xmlSetStructuredErrorFunc'/>
       <ref name='xmlTextReaderSetStructuredErrorHandler'/>
       <ref name='xmlThrDefSetStructuredErrorFunc'/>
@@ -11034,6 +11044,7 @@
       <ref name='xmlRelaxNGPtr'/>
       <ref name='xmlRelaxNGSetParserErrors'/>
       <ref name='xmlRelaxNGSetValidErrors'/>
+      <ref name='xmlRelaxNGSetValidStructuredErrors'/>
       <ref name='xmlRelaxNGValidCtxt'/>
       <ref name='xmlRelaxNGValidCtxtPtr'/>
       <ref name='xmlRelaxNGValidErr'/>
@@ -12827,6 +12838,7 @@
       <ref name='xmlSchemaSetParserErrors'/>
       <ref name='xmlSchemaSetValidErrors'/>
       <ref name='xmlSchemaSetValidOptions'/>
+      <ref name='xmlSchemaSetValidStructuredErrors'/>
       <ref name='xmlSchemaValidCtxt'/>
       <ref name='xmlSchemaValidCtxtGetOptions'/>
       <ref name='xmlSchemaValidCtxtPtr'/>
@@ -16472,6 +16484,7 @@
           <ref name='xmlRelaxNGParse'/>
           <ref name='xmlRelaxNGSetParserErrors'/>
           <ref name='xmlRelaxNGSetValidErrors'/>
+          <ref name='xmlRelaxNGSetValidStructuredErrors'/>
           <ref name='xmlRelaxNGValidateDoc'/>
         </word>
         <word name='RelaxNG'>
@@ -16761,38 +16774,6 @@
         <word name='Serialize'>
           <ref name='xmlAttrSerializeTxtContent'/>
         </word>
-        <word name='Set'>
-          <ref name='htmlHandleOmittedElem'/>
-          <ref name='initGenericErrorDefaultFunc'/>
-          <ref name='setNamespace'/>
-          <ref name='xlinkSetDefaultDetect'/>
-          <ref name='xlinkSetDefaultHandler'/>
-          <ref name='xmlDocSetRootElement'/>
-          <ref name='xmlInitializePredefinedEntities'/>
-          <ref name='xmlKeepBlanksDefault'/>
-          <ref name='xmlLineNumbersDefault'/>
-          <ref name='xmlNodeSetBase'/>
-          <ref name='xmlNodeSetLang'/>
-          <ref name='xmlNodeSetName'/>
-          <ref name='xmlNodeSetSpacePreserve'/>
-          <ref name='xmlPedanticParserDefault'/>
-          <ref name='xmlRelaxNGSetParserErrors'/>
-          <ref name='xmlRelaxNGSetValidErrors'/>
-          <ref name='xmlSAXDefaultVersion'/>
-          <ref name='xmlSaveSetAttrEscape'/>
-          <ref name='xmlSaveSetEscape'/>
-          <ref name='xmlSchemaSetParserErrors'/>
-          <ref name='xmlSchemaSetValidErrors'/>
-          <ref name='xmlSetBufferAllocationScheme'/>
-          <ref name='xmlSetEntityReferenceFunc'/>
-          <ref name='xmlSetNsProp'/>
-          <ref name='xmlSetProp'/>
-          <ref name='xmlSubstituteEntitiesDefault'/>
-          <ref name='xmlTextWriterSetIndent'/>
-          <ref name='xmlTextWriterSetIndentString'/>
-          <ref name='xmlXIncludeSetFlags'/>
-          <ref name='xmlXPtrEvalRangePredicate'/>
-        </word>
         <word name='Sets'>
           <ref name='htmlSetMetaEncoding'/>
           <ref name='xmlBufferSetAllocationScheme'/>
@@ -21902,9 +21883,11 @@
           <ref name='xmlRelaxNGGetValidErrors'/>
           <ref name='xmlRelaxNGSetParserErrors'/>
           <ref name='xmlRelaxNGSetValidErrors'/>
+          <ref name='xmlRelaxNGSetValidStructuredErrors'/>
           <ref name='xmlSchemaGetValidErrors'/>
           <ref name='xmlSchemaSetParserErrors'/>
           <ref name='xmlSchemaSetValidErrors'/>
+          <ref name='xmlSchemaSetValidStructuredErrors'/>
           <ref name='xmlShellCmd'/>
           <ref name='xmlSwitchEncoding'/>
           <ref name='xmlSwitchInputEncoding'/>
@@ -27409,6 +27392,8 @@
           <ref name='xmlSchemaNewStringValue'/>
         </word>
         <word name='structured'>
+          <ref name='xmlRelaxNGSetValidStructuredErrors'/>
+          <ref name='xmlSchemaSetValidStructuredErrors'/>
           <ref name='xmlSetStructuredErrorFunc'/>
         </word>
         <word name='structures'>
diff --git a/elfgcchack.h b/elfgcchack.h
index e2584c0..cc50374 100644
--- a/elfgcchack.h
+++ b/elfgcchack.h
@@ -8134,6 +8134,18 @@
 
 #if defined(LIBXML_SCHEMAS_ENABLED)
 #ifdef bottom_relaxng
+#undef xmlRelaxNGSetValidStructuredErrors
+extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors __attribute((alias("xmlRelaxNGSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGSetValidStructuredErrors
+extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGSetValidStructuredErrors xmlRelaxNGSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
 #undef xmlRelaxNGValidateDoc
 extern __typeof (xmlRelaxNGValidateDoc) xmlRelaxNGValidateDoc __attribute((alias("xmlRelaxNGValidateDoc__internal_alias")));
 #else
@@ -9240,6 +9252,18 @@
 
 #if defined(LIBXML_SCHEMAS_ENABLED)
 #ifdef bottom_xmlschemas
+#undef xmlSchemaIsValid
+extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid __attribute((alias("xmlSchemaIsValid__internal_alias")));
+#else
+#ifndef xmlSchemaIsValid
+extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaIsValid xmlSchemaIsValid__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
 #undef xmlSchemaNewDocParserCtxt
 extern __typeof (xmlSchemaNewDocParserCtxt) xmlSchemaNewDocParserCtxt __attribute((alias("xmlSchemaNewDocParserCtxt__internal_alias")));
 #else
@@ -9348,6 +9372,30 @@
 
 #if defined(LIBXML_SCHEMAS_ENABLED)
 #ifdef bottom_xmlschemas
+#undef xmlSchemaSAXPlug
+extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug __attribute((alias("xmlSchemaSAXPlug__internal_alias")));
+#else
+#ifndef xmlSchemaSAXPlug
+extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSAXPlug xmlSchemaSAXPlug__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSAXUnplug
+extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug __attribute((alias("xmlSchemaSAXUnplug__internal_alias")));
+#else
+#ifndef xmlSchemaSAXUnplug
+extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSAXUnplug xmlSchemaSAXUnplug__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
 #undef xmlSchemaSetParserErrors
 extern __typeof (xmlSchemaSetParserErrors) xmlSchemaSetParserErrors __attribute((alias("xmlSchemaSetParserErrors__internal_alias")));
 #else
@@ -9383,6 +9431,18 @@
 #endif
 
 #if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetValidStructuredErrors
+extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors __attribute((alias("xmlSchemaSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlSchemaSetValidStructuredErrors
+extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetValidStructuredErrors xmlSchemaSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
 #ifdef bottom_xmlschemastypes
 #undef xmlSchemaValPredefTypeNode
 extern __typeof (xmlSchemaValPredefTypeNode) xmlSchemaValPredefTypeNode __attribute((alias("xmlSchemaValPredefTypeNode__internal_alias")));
@@ -9998,7 +10058,6 @@
 #endif
 #endif
 
-#if defined(LIBXML_PUSH_ENABLED)
 #ifdef bottom_parser
 #undef xmlStopParser
 extern __typeof (xmlStopParser) xmlStopParser __attribute((alias("xmlStopParser__internal_alias")));
@@ -10008,7 +10067,6 @@
 #define xmlStopParser xmlStopParser__internal_alias
 #endif
 #endif
-#endif
 
 #ifdef bottom_xmlstring
 #undef xmlStrEqual
@@ -11056,6 +11114,18 @@
 #endif
 #endif
 
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSchemaValidate
+extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate __attribute((alias("xmlTextReaderSchemaValidate__internal_alias")));
+#else
+#ifndef xmlTextReaderSchemaValidate
+extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSchemaValidate xmlTextReaderSchemaValidate__internal_alias
+#endif
+#endif
+#endif
+
 #if defined(LIBXML_READER_ENABLED)
 #ifdef bottom_xmlreader
 #undef xmlTextReaderSetErrorHandler
@@ -11080,6 +11150,18 @@
 #endif
 #endif
 
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetSchema
+extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema __attribute((alias("xmlTextReaderSetSchema__internal_alias")));
+#else
+#ifndef xmlTextReaderSetSchema
+extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetSchema xmlTextReaderSetSchema__internal_alias
+#endif
+#endif
+#endif
+
 #if defined(LIBXML_READER_ENABLED)
 #ifdef bottom_xmlreader
 #undef xmlTextReaderSetStructuredErrorHandler
@@ -14484,7 +14566,7 @@
 #endif
 #endif
 
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED)
 #ifdef bottom_tree
 #undef xmlValidateNCName
 extern __typeof (xmlValidateNCName) xmlValidateNCName __attribute((alias("xmlValidateNCName__internal_alias")));
diff --git a/error.c b/error.c
index 17ced92..b0d0f14 100644
--- a/error.c
+++ b/error.c
@@ -595,8 +595,10 @@
 	    schannel = xmlStructuredError;
 	else
 	    channel = xmlGenericError;
+	if (!data) {
 	data = xmlGenericErrorContext;
     }
+    }
     if (schannel != NULL) {
         schannel(data, to);
 	return;
diff --git a/include/libxml/relaxng.h b/include/libxml/relaxng.h
index ca3c13b..cd75398 100644
--- a/include/libxml/relaxng.h
+++ b/include/libxml/relaxng.h
@@ -152,6 +152,9 @@
 					 xmlRelaxNGValidityErrorFunc *err,
 					 xmlRelaxNGValidityWarningFunc *warn,
 					 void **ctx);
+XMLPUBFUN void XMLCALL
+			xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
+					  xmlStructuredErrorFunc serror, void *ctx);
 XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL	
 		    xmlRelaxNGNewValidCtxt	(xmlRelaxNGPtr schema);
 XMLPUBFUN void XMLCALL			
diff --git a/include/libxml/xmlschemas.h b/include/libxml/xmlschemas.h
index 6cecffd..89fc4b4 100644
--- a/include/libxml/xmlschemas.h
+++ b/include/libxml/xmlschemas.h
@@ -138,6 +138,9 @@
 					 xmlSchemaValidityErrorFunc err,
 					 xmlSchemaValidityWarningFunc warn,
 					 void *ctx);
+XMLPUBFUN void XMLCALL
+	    xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
+								  xmlStructuredErrorFunc serror, void *ctx);
 XMLPUBFUN int XMLCALL
 	    xmlSchemaGetValidErrors	(xmlSchemaValidCtxtPtr ctxt,
 					 xmlSchemaValidityErrorFunc *err,
diff --git a/relaxng.c b/relaxng.c
index b1d4a77..61daa0d 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -10663,6 +10663,26 @@
 }
 
 /**
+ * xmlRelaxNGSetValidStructuredErrors:
+ * @ctxt:  a Relax-NG validation context
+ * @serror:  the structured error function
+ * @ctx: the functions context
+ *
+ * Set the structured error callback
+ */
+void
+xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
+								  xmlStructuredErrorFunc serror, void *ctx)
+{
+    if (ctxt == NULL)
+        return;
+	ctxt->serror = serror;
+    ctxt->error = NULL;
+    ctxt->warning = NULL;
+    ctxt->userData = ctx;
+}
+
+/**
  * xmlRelaxNGGetValidErrors:
  * @ctxt:  a Relax-NG validation context
  * @err:  the error function result
diff --git a/testapi.c b/testapi.c
index 9e7969b..e44e9be 100644
--- a/testapi.c
+++ b/testapi.c
@@ -17337,6 +17337,16 @@
 
 
 static int
+test_xmlRelaxNGSetValidStructuredErrors(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlRelaxNGValidateDoc(void) {
     int test_ret = 0;
 
@@ -17613,7 +17623,7 @@
 test_relaxng(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing relaxng : 14 of 22 functions ...\n");
+    if (quiet == 0) printf("Testing relaxng : 14 of 23 functions ...\n");
     test_ret += test_xmlRelaxNGDump();
     test_ret += test_xmlRelaxNGDumpTree();
     test_ret += test_xmlRelaxNGGetParserErrors();
@@ -17626,6 +17636,7 @@
     test_ret += test_xmlRelaxNGParse();
     test_ret += test_xmlRelaxNGSetParserErrors();
     test_ret += test_xmlRelaxNGSetValidErrors();
+    test_ret += test_xmlRelaxNGSetValidStructuredErrors();
     test_ret += test_xmlRelaxNGValidateDoc();
     test_ret += test_xmlRelaxNGValidateFullElement();
     test_ret += test_xmlRelaxNGValidatePopElement();
@@ -32809,6 +32820,16 @@
 
 
 static int
+test_xmlSchemaSetValidStructuredErrors(void) {
+    int test_ret = 0;
+
+
+    /* missing type support */
+    return(test_ret);
+}
+
+
+static int
 test_xmlSchemaValidCtxtGetOptions(void) {
     int test_ret = 0;
 
@@ -33037,7 +33058,7 @@
 test_xmlschemas(void) {
     int test_ret = 0;
 
-    if (quiet == 0) printf("Testing xmlschemas : 14 of 22 functions ...\n");
+    if (quiet == 0) printf("Testing xmlschemas : 14 of 23 functions ...\n");
     test_ret += test_xmlSchemaDump();
     test_ret += test_xmlSchemaGetParserErrors();
     test_ret += test_xmlSchemaGetValidErrors();
@@ -33052,6 +33073,7 @@
     test_ret += test_xmlSchemaSetParserErrors();
     test_ret += test_xmlSchemaSetValidErrors();
     test_ret += test_xmlSchemaSetValidOptions();
+    test_ret += test_xmlSchemaSetValidStructuredErrors();
     test_ret += test_xmlSchemaValidCtxtGetOptions();
     test_ret += test_xmlSchemaValidateDoc();
     test_ret += test_xmlSchemaValidateFile();
diff --git a/win32/libxml2.def.src b/win32/libxml2.def.src
index a0eb545..e9f7959 100644
--- a/win32/libxml2.def.src
+++ b/win32/libxml2.def.src
@@ -1430,6 +1430,9 @@
 xmlRelaxNGSetValidErrors
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
+xmlRelaxNGSetValidStructuredErrors
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
 xmlRelaxNGValidateDoc
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
@@ -1586,6 +1589,9 @@
 xmlSchemaIsBuiltInTypeFacet
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
+xmlSchemaIsValid
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
 xmlSchemaNewDocParserCtxt
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
@@ -1613,6 +1619,12 @@
 xmlSchemaParse
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
+xmlSchemaSAXPlug
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
+xmlSchemaSAXUnplug
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
 xmlSchemaSetParserErrors
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
@@ -1622,6 +1634,9 @@
 xmlSchemaSetValidOptions
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
+xmlSchemaSetValidStructuredErrors
+#endif
+#ifdef LIBXML_SCHEMAS_ENABLED
 xmlSchemaValPredefTypeNode
 #endif
 #ifdef LIBXML_SCHEMAS_ENABLED
@@ -1836,8 +1851,10 @@
 #ifdef LIBXML_SCHEMAS_ENABLED
 xmlTextReaderRelaxNGValidate
 #endif
+xmlTextReaderSchemaValidate
 xmlTextReaderSetErrorHandler
 xmlTextReaderSetParserProp
+xmlTextReaderSetSchema
 xmlTextReaderSetStructuredErrorHandler
 xmlTextReaderStandalone
 xmlTextReaderValue
diff --git a/xmlreader.c b/xmlreader.c
index 14843eb..e8858a1 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -3880,6 +3880,66 @@
 }
 
 #ifdef LIBXML_SCHEMAS_ENABLED
+
+static char *
+xmlTextReaderBuildMessage(const char *msg, va_list ap);
+
+static void 
+xmlTextReaderValidityError(void *ctxt, const char *msg, ...);
+
+static void 
+xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...);
+
+static void xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
+{
+	xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+	char * str;
+	va_list ap;
+
+	va_start(ap,msg);
+	str = xmlTextReaderBuildMessage(msg,ap);
+	if (!reader->errorFunc) {
+		xmlTextReaderValidityError(ctx, "%s", str);
+	} else {
+		reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_ERROR, NULL /* locator */);
+	}
+	if (str != NULL)
+		xmlFree(str);
+	va_end(ap);
+}
+
+static void xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
+{
+	xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+	char * str;
+	va_list ap;
+
+	va_start(ap,msg);
+	str = xmlTextReaderBuildMessage(msg,ap);
+	if (!reader->errorFunc) {
+		xmlTextReaderValidityWarning(ctx, "%s", str);
+	} else {
+		reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_WARNING, NULL /* locator */);
+	}
+	if (str != NULL)
+		xmlFree(str);
+	va_end(ap);
+}
+
+static void 
+xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
+
+static void xmlTextReaderValidityStructuredRelay(void * userData, xmlErrorPtr error)
+{
+	xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
+
+	if (reader->sErrorFunc) {
+		reader->sErrorFunc(reader->errorFuncArg, error);
+	} else {
+		xmlTextReaderStructuredError(reader, error);
+	}
+}
+
 /**
  * xmlTextReaderRelaxNGSetSchema:
  * @reader:  the xmlTextReaderPtr used
@@ -3924,9 +3984,14 @@
         return(-1);
     if (reader->errorFunc != NULL) {
 	xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
-			 (xmlRelaxNGValidityErrorFunc)reader->errorFunc,
-			 (xmlRelaxNGValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			xmlTextReaderValidityErrorRelay,
+			xmlTextReaderValidityWarningRelay,
+			reader);
+    }
+	if (reader->sErrorFunc != NULL) {
+		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+			xmlTextReaderValidityStructuredRelay,
+			reader);
     }
     reader->rngValidErrors = 0;
     reader->rngFullNode = NULL;
@@ -3999,9 +4064,14 @@
     }
     if (reader->errorFunc != NULL) {
 	xmlSchemaSetValidErrors(reader->xsdValidCtxt,
-			 (xmlSchemaValidityErrorFunc)reader->errorFunc,
-			 (xmlSchemaValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			xmlTextReaderValidityErrorRelay,
+			xmlTextReaderValidityWarningRelay,
+			reader);
+    }
+	if (reader->sErrorFunc != NULL) {
+		xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
+			xmlTextReaderValidityStructuredRelay,
+			reader);
     }
     reader->xsdValidErrors = 0;
     reader->validate = XML_TEXTREADER_VALIDATE_XSD;
@@ -4051,9 +4121,14 @@
     ctxt = xmlRelaxNGNewParserCtxt(rng);
     if (reader->errorFunc != NULL) {
 	xmlRelaxNGSetParserErrors(ctxt,
-			 (xmlRelaxNGValidityErrorFunc) reader->errorFunc,
-			 (xmlRelaxNGValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			 xmlTextReaderValidityErrorRelay,
+			 xmlTextReaderValidityWarningRelay,
+			 reader);
+    }
+	if (reader->sErrorFunc != NULL) {
+		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+			xmlTextReaderValidityStructuredRelay,
+			reader);
     }
     reader->rngSchemas = xmlRelaxNGParse(ctxt);
     xmlRelaxNGFreeParserCtxt(ctxt);
@@ -4067,9 +4142,14 @@
     }
     if (reader->errorFunc != NULL) {
 	xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
-			 (xmlRelaxNGValidityErrorFunc)reader->errorFunc,
-			 (xmlRelaxNGValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			 xmlTextReaderValidityErrorRelay,
+			 xmlTextReaderValidityWarningRelay,
+			 reader);
+    }
+	if (reader->sErrorFunc != NULL) {
+		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+			xmlTextReaderValidityStructuredRelay,
+			reader);
     }
     reader->rngValidErrors = 0;
     reader->rngFullNode = NULL;
@@ -4129,9 +4209,9 @@
     ctxt = xmlSchemaNewParserCtxt(xsd);
     if (reader->errorFunc != NULL) {
 	xmlSchemaSetParserErrors(ctxt,
-			 (xmlSchemaValidityErrorFunc) reader->errorFunc,
-			 (xmlSchemaValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			 xmlTextReaderValidityErrorRelay,
+			 xmlTextReaderValidityWarningRelay,
+			 reader);
     }
     reader->xsdSchemas = xmlSchemaParse(ctxt);
     xmlSchemaFreeParserCtxt(ctxt);
@@ -4155,9 +4235,14 @@
     }
     if (reader->errorFunc != NULL) {
 	xmlSchemaSetValidErrors(reader->xsdValidCtxt,
-			 (xmlSchemaValidityErrorFunc)reader->errorFunc,
-			 (xmlSchemaValidityWarningFunc) reader->errorFunc,
-			 reader->errorFuncArg);
+			 xmlTextReaderValidityErrorRelay,
+			 xmlTextReaderValidityWarningRelay,
+			 reader);
+    }
+	if (reader->sErrorFunc != NULL) {
+		xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, 
+			xmlTextReaderValidityStructuredRelay,
+			reader);
     }
     reader->xsdValidErrors = 0;
     reader->validate = XML_TEXTREADER_VALIDATE_XSD;
@@ -4467,6 +4552,22 @@
 	reader->errorFunc = f;
 	reader->sErrorFunc = NULL;
 	reader->errorFuncArg = arg;
+#ifdef LIBXML_SCHEMAS_ENABLED
+		if (reader->rngValidCtxt) {
+			xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
+				 xmlTextReaderValidityErrorRelay,
+				 xmlTextReaderValidityWarningRelay,
+				 reader);
+			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
+		}
+		if (reader->xsdValidCtxt) {
+			xmlSchemaSetValidErrors(reader->xsdValidCtxt,
+				 xmlTextReaderValidityErrorRelay,
+				 xmlTextReaderValidityWarningRelay,
+				 reader);
+			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
+		}
+#endif
     }
     else {
 	/* restore defaults */
@@ -4477,6 +4578,16 @@
 	reader->errorFunc = NULL;
 	reader->sErrorFunc = NULL;
 	reader->errorFuncArg = NULL;
+#ifdef LIBXML_SCHEMAS_ENABLED
+		if (reader->rngValidCtxt) {
+			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
+			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
+		}
+		if (reader->xsdValidCtxt) {
+			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
+			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
+		}
+#endif
     }
 }
 
@@ -4503,6 +4614,20 @@
 	reader->sErrorFunc = f;
 	reader->errorFunc = NULL;
 	reader->errorFuncArg = arg;
+#ifdef LIBXML_SCHEMAS_ENABLED
+		if (reader->rngValidCtxt) {
+			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
+			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+				xmlTextReaderValidityStructuredRelay,
+				reader);
+		}
+		if (reader->xsdValidCtxt) {
+			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
+			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, 
+				xmlTextReaderValidityStructuredRelay,
+				reader);
+		}
+#endif
   }
   else {
 	/* restore defaults */
@@ -4514,6 +4639,16 @@
 	reader->errorFunc = NULL;
 	reader->sErrorFunc = NULL;
 	reader->errorFuncArg = NULL;
+#ifdef LIBXML_SCHEMAS_ENABLED
+		if (reader->rngValidCtxt) {
+			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
+			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
+		}
+		if (reader->xsdValidCtxt) {
+			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
+			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
+		}
+#endif
   }
 }
 
diff --git a/xmlschemas.c b/xmlschemas.c
index afa7010..4411f39 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -23648,6 +23648,26 @@
 }
 
 /**
+ * xmlSchemaSetValidStructuredErrors:
+ * @ctxt:  a schema validation context
+ * @serror:  the structured error function
+ * @ctx: the functions context
+ *
+ * Set the structured error callback
+ */
+void
+xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
+								  xmlStructuredErrorFunc serror, void *ctx)
+{
+    if (ctxt == NULL)
+        return;
+	ctxt->serror = serror;
+    ctxt->error = NULL;
+    ctxt->warning = NULL;
+    ctxt->userData = ctx;
+}
+
+/**
  * xmlSchemaGetValidErrors:
  * @ctxt:	a XML-Schema validation context
  * @err: the error function result