1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

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
This commit is contained in:
Daniel Veillard 2004-08-16 12:34:50 +00:00
parent 335f5ec7e5
commit c14c3892a2
9 changed files with 101 additions and 25 deletions

View File

@ -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

View File

@ -477,6 +477,21 @@ XIncludetests : xmllint$(EXEEXT)
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 @@ XIncludetests : xmllint$(EXEEXT)
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)

View File

@ -2349,6 +2349,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
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");

View File

@ -24,7 +24,7 @@ xmllint \- command line XML tool
.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
@ -178,6 +178,10 @@ Generate a small document for testing purposes\&.
\fB\-\-xinclude\fR
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\&.

View File

@ -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>
@ -451,6 +452,15 @@
</simpara>
</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>

View File

@ -1071,7 +1071,8 @@ typedef enum {
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

View File

@ -2116,28 +2116,43 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
}
}
/*
* 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);
}
}

View File

@ -1612,6 +1612,7 @@ static void usage(const char *name) {
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 @@ main(int argc, char **argv) {
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

View File

@ -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 @@ node_found:
(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