fixed a bug where the principal node type of an axis wasn't tested on name

* xpath.c: fixed a bug where the principal node type of an axis
  wasn't tested on name check, fixes bug #377432
daniel
diff --git a/ChangeLog b/ChangeLog
index f1f9516..71be392 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Nov 23 17:11:23 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+	* xpath.c: fixed a bug where the principal node type of an axis
+	  wasn't tested on name check, fixes bug #377432
+
 Wed Nov  8 10:19:27 CET 2006 Daniel Veillard <daniel@veillard.com>
 
 	* HTMLparser.c: change htmlCtxtReset() following Michael Day bug
diff --git a/doc/APIchunk1.html b/doc/APIchunk1.html
index a222fe0..f17f1af 100644
--- a/doc/APIchunk1.html
+++ b/doc/APIchunk1.html
@@ -49,6 +49,8 @@
 <a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseAttValue">xmlParseAttValue</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseAttributeType">xmlParseAttributeType</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseCDSect">xmlParseCDSect</a><br />
diff --git a/doc/APIchunk10.html b/doc/APIchunk10.html
index 432eb31..c55e04a 100644
--- a/doc/APIchunk10.html
+++ b/doc/APIchunk10.html
@@ -331,6 +331,8 @@
 <a href="html/libxml-xmlautomata.html#xmlAutomataNewAllTrans">xmlAutomataNewAllTrans</a><br />
 <a href="html/libxml-xmlautomata.html#xmlAutomataNewCounterTrans">xmlAutomataNewCounterTrans</a><br />
 <a href="html/libxml-parserInternals.html#xmlIsLetter">xmlIsLetter</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 <a href="html/libxml-tree.html#xmlNodeDump">xmlNodeDump</a><br />
 <a href="html/libxml-tree.html#xmlNodeDumpOutput">xmlNodeDumpOutput</a><br />
 <a href="html/libxml-parser.html#xmlParseBalancedChunkMemory">xmlParseBalancedChunkMemory</a><br />
@@ -345,6 +347,8 @@
 <a href="html/libxml-HTMLparser.html#htmlIsAutoClosed">htmlIsAutoClosed</a><br />
 <a href="html/libxml-catalog.html#xmlCatalogAdd">xmlCatalogAdd</a><br />
 <a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-uri.html#xmlParseURIRaw">xmlParseURIRaw</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderConstString">xmlTextReaderConstString</a><br />
 </dd><dt>already</dt><dd><a href="html/libxml-schemasInternals.html#XML_SCHEMAS_ATTRGROUP_GLOBAL">XML_SCHEMAS_ATTRGROUP_GLOBAL</a><br />
diff --git a/doc/APIchunk12.html b/doc/APIchunk12.html
index b036fc8..b8a01b1 100644
--- a/doc/APIchunk12.html
+++ b/doc/APIchunk12.html
@@ -689,6 +689,8 @@
 </dd><dt>contraint</dt><dd><a href="html/libxml-schemasInternals.html#_xmlSchemaElement">_xmlSchemaElement</a><br />
 </dd><dt>contrary</dt><dd><a href="html/libxml-tree.html#xmlNodeListGetRawString">xmlNodeListGetRawString</a><br />
 <a href="html/libxml-xpath.html#xmlXPathFreeNodeSetList">xmlXPathFreeNodeSetList</a><br />
+</dd><dt>contrast</dt><dd><a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 </dd><dt>control</dt><dd><a href="html/libxml-xpath.html#_xmlXPathContext">_xmlXPathContext</a><br />
 <a href="html/libxml-SAX.html#resolveEntity">resolveEntity</a><br />
 <a href="html/libxml-parser.html#resolveEntitySAXFunc">resolveEntitySAXFunc</a><br />
diff --git a/doc/APIchunk14.html b/doc/APIchunk14.html
index dfe748d..77106c1 100644
--- a/doc/APIchunk14.html
+++ b/doc/APIchunk14.html
@@ -273,6 +273,8 @@
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
 <a href="html/libxml-tree.html#xmlNewTextChild">xmlNewTextChild</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseCDSect">xmlParseCDSect</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseCharData">xmlParseCharData</a><br />
 <a href="html/libxml-uri.html#xmlSaveUri">xmlSaveUri</a><br />
diff --git a/doc/APIchunk20.html b/doc/APIchunk20.html
index 2a9174d..97a8fc6 100644
--- a/doc/APIchunk20.html
+++ b/doc/APIchunk20.html
@@ -100,6 +100,8 @@
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
 <a href="html/libxml-tree.html#xmlNewTextChild">xmlNewTextChild</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseEntityRef">xmlParseEntityRef</a><br />
 <a href="html/libxml-parserInternals.html#xmlParserHandleReference">xmlParserHandleReference</a><br />
 <a href="html/libxml-xmlregexp.html#xmlRegExecErrInfo">xmlRegExecErrInfo</a><br />
diff --git a/doc/APIchunk22.html b/doc/APIchunk22.html
index bd256cb..f823421 100644
--- a/doc/APIchunk22.html
+++ b/doc/APIchunk22.html
@@ -162,6 +162,8 @@
 </dd><dt>piece</dt><dd><a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 </dd><dt>pieces</dt><dd><a href="html/libxml-uri.html#xmlParseURIRaw">xmlParseURIRaw</a><br />
 </dd><dt>place</dt><dd><a href="html/libxml-catalog.html#xmlCatalogAdd">xmlCatalogAdd</a><br />
 <a href="html/libxml-xmlerror.html#xmlCopyError">xmlCopyError</a><br />
diff --git a/doc/APIchunk23.html b/doc/APIchunk23.html
index effe8f5..91b1835 100644
--- a/doc/APIchunk23.html
+++ b/doc/APIchunk23.html
@@ -101,6 +101,8 @@
 <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 />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseCDSect">xmlParseCDSect</a><br />
 <a href="html/libxml-xmlIO.html#xmlParserInputBufferGrow">xmlParserInputBufferGrow</a><br />
 <a href="html/libxml-xmlwriter.html#xmlTextWriterWriteFormatRaw">xmlTextWriterWriteFormatRaw</a><br />
@@ -246,8 +248,12 @@
 <a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 <a href="html/libxml-tree.html#xmlNodeBufGetContent">xmlNodeBufGetContent</a><br />
 <a href="html/libxml-tree.html#xmlNodeGetContent">xmlNodeGetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseAttribute">xmlParseAttribute</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseCharRef">xmlParseCharRef</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseEntityRef">xmlParseEntityRef</a><br />
@@ -512,6 +518,8 @@
 <a href="html/libxml-schematron.html#xmlSchematronFreeValidCtxt">xmlSchematronFreeValidCtxt</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderClose">xmlTextReaderClose</a><br />
 <a href="html/libxml-xinclude.html#xmlXIncludeSetFlags">xmlXIncludeSetFlags</a><br />
+</dd><dt>resp</dt><dd><a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 </dd><dt>respect</dt><dd><a href="html/libxml-xmlregexp.html#xmlExpStringDerive">xmlExpStringDerive</a><br />
 </dd><dt>respecting</dt><dd><a href="html/libxml-valid.html#xmlValidGetValidElements">xmlValidGetValidElements</a><br />
 </dd><dt>response</dt><dd><a href="html/libxml-nanoftp.html#xmlNanoFTPCheckResponse">xmlNanoFTPCheckResponse</a><br />
diff --git a/doc/APIchunk24.html b/doc/APIchunk24.html
index b737b67..45da6ff 100644
--- a/doc/APIchunk24.html
+++ b/doc/APIchunk24.html
@@ -493,6 +493,10 @@
 <a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-xmlwriter.html#xmlTextWriterWriteRawLen">xmlTextWriterWriteRawLen</a><br />
 </dd><dt>specialized</dt><dd><a href="html/libxml-tree.html#_xmlDOMWrapCtxt">_xmlDOMWrapCtxt</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
@@ -859,6 +863,8 @@
 <a href="html/libxml-tree.html#xmlDOMWrapRemoveNode">xmlDOMWrapRemoveNode</a><br />
 <a href="html/libxml-encoding.html#xmlInitCharEncodingHandlers">xmlInitCharEncodingHandlers</a><br />
 <a href="html/libxml-nanoftp.html#xmlNanoFTPGetConnection">xmlNanoFTPGetConnection</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 <a href="html/libxml-xmlschemastypes.html#xmlSchemaGetCanonValue">xmlSchemaGetCanonValue</a><br />
 <a href="html/libxml-xmlschemastypes.html#xmlSchemaGetCanonValueWhtsp">xmlSchemaGetCanonValueWhtsp</a><br />
 <a href="html/libxml-xmlreader.html#xmlTextReaderNormalization">xmlTextReaderNormalization</a><br />
@@ -866,6 +872,10 @@
 <a href="html/libxml-tree.html#xmlNewChild">xmlNewChild</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNode">xmlNewDocNode</a><br />
 <a href="html/libxml-tree.html#xmlNewDocNodeEatName">xmlNewDocNodeEatName</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrcat">xmlStrcat</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrdup">xmlStrdup</a><br />
 </dd><dt>sure</dt><dd><a href="html/libxml-xmlsave.html#xmlSaveClose">xmlSaveClose</a><br />
diff --git a/doc/APIchunk26.html b/doc/APIchunk26.html
index 828659a..5606555 100644
--- a/doc/APIchunk26.html
+++ b/doc/APIchunk26.html
@@ -58,6 +58,8 @@
 </dd><dt>understand</dt><dd><a href="html/libxml-xmlregexp.html#xmlExpParse">xmlExpParse</a><br />
 </dd><dt>unescape</dt><dd><a href="html/libxml-uri.html#xmlURIUnescapeString">xmlURIUnescapeString</a><br />
 </dd><dt>unescaped</dt><dd><a href="html/libxml-xmlIO.html#xmlFileOpen">xmlFileOpen</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
 <a href="html/libxml-uri.html#xmlURIUnescapeString">xmlURIUnescapeString</a><br />
 </dd><dt>unescaping</dt><dd><a href="html/libxml-uri.html#xmlParseURIRaw">xmlParseURIRaw</a><br />
 </dd><dt>unicode</dt><dd><a href="html/libxml-HTMLparser.html#htmlEntityValueLookup">htmlEntityValueLookup</a><br />
diff --git a/doc/APIchunk4.html b/doc/APIchunk4.html
index b3c8364..4b74048 100644
--- a/doc/APIchunk4.html
+++ b/doc/APIchunk4.html
@@ -211,6 +211,10 @@
 <a href="html/libxml-tree.html#xmlNewTextChild">xmlNewTextChild</a><br />
 <a href="html/libxml-xmlwriter.html#xmlNewTextWriter">xmlNewTextWriter</a><br />
 <a href="html/libxml-xmlwriter.html#xmlNewTextWriterPushParser">xmlNewTextWriterPushParser</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContent">xmlNodeAddContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeAddContentLen">xmlNodeAddContentLen</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContent">xmlNodeSetContent</a><br />
+<a href="html/libxml-tree.html#xmlNodeSetContentLen">xmlNodeSetContentLen</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseExternalID">xmlParseExternalID</a><br />
 <a href="html/libxml-parserInternals.html#xmlParsePEReference">xmlParsePEReference</a><br />
 <a href="html/libxml-parserInternals.html#xmlParserHandlePEReference">xmlParserHandlePEReference</a><br />
diff --git a/doc/devhelp/libxml2-tree.html b/doc/devhelp/libxml2-tree.html
index 70c6e50..260217f 100644
--- a/doc/devhelp/libxml2-tree.html
+++ b/doc/devhelp/libxml2-tree.html
@@ -1288,11 +1288,11 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the text content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the text len.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the new node object.</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeAddContent"/>xmlNodeAddContent ()</h3><pre class="programlisting">void	xmlNodeAddContent		(<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br/>
-</pre><p>Append the extra substring to the node content.</p>
+</pre><p>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>extra content</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeAddContentLen"/>xmlNodeAddContentLen ()</h3><pre class="programlisting">void	xmlNodeAddContentLen		(<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content, <br/>					 int len)<br/>
-</pre><p>Append the extra substring to the node content.</p>
+</pre><p>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>extra content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the size of @content</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeBufGetContent"/>xmlNodeBufGetContent ()</h3><pre class="programlisting">int	xmlNodeBufGetContent		(<a href="libxml2-tree.html#xmlBufferPtr">xmlBufferPtr</a> buffer, <br/>					 <a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br/>
@@ -1340,11 +1340,11 @@
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being changed</td></tr><tr><td><span class="term"><i><tt>uri</tt></i>:</span></td><td>the new base URI</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeSetContent"/>xmlNodeSetContent ()</h3><pre class="programlisting">void	xmlNodeSetContent		(<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content)<br/>
-</pre><p>Replace the content of a node.</p>
+</pre><p>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the new value of the content</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeSetContentLen"/>xmlNodeSetContentLen ()</h3><pre class="programlisting">void	xmlNodeSetContentLen		(<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * content, <br/>					 int len)<br/>
-</pre><p>Replace the content of a node.</p>
+</pre><p>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</p>
 <div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the new value of the content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the size of @content</td></tr></tbody></table></div></div>
         <hr/>
         <div class="refsect2" lang="en"><h3><a name="xmlNodeSetLang"/>xmlNodeSetLang ()</h3><pre class="programlisting">void	xmlNodeSetLang			(<a href="libxml2-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br/>					 const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * lang)<br/>
diff --git a/doc/html/libxml-tree.html b/doc/html/libxml-tree.html
index 26ec73b..7a5c31b 100644
--- a/doc/html/libxml-tree.html
+++ b/doc/html/libxml-tree.html
@@ -820,9 +820,9 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>parent</tt></i>:</span></td><td>the parent node</td></tr><tr><td><span class="term"><i><tt>ns</tt></i>:</span></td><td>a namespace if any</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name of the child</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the text content of the child if any.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the new node object.</td></tr></tbody></table></div><h3><a name="xmlNewTextLen" id="xmlNewTextLen"></a>Function: xmlNewTextLen</h3><pre class="programlisting"><a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a>	xmlNewTextLen		(const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * content, <br />					 int len)<br />
 </pre><p>Creation of a new text node with an extra parameter for the content's length</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the text content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the text len.</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the new node object.</td></tr></tbody></table></div><h3><a name="xmlNodeAddContent" id="xmlNodeAddContent"></a>Function: xmlNodeAddContent</h3><pre class="programlisting">void	xmlNodeAddContent		(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * content)<br />
-</pre><p>Append the extra substring to the node content.</p>
+</pre><p>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>extra content</td></tr></tbody></table></div><h3><a name="xmlNodeAddContentLen" id="xmlNodeAddContentLen"></a>Function: xmlNodeAddContentLen</h3><pre class="programlisting">void	xmlNodeAddContentLen		(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * content, <br />					 int len)<br />
-</pre><p>Append the extra substring to the node content.</p>
+</pre><p>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>extra content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the size of @content</td></tr></tbody></table></div><h3><a name="xmlNodeBufGetContent" id="xmlNodeBufGetContent"></a>Function: xmlNodeBufGetContent</h3><pre class="programlisting">int	xmlNodeBufGetContent		(<a href="libxml-tree.html#xmlBufferPtr">xmlBufferPtr</a> buffer, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur)<br />
 </pre><p>Read the value of a node @cur, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF). Entity references are substituted. Fills up the buffer @buffer with this value</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>buffer</tt></i>:</span></td><td>a buffer</td></tr><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being read</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success and -1 in case of error.</td></tr></tbody></table></div><h3><a name="xmlNodeDump" id="xmlNodeDump"></a>Function: xmlNodeDump</h3><pre class="programlisting">int	xmlNodeDump			(<a href="libxml-tree.html#xmlBufferPtr">xmlBufferPtr</a> buf, <br />					 <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a> doc, <br />					 <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 int level, <br />					 int format)<br />
@@ -846,9 +846,9 @@
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>doc</tt></i>:</span></td><td>the document</td></tr><tr><td><span class="term"><i><tt>list</tt></i>:</span></td><td>a Node list</td></tr><tr><td><span class="term"><i><tt>inLine</tt></i>:</span></td><td>should we replace entity contents or show their external form</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the string copy, the caller must free it with xmlFree().</td></tr></tbody></table></div><h3><a name="xmlNodeSetBase" id="xmlNodeSetBase"></a>Function: xmlNodeSetBase</h3><pre class="programlisting">void	xmlNodeSetBase			(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * uri)<br />
 </pre><p>Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being changed</td></tr><tr><td><span class="term"><i><tt>uri</tt></i>:</span></td><td>the new base URI</td></tr></tbody></table></div><h3><a name="xmlNodeSetContent" id="xmlNodeSetContent"></a>Function: xmlNodeSetContent</h3><pre class="programlisting">void	xmlNodeSetContent		(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * content)<br />
-</pre><p>Replace the content of a node.</p>
+</pre><p>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the new value of the content</td></tr></tbody></table></div><h3><a name="xmlNodeSetContentLen" id="xmlNodeSetContentLen"></a>Function: xmlNodeSetContentLen</h3><pre class="programlisting">void	xmlNodeSetContentLen		(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * content, <br />					 int len)<br />
-</pre><p>Replace the content of a node.</p>
+</pre><p>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being modified</td></tr><tr><td><span class="term"><i><tt>content</tt></i>:</span></td><td>the new value of the content</td></tr><tr><td><span class="term"><i><tt>len</tt></i>:</span></td><td>the size of @content</td></tr></tbody></table></div><h3><a name="xmlNodeSetLang" id="xmlNodeSetLang"></a>Function: xmlNodeSetLang</h3><pre class="programlisting">void	xmlNodeSetLang			(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * lang)<br />
 </pre><p>Set the language of a node, i.e. the values of the xml:lang attribute.</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>cur</tt></i>:</span></td><td>the node being changed</td></tr><tr><td><span class="term"><i><tt>lang</tt></i>:</span></td><td>the language description</td></tr></tbody></table></div><h3><a name="xmlNodeSetName" id="xmlNodeSetName"></a>Function: xmlNodeSetName</h3><pre class="programlisting">void	xmlNodeSetName			(<a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> cur, <br />					 const <a href="libxml-xmlstring.html#xmlChar">xmlChar</a> * name)<br />
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index dd49a2b..943f8d5 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -11429,13 +11429,13 @@
       <arg name='ctxt' type='xmlParserCtxtPtr' info='the context in which the entity is called or NULL'/>
     </function>
     <function name='xmlNodeAddContent' file='tree' module='tree'>
-      <info>Append the extra substring to the node content.</info>
+      <info>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</info>
       <return type='void'/>
       <arg name='cur' type='xmlNodePtr' info='the node being modified'/>
       <arg name='content' type='const xmlChar *' info='extra content'/>
     </function>
     <function name='xmlNodeAddContentLen' file='tree' module='tree'>
-      <info>Append the extra substring to the node content.</info>
+      <info>Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.</info>
       <return type='void'/>
       <arg name='cur' type='xmlNodePtr' info='the node being modified'/>
       <arg name='content' type='const xmlChar *' info='extra content'/>
@@ -11517,14 +11517,14 @@
       <arg name='uri' type='const xmlChar *' info='the new base URI'/>
     </function>
     <function name='xmlNodeSetContent' file='tree' module='tree'>
-      <info>Replace the content of a node.</info>
+      <info>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</info>
       <return type='void'/>
       <arg name='cur' type='xmlNodePtr' info='the node being modified'/>
       <arg name='content' type='const xmlChar *' info='the new value of the content'/>
     </function>
     <function name='xmlNodeSetContentLen' file='tree' module='tree'>
       <cond>defined(LIBXML_TREE_ENABLED)</cond>
-      <info>Replace the content of a node.</info>
+      <info>Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars().</info>
       <return type='void'/>
       <arg name='cur' type='xmlNodePtr' info='the node being modified'/>
       <arg name='content' type='const xmlChar *' info='the new value of the content'/>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index d7af1f5..c316bda 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -14468,6 +14468,8 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseAttValue'/>
           <ref name='xmlParseAttributeType'/>
           <ref name='xmlParseCDSect'/>
@@ -16348,6 +16350,10 @@
           <ref name='xmlNewTextChild'/>
           <ref name='xmlNewTextWriter'/>
           <ref name='xmlNewTextWriterPushParser'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseExternalID'/>
           <ref name='xmlParsePEReference'/>
           <ref name='xmlParserHandlePEReference'/>
@@ -18751,6 +18757,8 @@
           <ref name='xmlAutomataNewAllTrans'/>
           <ref name='xmlAutomataNewCounterTrans'/>
           <ref name='xmlIsLetter'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
           <ref name='xmlNodeDump'/>
           <ref name='xmlNodeDumpOutput'/>
           <ref name='xmlParseBalancedChunkMemory'/>
@@ -18769,6 +18777,8 @@
           <ref name='htmlIsAutoClosed'/>
           <ref name='xmlCatalogAdd'/>
           <ref name='xmlNewChild'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseURIRaw'/>
           <ref name='xmlTextReaderConstString'/>
         </word>
@@ -20468,6 +20478,10 @@
           <ref name='xmlNodeListGetRawString'/>
           <ref name='xmlXPathFreeNodeSetList'/>
         </word>
+        <word name='contrast'>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
+        </word>
         <word name='control'>
           <ref name='_xmlXPathContext'/>
           <ref name='resolveEntity'/>
@@ -21869,6 +21883,8 @@
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
           <ref name='xmlNewTextChild'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseCDSect'/>
           <ref name='xmlParseCharData'/>
           <ref name='xmlSaveUri'/>
@@ -24879,6 +24895,8 @@
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
           <ref name='xmlNewTextChild'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseEntityRef'/>
           <ref name='xmlParserHandleReference'/>
           <ref name='xmlRegExecErrInfo'/>
@@ -25830,6 +25848,8 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
         </word>
         <word name='pieces'>
           <ref name='xmlParseURIRaw'/>
@@ -26534,6 +26554,8 @@
           <ref name='xmlNamespaceParseNCName'/>
           <ref name='xmlNamespaceParseNSDef'/>
           <ref name='xmlNamespaceParseQName'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
           <ref name='xmlParseCDSect'/>
           <ref name='xmlParserInputBufferGrow'/>
           <ref name='xmlTextWriterWriteFormatRaw'/>
@@ -26755,8 +26777,12 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
           <ref name='xmlNodeBufGetContent'/>
           <ref name='xmlNodeGetContent'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlParseAttribute'/>
           <ref name='xmlParseCharRef'/>
           <ref name='xmlParseEntityRef'/>
@@ -27148,6 +27174,10 @@
           <ref name='xmlTextReaderClose'/>
           <ref name='xmlXIncludeSetFlags'/>
         </word>
+        <word name='resp'>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
+        </word>
         <word name='respect'>
           <ref name='xmlExpStringDerive'/>
         </word>
@@ -27980,6 +28010,10 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlTextWriterWriteRawLen'/>
         </word>
         <word name='specialized'>
@@ -28560,6 +28594,8 @@
           <ref name='xmlDOMWrapRemoveNode'/>
           <ref name='xmlInitCharEncodingHandlers'/>
           <ref name='xmlNanoFTPGetConnection'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
           <ref name='xmlSchemaGetCanonValue'/>
           <ref name='xmlSchemaGetCanonValueWhtsp'/>
           <ref name='xmlTextReaderNormalization'/>
@@ -28569,6 +28605,10 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
           <ref name='xmlStrcat'/>
           <ref name='xmlStrdup'/>
         </word>
@@ -29189,6 +29229,8 @@
         </word>
         <word name='unescaped'>
           <ref name='xmlFileOpen'/>
+          <ref name='xmlNodeAddContent'/>
+          <ref name='xmlNodeAddContentLen'/>
           <ref name='xmlURIUnescapeString'/>
         </word>
         <word name='unescaping'>
@@ -30160,6 +30202,12 @@
           <ref name='xmlNewChild'/>
           <ref name='xmlNewDocNode'/>
           <ref name='xmlNewDocNodeEatName'/>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
+        </word>
+        <word name='xmlEncodeSpecialChars'>
+          <ref name='xmlNodeSetContent'/>
+          <ref name='xmlNodeSetContentLen'/>
         </word>
         <word name='xmlEntitiesTablePtr'>
           <ref name='xmlCopyEntitiesTable'/>
@@ -30416,6 +30464,12 @@
           <ref name='xmlXPathNodeSetItem'/>
           <ref name='xmlXPtrBuildNodeList'/>
         </word>
+        <word name='xmlNodeSetContent'>
+          <ref name='xmlNodeAddContent'/>
+        </word>
+        <word name='xmlNodeSetContentLen'>
+          <ref name='xmlNodeAddContentLen'/>
+        </word>
         <word name='xmlNodeSetPtr'>
           <ref name='xmlXPathFreeNodeSet'/>
           <ref name='xmlXPathNodeSetCreate'/>
diff --git a/xpath.c b/xpath.c
index ebf8744..01e44ee 100644
--- a/xpath.c
+++ b/xpath.c
@@ -12163,6 +12163,7 @@
 #ifdef DEBUG_STEP
             xmlGenericError(xmlGenericErrorContext, " %s", cur->name);
 #endif
+            
 	    switch (test) {
                 case NODE_TEST_NONE:
 		    total = 0;
@@ -12241,6 +12242,16 @@
                         break;
                     }
                 case NODE_TEST_NAME:
+                    if (axis == AXIS_ATTRIBUTE) {
+                        if (cur->type != XML_ATTRIBUTE_NODE)
+			    break;
+		    } else if (axis == AXIS_NAMESPACE) {
+                        if (cur->type != XML_NAMESPACE_DECL)
+			    break;
+		    } else {
+		        if (cur->type != XML_ELEMENT_NODE)
+			    break;
+		    }
                     switch (cur->type) {
                         case XML_ELEMENT_NODE:
                             if (xmlStrEqual(name, cur->name)) {