fixed namespace bug in push mode reported by Rob Richards added it to the

* parser.c: fixed namespace bug in push mode reported by
  Rob Richards
* test/ns6 result//ns6*: added it to the regression tests
* xmlmodule.c testModule.c include/libxml/xmlmodule.h:
  added an extra option argument to module opening and defined
  a couple of flags to the API.
Daniel
diff --git a/ChangeLog b/ChangeLog
index a19dfaf..d9ab9d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Jan  4 22:47:22 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+	* parser.c: fixed namespace bug in push mode reported by 
+	  Rob Richards
+	* test/ns6 result//ns6*: added it to the regression tests
+	* xmlmodule.c testModule.c include/libxml/xmlmodule.h:
+	  added an extra option argument to module opening and defined
+	  a couple of flags to the API.
+
 Tue Jan  4 21:16:05 CET 2005 Daniel Veillard <daniel@veillard.com>
 
 	* xmlmodule.c include/libxml/xmlmodule.h: applied patch from
diff --git a/doc/APIchunk15.html b/doc/APIchunk15.html
index d398332..3867ad2 100644
--- a/doc/APIchunk15.html
+++ b/doc/APIchunk15.html
@@ -76,6 +76,7 @@
 <a href="html/libxml-HTMLtree.html#HTML_PI_NODE">HTML_PI_NODE</a><br />
 <a href="html/libxml-HTMLtree.html#HTML_PRESERVE_NODE">HTML_PRESERVE_NODE</a><br />
 <a href="html/libxml-HTMLtree.html#HTML_TEXT_NODE">HTML_TEXT_NODE</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveDoc">xmlSaveDoc</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveTree">xmlSaveTree</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderNextSibling">xmlTextReaderNextSibling</a><br />
diff --git a/doc/APIchunk19.html b/doc/APIchunk19.html
index 96ca3b7..9c15d8f 100644
--- a/doc/APIchunk19.html
+++ b/doc/APIchunk19.html
@@ -234,6 +234,7 @@
 <a href="html/libxml-uri.html#xmlURIUnescapeString">xmlURIUnescapeString</a><br />
 </dd><dt>options</dt><dd><a href="html/libxml-HTMLparser.html#htmlCtxtUseOptions">htmlCtxtUseOptions</a><br />
 <a href="html/libxml-parser.html#xmlCtxtUseOptions">xmlCtxtUseOptions</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveToFd">xmlSaveToFd</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveToFilename">xmlSaveToFilename</a><br />
 <a href="html/libxml-xmlsave.html#xmlSaveToIO">xmlSaveToIO</a><br />
diff --git a/doc/APIchunk26.html b/doc/APIchunk26.html
index f69ace8..eb0df98 100644
--- a/doc/APIchunk26.html
+++ b/doc/APIchunk26.html
@@ -237,6 +237,7 @@
 </dd><dt>xmlLocationSetPtr</dt><dd><a href="html/libxml-xpointer.html#xmlXPtrFreeLocationSet">xmlXPtrFreeLocationSet</a><br />
 <a href="html/libxml-xpointer.html#xmlXPtrLocationSetCreate">xmlXPtrLocationSetCreate</a><br />
 </dd><dt>xmlLockLibrary</dt><dd><a href="html/libxml-threads.html#xmlLockLibrary">xmlLockLibrary</a><br />
+</dd><dt>xmlModuleOption</dt><dd><a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 </dd><dt>xmlMutexLock</dt><dd><a href="html/libxml-threads.html#xmlMutexLock">xmlMutexLock</a><br />
 </dd><dt>xmlMutexUnlock</dt><dd><a href="html/libxml-threads.html#xmlMutexUnlock">xmlMutexUnlock</a><br />
 </dd><dt>xmlNanoFTPGet</dt><dd><a href="html/libxml-nanoftp.html#ftpDataCallback">ftpDataCallback</a><br />
diff --git a/doc/APIchunk7.html b/doc/APIchunk7.html
index 64be9fd..423610a 100644
--- a/doc/APIchunk7.html
+++ b/doc/APIchunk7.html
@@ -55,6 +55,7 @@
 <a href="html/libxml-parserInternals.html#xmlDecodeEntities">xmlDecodeEntities</a><br />
 <a href="html/libxml-entities.html#xmlEncodeEntities">xmlEncodeEntities</a><br />
 <a href="html/libxml-parser.html#xmlLoadExternalEntity">xmlLoadExternalEntity</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
 <a href="html/libxml-parserInternals.html#xmlNamespaceParseNCName">xmlNamespaceParseNCName</a><br />
 <a href="html/libxml-parserInternals.html#xmlNamespaceParseNSDef">xmlNamespaceParseNSDef</a><br />
 <a href="html/libxml-parserInternals.html#xmlNamespaceParseQName">xmlNamespaceParseQName</a><br />
diff --git a/doc/APIfiles.html b/doc/APIfiles.html
index bb0af87..b35dfe1 100644
--- a/doc/APIfiles.html
+++ b/doc/APIfiles.html
@@ -2433,10 +2433,13 @@
 <a href="html/libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlReallocLoc">xmlReallocLoc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a><br />
-</p><h2><a name="xmlmodule" id="xmlmodule">Module xmlmodule</a>:</h2><p><a href="html/libxml-xmlmodule.html#xmlModule">xmlModule</a><br />
+</p><h2><a name="xmlmodule" id="xmlmodule">Module xmlmodule</a>:</h2><p><a href="html/libxml-xmlmodule.html#XML_MODULE_LAZY">XML_MODULE_LAZY</a><br />
+<a href="html/libxml-xmlmodule.html#XML_MODULE_LOCAL">XML_MODULE_LOCAL</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModule">xmlModule</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleClose">xmlModuleClose</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleFree">xmlModuleFree</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModuleOption">xmlModuleOption</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
 </p><h2><a name="xmlreader" id="xmlreader">Module xmlreader</a>:</h2><p><a href="html/libxml-xmlreader.html#XML_PARSER_DEFAULTATTRS">XML_PARSER_DEFAULTATTRS</a><br />
diff --git a/doc/APIsymbols.html b/doc/APIsymbols.html
index 98aa091..9c6f168 100644
--- a/doc/APIsymbols.html
+++ b/doc/APIsymbols.html
@@ -498,6 +498,8 @@
 <a href="html/libxml-tree.html#XML_LOCAL_NAMESPACE">XML_LOCAL_NAMESPACE</a><br />
 <a href="html/libxml-parserInternals.html#XML_MAX_NAMELEN">XML_MAX_NAMELEN</a><br />
 <a href="html/libxml-xmlerror.html#XML_MODULE_CLOSE">XML_MODULE_CLOSE</a><br />
+<a href="html/libxml-xmlmodule.html#XML_MODULE_LAZY">XML_MODULE_LAZY</a><br />
+<a href="html/libxml-xmlmodule.html#XML_MODULE_LOCAL">XML_MODULE_LOCAL</a><br />
 <a href="html/libxml-xmlerror.html#XML_MODULE_OPEN">XML_MODULE_OPEN</a><br />
 <a href="html/libxml-tree.html#XML_NAMESPACE_DECL">XML_NAMESPACE_DECL</a><br />
 <a href="html/libxml-tree.html#XML_NOTATION_NODE">XML_NOTATION_NODE</a><br />
@@ -2050,6 +2052,7 @@
 <a href="html/libxml-xmlmodule.html#xmlModuleClose">xmlModuleClose</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleFree">xmlModuleFree</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
+<a href="html/libxml-xmlmodule.html#xmlModuleOption">xmlModuleOption</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a><br />
 <a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
 <a href="html/libxml-threads.html#xmlMutex">xmlMutex</a><br />
diff --git a/doc/html/libxml-xmlmodule.html b/doc/html/libxml-xmlmodule.html
index 1cb0671..b159489 100644
--- a/doc/html/libxml-xmlmodule.html
+++ b/doc/html/libxml-xmlmodule.html
@@ -12,20 +12,25 @@
       pre.programlisting {border-style: double;background: #EECFA1}
     </style><title>Module xmlmodule from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module xmlmodule from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://www.blastwave.org/packages.php/libxml2">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-xmlmemory.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-xmlmemory.html">xmlmemory</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-xmlreader.html">xmlreader</a></th><td><a accesskey="n" href="libxml-xmlreader.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>basic API for dynamic module loading, used by libexslt added in 2.6.17 </p><h2>Table of Contents</h2><pre class="programlisting">Structure <a href="#xmlModule">xmlModule</a><br />struct _xmlModule
 The content of this structure is not made public by the API.
+</pre><pre class="programlisting">Enum <a href="#xmlModuleOption">xmlModuleOption</a>
 </pre><pre class="programlisting">Typedef <a href="libxml-xmlmodule.html#xmlModule">xmlModule</a> * <a name="xmlModulePtr" id="xmlModulePtr">xmlModulePtr</a>
 </pre><pre class="programlisting">int	<a href="#xmlModuleClose">xmlModuleClose</a>			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)</pre>
 <pre class="programlisting">int	<a href="#xmlModuleFree">xmlModuleFree</a>			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)</pre>
-<pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a>	<a href="#xmlModuleOpen">xmlModuleOpen</a>		(const char * name)</pre>
+<pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a>	<a href="#xmlModuleOpen">xmlModuleOpen</a>		(const char * name, <br />					 int options)</pre>
 <pre class="programlisting">int	<a href="#xmlModuleSymbol">xmlModuleSymbol</a>			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br />					 const char * name, <br />					 void ** symbol)</pre>
 <h2>Description</h2>
 <h3><a name="xmlModule" id="xmlModule">Structure xmlModule</a></h3><pre class="programlisting">Structure xmlModule<br />struct _xmlModule {
 The content of this structure is not made public by the API.
-}</pre><h3><a name="xmlModuleClose" id="xmlModuleClose"></a>Function: xmlModuleClose</h3><pre class="programlisting">int	xmlModuleClose			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)<br />
+}</pre><h3>Enum <a name="xmlModuleOption" id="xmlModuleOption">xmlModuleOption</a></h3><pre class="programlisting">Enum xmlModuleOption {
+    <a name="XML_MODULE_LAZY" id="XML_MODULE_LAZY">XML_MODULE_LAZY</a> = 1 : lazy binding
+    <a name="XML_MODULE_LOCAL" id="XML_MODULE_LOCAL">XML_MODULE_LOCAL</a> = 2 : local binding
+}
+</pre><h3><a name="xmlModuleClose" id="xmlModuleClose"></a>Function: xmlModuleClose</h3><pre class="programlisting">int	xmlModuleClose			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)<br />
 </pre><p>The close operations unload the associated module and free the data associated to the module.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module handle</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of argument error and -2 if the module could not be closed/unloaded.</td></tr></tbody></table></div><h3><a name="xmlModuleFree" id="xmlModuleFree"></a>Function: xmlModuleFree</h3><pre class="programlisting">int	xmlModuleFree			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)<br />
 </pre><p>The free operations free the data associated to the module but does not unload the associated shared library which may still be in use.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module handle</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of argument error</td></tr></tbody></table></div><h3><a name="xmlModuleOpen" id="xmlModuleOpen"></a>Function: xmlModuleOpen</h3><pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a>	xmlModuleOpen		(const char * name)<br />
-</pre><p>Opens a module/shared library given its name or path</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the module name</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a handle for the module or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlModuleSymbol" id="xmlModuleSymbol"></a>Function: xmlModuleSymbol</h3><pre class="programlisting">int	xmlModuleSymbol			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br />					 const char * name, <br />					 void ** symbol)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module handle</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of argument error</td></tr></tbody></table></div><h3><a name="xmlModuleOpen" id="xmlModuleOpen"></a>Function: xmlModuleOpen</h3><pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a>	xmlModuleOpen		(const char * name, <br />					 int options)<br />
+</pre><p>Opens a module/shared library given its name or path TODO: options are not yet implemented.</p>
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the module name</td></tr><tr><td><span class="term"><i><tt>options</tt></i>:</span></td><td>a set of <a href="libxml-xmlmodule.html#xmlModuleOption">xmlModuleOption</a></td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a handle for the module or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlModuleSymbol" id="xmlModuleSymbol"></a>Function: xmlModuleSymbol</h3><pre class="programlisting">int	xmlModuleSymbol			(<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br />					 const char * name, <br />					 void ** symbol)<br />
 </pre><p>Lookup for a symbol address in the given module</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name of the symbol</td></tr><tr><td><span class="term"><i><tt>symbol</tt></i>:</span></td><td>the resulting symbol address</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 if the symbol was found, or -1 in case of error</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 0128b28..1a88605 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -2598,8 +2598,11 @@
      <summary>dynamic module loading</summary>
      <description>basic API for dynamic module loading, used by libexslt added in 2.6.17 </description>
      <author>Joel W. Reed </author>
+     <exports symbol='XML_MODULE_LAZY' type='enum'/>
+     <exports symbol='XML_MODULE_LOCAL' type='enum'/>
      <exports symbol='xmlModule' type='typedef'/>
      <exports symbol='xmlModulePtr' type='typedef'/>
+     <exports symbol='xmlModuleOption' type='typedef'/>
      <exports symbol='xmlModuleFree' type='function'/>
      <exports symbol='xmlModuleSymbol' type='function'/>
      <exports symbol='xmlModuleOpen' type='function'/>
@@ -4616,6 +4619,8 @@
     <enum name='XML_IO_UNKNOWN' file='xmlerror' value='1500' type='xmlParserErrors'/>
     <enum name='XML_IO_WRITE' file='xmlerror' value='1546' type='xmlParserErrors' info='1546'/>
     <enum name='XML_MODULE_CLOSE' file='xmlerror' value='4901' type='xmlParserErrors' info='4901'/>
+    <enum name='XML_MODULE_LAZY' file='xmlmodule' value='1' type='xmlModuleOption' info='lazy binding'/>
+    <enum name='XML_MODULE_LOCAL' file='xmlmodule' value='2' type='xmlModuleOption' info=' local binding'/>
     <enum name='XML_MODULE_OPEN' file='xmlerror' value='4900' type='xmlParserErrors' info='4900'/>
     <enum name='XML_NAMESPACE_DECL' file='tree' value='18' type='xmlElementType'/>
     <enum name='XML_NOTATION_NODE' file='tree' value='12' type='xmlElementType'/>
@@ -5662,6 +5667,7 @@
     </struct>
     <typedef name='xmlLocationSetPtr' file='xpointer' type='xmlLocationSet *'/>
     <struct name='xmlModule' file='xmlmodule' type='struct _xmlModule'/>
+    <typedef name='xmlModuleOption' file='xmlmodule' type='enum'/>
     <typedef name='xmlModulePtr' file='xmlmodule' type='xmlModule *'/>
     <struct name='xmlMutex' file='threads' type='struct _xmlMutex'/>
     <typedef name='xmlMutexPtr' file='threads' type='xmlMutex *'/>
@@ -10070,9 +10076,10 @@
     </function>
     <function name='xmlModuleOpen' file='xmlmodule'>
       <cond>defined(LIBXML_MODULES_ENABLED)</cond>
-      <info>Opens a module/shared library given its name or path</info>
+      <info>Opens a module/shared library given its name or path TODO: options are not yet implemented.</info>
       <return type='xmlModulePtr' info='a handle for the module or NULL in case of error'/>
       <arg name='name' type='const char *' info='the module name'/>
+      <arg name='options' type='int' info='a set of xmlModuleOption'/>
     </function>
     <function name='xmlModuleSymbol' file='xmlmodule'>
       <cond>defined(LIBXML_MODULES_ENABLED)</cond>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index 7306aee..6ae7024 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -492,6 +492,8 @@
     <reference name='XML_LOCAL_NAMESPACE' href='html/libxml-tree.html#XML_LOCAL_NAMESPACE'/>
     <reference name='XML_MAX_NAMELEN' href='html/libxml-parserInternals.html#XML_MAX_NAMELEN'/>
     <reference name='XML_MODULE_CLOSE' href='html/libxml-xmlerror.html#XML_MODULE_CLOSE'/>
+    <reference name='XML_MODULE_LAZY' href='html/libxml-xmlmodule.html#XML_MODULE_LAZY'/>
+    <reference name='XML_MODULE_LOCAL' href='html/libxml-xmlmodule.html#XML_MODULE_LOCAL'/>
     <reference name='XML_MODULE_OPEN' href='html/libxml-xmlerror.html#XML_MODULE_OPEN'/>
     <reference name='XML_NAMESPACE_DECL' href='html/libxml-tree.html#XML_NAMESPACE_DECL'/>
     <reference name='XML_NOTATION_NODE' href='html/libxml-tree.html#XML_NOTATION_NODE'/>
@@ -2044,6 +2046,7 @@
     <reference name='xmlModuleClose' href='html/libxml-xmlmodule.html#xmlModuleClose'/>
     <reference name='xmlModuleFree' href='html/libxml-xmlmodule.html#xmlModuleFree'/>
     <reference name='xmlModuleOpen' href='html/libxml-xmlmodule.html#xmlModuleOpen'/>
+    <reference name='xmlModuleOption' href='html/libxml-xmlmodule.html#xmlModuleOption'/>
     <reference name='xmlModulePtr' href='html/libxml-xmlmodule.html#xmlModulePtr'/>
     <reference name='xmlModuleSymbol' href='html/libxml-xmlmodule.html#xmlModuleSymbol'/>
     <reference name='xmlMutex' href='html/libxml-threads.html#xmlMutex'/>
@@ -3764,6 +3767,8 @@
       <ref name='XML_LOCAL_NAMESPACE'/>
       <ref name='XML_MAX_NAMELEN'/>
       <ref name='XML_MODULE_CLOSE'/>
+      <ref name='XML_MODULE_LAZY'/>
+      <ref name='XML_MODULE_LOCAL'/>
       <ref name='XML_MODULE_OPEN'/>
       <ref name='XML_NAMESPACE_DECL'/>
       <ref name='XML_NOTATION_NODE'/>
@@ -5352,6 +5357,7 @@
       <ref name='xmlModuleClose'/>
       <ref name='xmlModuleFree'/>
       <ref name='xmlModuleOpen'/>
+      <ref name='xmlModuleOption'/>
       <ref name='xmlModulePtr'/>
       <ref name='xmlModuleSymbol'/>
       <ref name='xmlMutex'/>
@@ -12261,10 +12267,13 @@
       <ref name='xmlStrdupFunc'/>
     </file>
     <file name='xmlmodule'>
+      <ref name='XML_MODULE_LAZY'/>
+      <ref name='XML_MODULE_LOCAL'/>
       <ref name='xmlModule'/>
       <ref name='xmlModuleClose'/>
       <ref name='xmlModuleFree'/>
       <ref name='xmlModuleOpen'/>
+      <ref name='xmlModuleOption'/>
       <ref name='xmlModulePtr'/>
       <ref name='xmlModuleSymbol'/>
     </file>
@@ -16575,6 +16584,7 @@
           <ref name='xmlDecodeEntities'/>
           <ref name='xmlEncodeEntities'/>
           <ref name='xmlLoadExternalEntity'/>
+          <ref name='xmlModuleOpen'/>
           <ref name='xmlNamespaceParseNCName'/>
           <ref name='xmlNamespaceParseNSDef'/>
           <ref name='xmlNamespaceParseQName'/>
@@ -21776,6 +21786,7 @@
           <ref name='HTML_PI_NODE'/>
           <ref name='HTML_PRESERVE_NODE'/>
           <ref name='HTML_TEXT_NODE'/>
+          <ref name='xmlModuleOpen'/>
           <ref name='xmlSaveDoc'/>
           <ref name='xmlSaveTree'/>
           <ref name='xmlTextReaderNextSibling'/>
@@ -23941,6 +23952,7 @@
         <word name='options'>
           <ref name='htmlCtxtUseOptions'/>
           <ref name='xmlCtxtUseOptions'/>
+          <ref name='xmlModuleOpen'/>
           <ref name='xmlSaveToFd'/>
           <ref name='xmlSaveToFilename'/>
           <ref name='xmlSaveToIO'/>
@@ -28437,6 +28449,9 @@
         <word name='xmlLockLibrary'>
           <ref name='xmlLockLibrary'/>
         </word>
+        <word name='xmlModuleOption'>
+          <ref name='xmlModuleOpen'/>
+        </word>
         <word name='xmlMutexLock'>
           <ref name='xmlMutexLock'/>
         </word>
@@ -28953,6 +28968,7 @@
           <ref name='xmlTextWriterStartDocument'/>
         </word>
         <word name='yet'>
+          <ref name='xmlModuleOpen'/>
           <ref name='xmlPatterncompile'/>
           <ref name='xmlSaveDoc'/>
           <ref name='xmlSaveTree'/>
diff --git a/include/libxml/xmlmodule.h b/include/libxml/xmlmodule.h
index b0e398f..8f4a560 100644
--- a/include/libxml/xmlmodule.h
+++ b/include/libxml/xmlmodule.h
@@ -27,21 +27,26 @@
 typedef struct _xmlModule xmlModule;
 typedef xmlModule *xmlModulePtr;
 
-#ifdef __cplusplus
-}
-#endif 
+/**
+ * xmlModuleOption:
+ *
+ * enumeration of options that can be passed down to xmlModuleOpen()
+ */
+typedef enum {
+    XML_MODULE_LAZY = 1,	/* lazy binding */
+    XML_MODULE_LOCAL= 2		/* local binding */
+} xmlModuleOption;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen	(const char *filename,
+						 int options);
 
-XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen	(const char *filename);
+XMLPUBFUN int XMLCALL xmlModuleSymbol		(xmlModulePtr module,
+						 const char* name,
+						 void **result);
 
-XMLPUBFUN int XMLCALL xmlModuleSymbol	(xmlModulePtr module, const char* name, void **result);
+XMLPUBFUN int XMLCALL xmlModuleClose		(xmlModulePtr module);
 
-XMLPUBFUN int XMLCALL xmlModuleClose	(xmlModulePtr module);
-
-XMLPUBFUN int XMLCALL xmlModuleFree	(xmlModulePtr module);
+XMLPUBFUN int XMLCALL xmlModuleFree		(xmlModulePtr module);
 
 #ifdef __cplusplus
 }
diff --git a/parser.c b/parser.c
index 6ee9159..02ccdb1 100644
--- a/parser.c
+++ b/parser.c
@@ -9256,6 +9256,8 @@
 			    (!ctxt->disableSAX))
 			    ctxt->sax->endElementNs(ctxt->userData, name,
 			                            prefix, URI);
+			if (ctxt->nsNr - nsNr > 0)
+			    nsPop(ctxt, ctxt->nsNr - nsNr);
 #ifdef LIBXML_SAX1_ENABLED
 		    } else {
 			if ((ctxt->sax != NULL) &&
diff --git a/result/noent/ns6 b/result/noent/ns6
new file mode 100644
index 0000000..c971252
--- /dev/null
+++ b/result/noent/ns6
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<root>
+  <foo xmlns="http://abc"/>
+  <bar/>
+</root>
diff --git a/result/ns6 b/result/ns6
new file mode 100644
index 0000000..c971252
--- /dev/null
+++ b/result/ns6
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<root>
+  <foo xmlns="http://abc"/>
+  <bar/>
+</root>
diff --git a/result/ns6.rde b/result/ns6.rde
new file mode 100644
index 0000000..23a80ec
--- /dev/null
+++ b/result/ns6.rde
@@ -0,0 +1,10 @@
+0 1 root 0 0
+1 14 #text 0 1 
+  
+1 1 foo 1 0
+1 14 #text 0 1 
+  
+1 1 bar 1 0
+1 14 #text 0 1 
+
+0 15 root 0 0
diff --git a/result/ns6.rdr b/result/ns6.rdr
new file mode 100644
index 0000000..23a80ec
--- /dev/null
+++ b/result/ns6.rdr
@@ -0,0 +1,10 @@
+0 1 root 0 0
+1 14 #text 0 1 
+  
+1 1 foo 1 0
+1 14 #text 0 1 
+  
+1 1 bar 1 0
+1 14 #text 0 1 
+
+0 15 root 0 0
diff --git a/result/ns6.sax b/result/ns6.sax
new file mode 100644
index 0000000..a1405b1
--- /dev/null
+++ b/result/ns6.sax
@@ -0,0 +1,15 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.startElement(root)
+SAX.characters(
+  , 3)
+SAX.startElement(foo, xmlns='http://abc')
+SAX.endElement(foo)
+SAX.characters(
+  , 3)
+SAX.startElement(bar)
+SAX.endElement(bar)
+SAX.characters(
+, 1)
+SAX.endElement(root)
+SAX.endDocument()
diff --git a/test/ns6 b/test/ns6
new file mode 100644
index 0000000..1f2a8b3
--- /dev/null
+++ b/test/ns6
@@ -0,0 +1,4 @@
+<root>
+  <foo xmlns="http://abc" />
+  <bar />
+</root>
diff --git a/testModule.c b/testModule.c
index a878e03..f245829 100644
--- a/testModule.c
+++ b/testModule.c
@@ -27,7 +27,7 @@
 #define MODULE_PATH ".libs"
 #endif
 
-typedef int (*hello_world_t)();
+typedef int (*hello_world_t)(void);
  
 int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     xmlChar filename[PATH_MAX];
@@ -35,11 +35,12 @@
     hello_world_t hello_world = NULL;
 
     /* build the module filename, and confirm the module exists */
-    xmlStrPrintf(filename, sizeof(filename), "%s/testdso%s",
+    xmlStrPrintf(filename, sizeof(filename),
+                 (const xmlChar*) "%s/testdso%s",
                  (const xmlChar*)MODULE_PATH,
 		 (const xmlChar*)LIBXML_MODULE_EXTENSION);
 
-    module = xmlModuleOpen((const char*)filename);
+    module = xmlModuleOpen((const char*)filename, 0);
     if (module)
       {
         if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
diff --git a/xmlmodule.c b/xmlmodule.c
index e1c351a..318497b 100644
--- a/xmlmodule.c
+++ b/xmlmodule.c
@@ -58,13 +58,15 @@
 /**
  * xmlModuleOpen:
  * @name: the module name
+ * @options: a set of xmlModuleOption
  *
  * Opens a module/shared library given its name or path
+ * TODO: options are not yet implemented.
  *
  * Returns a handle for the module or NULL in case of error
  */
 xmlModulePtr
-xmlModuleOpen(const char *name)
+xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED)
 {
     xmlModulePtr module;