added new APIs for creating reader from sources or reusing a reader with a

* xmlreader.c include/libxml/xmlreader.h: added new APIs
  for creating reader from sources or reusing a reader with
  a new source, like the xmlReadxx and xmlCtxtReadxxx
* win32/libxml2.def.src doc/libxml2-api.xml doc/apibuild.py
  doc/Makefile.am: regenerated the APIs
* doc/xml.html: applied a patch from Stefan Kost for namesapce docs
Daniel
diff --git a/doc/Makefile.am b/doc/Makefile.am
index d018f39..7aef77d 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -60,7 +60,7 @@
 	-@(xsltproc --nonet xmlcatalog_man.xml)
 
 scan:
-	-gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h win32config.h trio.h triostr.h triop.h config-mac.h XMLTestPrefix2.h  XMLTestPrefix.h triodef.h trionan.h xlink.h libxml.h libxml2-py.h libxml_wrap.h"
+	-gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h win32config.h trio.h triostr.h triop.h config-mac.h XMLTestPrefix2.h  XMLTestPrefix.h triodef.h trionan.h xlink.h libxml.h libxml2-py.h libxml_wrap.h chvalid.h"
 
 templates: scan
 	-gtkdoc-mktmpl --module=libxml
diff --git a/doc/apibuild.py b/doc/apibuild.py
index 59cc0cf..ce2f738 100755
--- a/doc/apibuild.py
+++ b/doc/apibuild.py
@@ -25,6 +25,9 @@
   "testOOM.c": "out of memory tester",
   "testOOMlib.h": "out of memory tester",
   "testOOMlib.c": "out of memory tester",
+  "chvalid.h":  "internal only + parsing problems",
+  "pattern.c": "not integrated yet",
+  "pattern.h": "not integrated yet",
 }
 
 ignored_words = {
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 4cfee68..1effbc0 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -140,15 +140,7 @@
      <exports symbol='xmlErrMemory'/>
      <exports symbol='xmlFreeInputStream'/>
      <exports symbol='xmlHandleEntity'/>
-     <exports symbol='xmlIsBaseChar'/>
-     <exports symbol='xmlIsBlank'/>
-     <exports symbol='xmlIsChar'/>
-     <exports symbol='xmlIsCombining'/>
-     <exports symbol='xmlIsDigit'/>
-     <exports symbol='xmlIsExtender'/>
-     <exports symbol='xmlIsIdeographic'/>
      <exports symbol='xmlIsLetter'/>
-     <exports symbol='xmlIsPubidChar'/>
      <exports symbol='xmlNamespaceParseNCName'/>
      <exports symbol='xmlNamespaceParseNSDef'/>
      <exports symbol='xmlNamespaceParseQName'/>
@@ -206,6 +198,7 @@
      <exports symbol='xmlParserHandlePEReference'/>
      <exports symbol='xmlParserHandleReference'/>
      <exports symbol='xmlParserInputShrink'/>
+     <exports symbol='xmlParserMaxDepth'/>
      <exports symbol='xmlPopInput'/>
      <exports symbol='xmlPushInput'/>
      <exports symbol='xmlScanName'/>
@@ -1385,6 +1378,16 @@
      <exports symbol='xmlNewTextReaderFilename'/>
      <exports symbol='xmlParserProperties'/>
      <exports symbol='xmlParserSeverities'/>
+     <exports symbol='xmlReaderForDoc'/>
+     <exports symbol='xmlReaderForFd'/>
+     <exports symbol='xmlReaderForFile'/>
+     <exports symbol='xmlReaderForIO'/>
+     <exports symbol='xmlReaderForMemory'/>
+     <exports symbol='xmlReaderNewDoc'/>
+     <exports symbol='xmlReaderNewFd'/>
+     <exports symbol='xmlReaderNewFile'/>
+     <exports symbol='xmlReaderNewIO'/>
+     <exports symbol='xmlReaderNewMemory'/>
      <exports symbol='xmlReaderTypes'/>
      <exports symbol='xmlTextReader'/>
      <exports symbol='xmlTextReaderAttributeCount'/>
@@ -4911,6 +4914,7 @@
     <variable name='xmlMallocAtomic' file='globals' type='xmlMallocFunc'/>
     <variable name='xmlMemStrdup' file='globals' type='xmlStrdupFunc'/>
     <variable name='xmlParserDebugEntities' file='globals' type='int'/>
+    <variable name='xmlParserMaxDepth' file='parserInternals' type='unsigned int'/>
     <variable name='xmlParserVersion' file='globals' type='const char *'/>
     <variable name='xmlPedanticParserDefaultValue' file='globals' type='int'/>
     <variable name='xmlRealloc' file='globals' type='xmlReallocFunc'/>
@@ -8053,41 +8057,11 @@
       <arg name='buffer' type='char *' info='the buffer to store data read'/>
       <arg name='len' type='int' info='the length of the buffer in bytes'/>
     </functype>
-    <function name='xmlIsBaseChar' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [85] BaseChar ::= ... long list see REC ...  VI is your friend ! :1,$ s/\[#x\([0-9A-Z]*\)-#x\([0-9A-Z]*\)\]/     (((c) &gt;= 0x\1) \&amp;\&amp; ((c) &lt;= 0x\2)) ||/ and :1,$ s/#x\([0-9A-Z]*\)/     ((c) == 0x\1) ||/</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
-    <function name='xmlIsBlank' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [3] S ::= (#x20 | #x9 | #xD | #xA)+ Also available as a macro IS_BLANK()</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
     <function name='xmlIsBlankNode' file='tree'>
       <info>Checks whether this node is an empty or whitespace only (and possibly ignorable) text-node.</info>
       <return type='int' info='1 yes, 0 no'/>
       <arg name='node' type='xmlNodePtr' info='the node'/>
     </function>
-    <function name='xmlIsChar' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. Also available as a macro IS_CHAR()</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
-    <function name='xmlIsCombining' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [87] CombiningChar ::= ... long list see REC ...</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
-    <function name='xmlIsDigit' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [88] Digit ::= ... long list see REC ...</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
-    <function name='xmlIsExtender' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
     <function name='xmlIsID' file='valid'>
       <info>Determine whether an attribute is of type ID. In case we have DTD(s) then this is done if DTD loading has been requested. In the case of HTML documents parsed with the HTML parser, then ID detection is done systematically.</info>
       <return type='int' info='0 or 1 depending on the lookup result'/>
@@ -8095,11 +8069,6 @@
       <arg name='elem' type='xmlNodePtr' info='the element carrying the attribute'/>
       <arg name='attr' type='xmlAttrPtr' info='the attribute'/>
     </function>
-    <function name='xmlIsIdeographic' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
     <function name='xmlIsLetter' file='parserInternals'>
       <info>Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic</info>
       <return type='int' info='0 if not, non-zero otherwise'/>
@@ -8115,11 +8084,6 @@
       <arg name='doc' type='xmlDocPtr' info='the document'/>
       <arg name='name' type='const xmlChar *' info='the element name'/>
     </function>
-    <function name='xmlIsPubidChar' file='parserInternals'>
-      <info>Check whether the character is allowed by the production [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-&apos;()+,./:=?;!*#@$_%]</info>
-      <return type='int' info='0 if not, non-zero otherwise'/>
-      <arg name='c' type='int' info='an unicode character (int)'/>
-    </function>
     <function name='xmlIsRef' file='valid'>
       <info>Determine whether an attribute is of type Ref. In case we have DTD(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase).</info>
       <return type='int' info='0 or 1 depending on the lookup result'/>
@@ -9700,6 +9664,95 @@
       <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
       <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
     </function>
+    <function name='xmlReaderForDoc' file='xmlreader'>
+      <info>Create an xmltextReader for an XML in-memory document.</info>
+      <return type='xmlTextReaderPtr' info='the new reader or NULL in case of error.'/>
+      <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderForFd' file='xmlreader'>
+      <info>Create an xmltextReader for an XML from a file descriptor.</info>
+      <return type='xmlTextReaderPtr' info='the new reader or NULL in case of error.'/>
+      <arg name='fd' type='int' info='an open file descriptor'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderForFile' file='xmlreader'>
+      <info>parse an XML file from the filesystem or the network.</info>
+      <return type='xmlTextReaderPtr' info='the new reader or NULL in case of error.'/>
+      <arg name='filename' type='const char *' info='a file or URL'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderForIO' file='xmlreader'>
+      <info>Create an xmltextReader for an XML document from I/O functions and source.</info>
+      <return type='xmlTextReaderPtr' info='the new reader or NULL in case of error.'/>
+      <arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
+      <arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
+      <arg name='ioctx' type='void *' info='an I/O handler'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderForMemory' file='xmlreader'>
+      <info>Create an xmltextReader for an XML in-memory document.</info>
+      <return type='xmlTextReaderPtr' info='the new reader or NULL in case of error.'/>
+      <arg name='buffer' type='const char *' info='a pointer to a char array'/>
+      <arg name='size' type='int' info='the size of the array'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderNewDoc' file='xmlreader'>
+      <info>Setup an xmltextReader to parse an XML in-memory document. This reuses the existing @reader xmlTextReader.</info>
+      <return type='int' info='0 in case of success and -1 in case of error'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderNewFd' file='xmlreader'>
+      <info>Setup an xmltextReader to parse an XML from a file descriptor. This reuses the existing @reader xmlTextReader.</info>
+      <return type='int' info='0 in case of success and -1 in case of error'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='fd' type='int' info='an open file descriptor'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderNewFile' file='xmlreader'>
+      <info>parse an XML file from the filesystem or the network. This reuses the existing @reader xmlTextReader.</info>
+      <return type='int' info='0 in case of success and -1 in case of error'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='filename' type='const char *' info='a file or URL'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderNewIO' file='xmlreader'>
+      <info>Setup an xmltextReader to parse an XML document from I/O functions and source. This reuses the existing @reader xmlTextReader.</info>
+      <return type='int' info='0 in case of success and -1 in case of error'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
+      <arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
+      <arg name='ioctx' type='void *' info='an I/O handler'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
+    <function name='xmlReaderNewMemory' file='xmlreader'>
+      <info>Setup an xmltextReader to parse an XML in-memory document. This reuses the existing @reader xmlTextReader.</info>
+      <return type='int' info='0 in case of success and -1 in case of error'/>
+      <arg name='reader' type='xmlTextReaderPtr' info='an XML reader'/>
+      <arg name='buffer' type='const char *' info='a pointer to a char array'/>
+      <arg name='size' type='int' info='the size of the array'/>
+      <arg name='URL' type='const char *' info='the base URL to use for the document'/>
+      <arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
+      <arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
+    </function>
     <functype name='xmlReallocFunc' file='xmlmemory'>
       <info>Signature for a realloc() implementation.</info>
       <return type='void *' info='a pointer to the newly reallocated block or NULL in case of error.'/>
diff --git a/doc/namespaces.html b/doc/namespaces.html
index d50f10b..6f15c5f 100644
--- a/doc/namespaces.html
+++ b/doc/namespaces.html
@@ -34,12 +34,21 @@
 associated with the element or the attribute, not the prefix string (which is
 just a shortcut for the full URI). In libxml, element and attributes have an
 <code>ns</code> field pointing to an xmlNs structure detailing the namespace
-prefix and its URI.</p><p>@@Interfaces@@</p><p>@@Examples@@</p><p>Usually people object to using namespaces together with validity checking.
+prefix and its URI.</p><p>@@Interfaces@@</p><pre>
+xmlNodePtr node;
+if(!strncmp(node-&gt;name,&quot;mytag&quot;,5)
+  &amp;&amp; node-&gt;ns
+  &amp;&amp; !strcmp(node-&gt;ns-&gt;href,&quot;http://www.mysite.com/myns/1.0&quot;)) {
+  ...
+}
+</pre><p>Usually people object to using namespaces together with validity checking.
 I will try to make sure that using namespaces won't break validity checking,
 so even if you plan to use or currently are using validation I strongly
 suggest adding namespaces to your document. A default namespace scheme
 <code>xmlns=&quot;http://....&quot;</code> should not break validity even on less
 flexible parsers. Using namespaces to mix and differentiate content coming
-from multiple DTDs will certainly break current validation schemes. I will
-try to provide ways to do this, but this may not be portable or
-standardized.</p><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>
+from multiple DTDs will certainly break current validation schemes.
+To check such documents one needs to use schema-validation, which is supported
+in libxml2 as well. See <a href="http://www.relaxng.org/">relagx-ng</a> and
+<a href="http://www.w3c.org/XML/Schema">w3c-schema</a>.
+</p><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/upgrade.html b/doc/upgrade.html
index 335e9bc..8196a48 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -23,7 +23,7 @@
 </ul><h3>How to fix libxml-1.x code:</h3><p>So client code of libxml designed to run with version 1.x may have to be
 changed to compile against version 2.x of libxml. Here is a list of changes
 that I have collected, they may not be sufficient, so in case you find other
-change which are required, <a href="mailto:Daniel.Ïeillardw3.org">drop me a
+change which are required, <a href="mailto:Daniel.Veillard@w3.org">drop me a
 mail</a>:</p><ol><li>The package name have changed from libxml to libxml2, the library name
     is now -lxml2 . There is a new xml2-config script which should be used to
     select the right parameters libxml2</li>
diff --git a/doc/xml.html b/doc/xml.html
index d72d4b9..f7fcdaa 100644
--- a/doc/xml.html
+++ b/doc/xml.html
@@ -3758,7 +3758,14 @@
 
 <p>@@Interfaces@@</p>
 
-<p>@@Examples@@</p>
+<pre>
+xmlNodePtr node;
+if(!strncmp(node-&gt;name,"mytag",5)
+  &amp;&amp; node-&gt;ns
+  &amp;&amp; !strcmp(node-&gt;ns-&gt;href,"http://www.mysite.com/myns/1.0")) {
+  ...
+}
+</pre>
 
 <p>Usually people object to using namespaces together with validity checking.
 I will try to make sure that using namespaces won't break validity checking,
@@ -3766,9 +3773,11 @@
 suggest adding namespaces to your document. A default namespace scheme
 <code>xmlns="http://...."</code> should not break validity even on less
 flexible parsers. Using namespaces to mix and differentiate content coming
-from multiple DTDs will certainly break current validation schemes. I will
-try to provide ways to do this, but this may not be portable or
-standardized.</p>
+from multiple DTDs will certainly break current validation schemes.
+To check such documents one needs to use schema-validation, which is supported
+in libxml2 as well. See <a href="http://www.relaxng.org/">relagx-ng</a> and
+<a href="http://www.w3c.org/XML/Schema">w3c-schema</a>.
+</p>
 
 <h2><a name="Upgrading">Upgrading 1.x code</a></h2>
 
@@ -3796,7 +3805,7 @@
 <p>So client code of libxml designed to run with version 1.x may have to be
 changed to compile against version 2.x of libxml. Here is a list of changes
 that I have collected, they may not be sufficient, so in case you find other
-change which are required, <a href="mailto:Daniel.Ïeillardw3.org">drop me a
+change which are required, <a href="mailto:Daniel.Veillard@w3.org">drop me a
 mail</a>:</p>
 <ol>
   <li>The package name have changed from libxml to libxml2, the library name