added help for new set shell command added parser option to not generate

* debugXML.c: added help for new set shell command
* xinclude.c xmllint.c xmlreader.c include/libxml/parser.h:
  added parser option to not generate XInclude start/end nodes,
  added a specific option to xmllint to test it fixes #130769
* Makefile.am: regression test the new feature
* doc/xmllint.1 doc/xmllint.xml: updated man page to document option.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 9fb3d65..b7cfe6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Aug 16 14:36:25 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+	* debugXML.c: added help for new set shell command
+	* xinclude.c xmllint.c xmlreader.c include/libxml/parser.h:
+	  added parser option to not generate XInclude start/end nodes,
+	  added a specific option to xmllint to test it fixes #130769
+	* Makefile.am: regression test the new feature
+	* doc/xmllint.1 doc/xmllint.xml: updated man page to document option.
+
 Mon Aug 16 02:42:30 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
 	* xmlIO.c: small typo pointed out by Mike Hommey
diff --git a/Makefile.am b/Makefile.am
index 29880f0..f81b024 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -477,6 +477,21 @@
 	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
+	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
+	  name=`basename $$i`; \
+	  if [ ! -d $$i ] ; then \
+	  if [ ! -f $(srcdir)/result/XInclude/$$name ] ; then \
+	      echo New test file $$name ; \
+	      $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \
+	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
+	  else \
+	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > result.$$name 2>error.$$name ; \
+	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
+	      diff $(srcdir)/result/XInclude/$$name result.$$name ; \
+	      diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      rm result.$$name error.$$name ; \
+	  fi ; fi ; done)
 	@(echo > .memdump)
 	@echo "## XInclude xmlReader regression tests"
 	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
@@ -494,6 +509,21 @@
 	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
 	      rm result.$$name error.$$name ; \
 	  fi ; fi ; done)
+	-@(for i in $(srcdir)/test/XInclude/docs/* ; do \
+	  name=`basename $$i`; \
+	  if [ ! -d $$i ] ; then \
+	  if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \
+	      echo New test file $$name ; \
+	      $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \
+	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
+	  else \
+	      log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \
+	      grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
+	      diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \
+	      diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \
+	      if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
+	      rm result.$$name error.$$name ; \
+	  fi ; fi ; done)
 
 Scripttests : xmllint$(EXEEXT)
 	@(echo > .memdump)
diff --git a/debugXML.c b/debugXML.c
index 3079131..71a8712 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -2349,6 +2349,7 @@
 		  fprintf(ctxt->output, "\tfree         display memory usage\n");
 		  fprintf(ctxt->output, "\tload [name]  load a new document with name\n");
 		  fprintf(ctxt->output, "\tls [path]    list contents of path or the current directory\n");
+		  fprintf(ctxt->output, "\tset xml_fragment replace the current node content with the fragment parsed in context\n");
 #ifdef LIBXML_XPATH_ENABLED
 		  fprintf(ctxt->output, "\txpath expr   evaluate the XPath expression in that context and print the result\n");
 		  fprintf(ctxt->output, "\tsetns nsreg  register a namespace to a prefix in the XPath evaluation context\n");
diff --git a/doc/xmllint.1 b/doc/xmllint.1
index ffb7a75..2dd3a57 100644
--- a/doc/xmllint.1
+++ b/doc/xmllint.1
@@ -24,7 +24,7 @@
 .ad l
 .hy 0
 .HP 8
-\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-shell\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fIfile\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-maxmem\ \fInbbytes\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fIencoding\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fIpatternvalue\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\fR | \fB\-\-schema\fR | \fB\-\-c14n\fR] [\fB\fIxmlfile\fR\fR]
+\fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-shell\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fIfile\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-maxmem\ \fInbbytes\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fIencoding\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fIpatternvalue\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\fR | \fB\-\-schema\fR | \fB\-\-c14n\fR] [\fB\fIxmlfile\fR\fR]
 .ad
 .hy
 
@@ -179,6 +179,10 @@
 Do XInclude processing\&.
 
 .TP
+\fB\-\-noxincludenode\fR
+Do XInclude processing but do not generate XInclude start and end nodes\&.
+
+.TP
 \fB\-\-loaddtd\fR
 Fetch external DTD\&.
 
diff --git a/doc/xmllint.xml b/doc/xmllint.xml
index 1a998e1..d6b747d 100644
--- a/doc/xmllint.xml
+++ b/doc/xmllint.xml
@@ -83,6 +83,7 @@
 	<arg>--nocatalogs</arg>
 	<arg>--auto</arg>
 	<arg>--xinclude</arg>
+	<arg>--noxincludenode</arg>
 	<arg>--loaddtd</arg>
 	<arg>--dtdattr</arg>
 	<arg>--stream</arg>
@@ -452,6 +453,15 @@
 	</listitem>
       </varlistentry>
     <varlistentry>
+	<term><option>--noxincludenode</option></term>
+	<listitem>
+	  <simpara>
+	   Do XInclude processing but do not generate XInclude start and end
+	   nodes.
+	  </simpara>
+	</listitem>
+      </varlistentry>
+    <varlistentry>
 	<term><option>--loaddtd</option></term>
 	<listitem>
 	  <simpara>
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 01cf27a..cc6fae1 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -1071,7 +1071,8 @@
     XML_PARSE_NONET	= 1<<11,/* Forbid network access */
     XML_PARSE_NODICT	= 1<<12,/* Do not reuse the context dictionnary */
     XML_PARSE_NSCLEAN	= 1<<13,/* remove redundant namespaces declarations */
-    XML_PARSE_NOCDATA	= 1<<14 /* merge CDATA as text nodes */
+    XML_PARSE_NOCDATA	= 1<<14,/* merge CDATA as text nodes */
+    XML_PARSE_NOXINCNODE= 1<<15 /* do not generate XINCLUDE START/END nodes */
 } xmlParserOption;
 
 XMLPUBFUN void XMLCALL
diff --git a/xinclude.c b/xinclude.c
index aa14b2c..f43a2e8 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -2116,28 +2116,43 @@
 	}
     }
 
-    /*
-     * Change the current node as an XInclude start one, and add an
-     * entity end one
-     */
-    cur->type = XML_XINCLUDE_START;
-    end = xmlNewNode(cur->ns, cur->name);
-    if (end == NULL) {
-	xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, XML_XINCLUDE_BUILD_FAILED,
-	               "failed to build node\n", NULL);
-	return(-1);
-    }
-    end->type = XML_XINCLUDE_END;
-    xmlAddNextSibling(cur, end);
+    if (ctxt->parseFlags & XML_PARSE_NOXINCNODE) {
+	/*
+	 * Add the list of nodes
+	 */
+	while (list != NULL) {
+	    end = list;
+	    list = list->next;
 
-    /*
-     * Add the list of nodes
-     */
-    while (list != NULL) {
-	cur = list;
-	list = list->next;
+	    xmlAddPrevSibling(cur, end);
+	}
+	xmlUnlinkNode(cur);
+	xmlFreeNode(cur);
+    } else {
+	/*
+	 * Change the current node as an XInclude start one, and add an
+	 * XInclude end one
+	 */
+	cur->type = XML_XINCLUDE_START;
+	end = xmlNewNode(cur->ns, cur->name);
+	if (end == NULL) {
+	    xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+	                   XML_XINCLUDE_BUILD_FAILED,
+			   "failed to build node\n", NULL);
+	    return(-1);
+	}
+	end->type = XML_XINCLUDE_END;
+	xmlAddNextSibling(cur, end);
 
-        xmlAddPrevSibling(end, cur);
+	/*
+	 * Add the list of nodes
+	 */
+	while (list != NULL) {
+	    cur = list;
+	    list = list->next;
+
+	    xmlAddPrevSibling(end, cur);
+	}
     }
 
     
diff --git a/xmllint.c b/xmllint.c
index 390a1db..6225df9 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -1612,6 +1612,7 @@
     printf("\t--auto : generate a small doc on the fly\n");
 #ifdef LIBXML_XINCLUDE_ENABLED
     printf("\t--xinclude : do XInclude processing\n");
+    printf("\t--noxincludenode : same but do not generate XInclude nodes\n");
 #endif
     printf("\t--loaddtd : fetch external DTD\n");
     printf("\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
@@ -1799,6 +1800,12 @@
 	    xinclude++;
 	    options |= XML_PARSE_XINCLUDE;
 	}
+	else if ((!strcmp(argv[i], "-noxincludenode")) ||
+	         (!strcmp(argv[i], "--noxincludenode"))) {
+	    xinclude++;
+	    options |= XML_PARSE_XINCLUDE;
+	    options |= XML_PARSE_NOXINCNODE;
+	}
 #endif
 #ifdef LIBXML_OUTPUT_ENABLED
 #ifdef HAVE_ZLIB_H
diff --git a/xmlreader.c b/xmlreader.c
index b075328..58fbe2e 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -13,8 +13,6 @@
 /*
  * TODOs:
  *   - XML Schemas validation
- *   - setting(s) for NoBlanks
- *   - performances and tuning ...
  */
 #define IN_LIBXML
 #include "libxml.h"
@@ -1405,7 +1403,8 @@
 	 (xmlStrEqual(reader->node->ns->href, XINCLUDE_OLD_NS)))) {
 	if (reader->xincctxt == NULL) {
 	    reader->xincctxt = xmlXIncludeNewContext(reader->ctxt->myDoc);
-	    xmlXIncludeSetFlags(reader->xincctxt, reader->parserFlags);
+	    xmlXIncludeSetFlags(reader->xincctxt, 
+	                        reader->parserFlags & (~XML_PARSE_NOXINCNODE));
 	}
 	/*
 	 * expand that node and process it