Commit 361d845d authored by Daniel Veillard's avatar Daniel Veillard

Work done on the plane, ready to release libxml2-2.0.0, Daniel

parent ec30341c
Mon Apr 3 21:47:10 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: preparing libxml-2.0.0 version looks Ok so far
* README TODO: updated for release
* uri.c uri.h: added authority parsing/saving
* uri.c testURI.c Makefile.am: moved the testing code to testURI.c
* xmlversion.h.in configure.in nanoftp.[ch] nanohttp.[ch] encoding.h
debugXML.[ch] xpath.[ch] xmlIO.c tester.c testXPath.c testHTML.c
tree.c HTMLtree.c HTMLparser.c tree.c tree.h parser.c
Makefile.am : added compile-time customization of libxml
--with-ftp --with-http --with-html --with-xpath --with-debug
--with-mem-debug
* *.[ch] autoconf.sh : moved to an absolute adressing of includes :
#include <libxml/xxx.h> I hope it won't break too much stuff
and will be manageable in the future...
* xmllint.c Makefile.am libxml.spec.in : renamed tester.c to xmllint.c
and added xmllint to the installed programs
* uri.h: added xmlFreeURI()
Fri Mar 24 14:35:21 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* uri.c uri.h: finished the escaping handling, the base support
......
......@@ -12,6 +12,9 @@
#include "config.h"
#endif
#include "xmlversion.h"
#ifdef LIBXML_HTML_ENABLED
#include <stdio.h>
#include <string.h> /* for memset() only */
#ifdef HAVE_CTYPE_H
......@@ -33,14 +36,14 @@
#include <zlib.h>
#endif
#include "xmlmemory.h"
#include "tree.h"
#include "HTMLparser.h"
#include "entities.h"
#include "encoding.h"
#include "valid.h"
#include "parserInternals.h"
#include "xmlIO.h"
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/HTMLparser.h>
#include <libxml/entities.h>
#include <libxml/encoding.h>
#include <libxml/valid.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlIO.h>
#include "xml-error.h"
#define HTML_MAX_NAMELEN 1000
......@@ -3843,3 +3846,5 @@ htmlDocPtr
htmlParseFile(const char *filename, const char *encoding) {
return(htmlSAXParseFile(filename, encoding, NULL, NULL));
}
#endif /* LIBXML_HTML_ENABLED */
......@@ -8,7 +8,7 @@
#ifndef __HTML_PARSER_H__
#define __HTML_PARSER_H__
#include "parser.h"
#include <libxml/parser.h>
#ifdef __cplusplus
extern "C" {
......
......@@ -12,6 +12,10 @@
#else
#include "config.h"
#endif
#include "xmlversion.h"
#ifdef LIBXML_HTML_ENABLED
#include <stdio.h>
#include <string.h> /* for memset() only ! */
......@@ -22,11 +26,11 @@
#include <stdlib.h>
#endif
#include "xmlmemory.h"
#include "HTMLparser.h"
#include "HTMLtree.h"
#include "entities.h"
#include "valid.h"
#include <libxml/xmlmemory.h>
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/entities.h>
#include <libxml/valid.h>
static void
htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur);
......@@ -404,3 +408,4 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
return(ret * sizeof(xmlChar));
}
#endif /* LIBXML_HTML_ENABLED */
......@@ -11,7 +11,7 @@
#define __HTML_TREE_H__
#include <stdio.h>
#include "tree.h"
#include <libxml/tree.h>
#ifdef __cplusplus
......
......@@ -2,11 +2,11 @@
SUBDIRS = doc
INCLUDES = -I@srcdir@ @Z_CFLAGS@ @CORBA_CFLAGS@ $(VERSION_FLAGS)
INCLUDES = -I@srcdir@ @Z_CFLAGS@ @CORBA_CFLAGS@
VERSION_FLAGS = -DLIBXML_VERSION=\"@LIBXML_VERSION@\"
noinst_PROGRAMS=testSAX testHTML testXPath testURI
noinst_PROGRAMS=tester testSAX testHTML testXPath testURI
bin_PROGRAMS = xmllint
bin_SCRIPTS=xml-config
......@@ -21,20 +21,20 @@ libxml_la_SOURCES = \
encoding.c \
error.c \
parser.c \
HTMLparser.c \
HTMLtree.c \
debugXML.c \
tree.c \
xpath.c \
xmlIO.c \
xmlmemory.c \
nanohttp.c \
nanoftp.c \
uri.c \
valid.c \
xlink.c
xlink.c \
HTMLparser.c \
HTMLtree.c \
debugXML.c \
xpath.c \
nanohttp.c \
nanoftp.c
xmlincdir = $(includedir)/gnome-xml
xmlincdir = $(includedir)/libxml
xmlinc_HEADERS = \
SAX.h \
entities.h \
......@@ -53,15 +53,16 @@ xmlinc_HEADERS = \
nanoftp.h \
uri.h \
valid.h \
xlink.h
xlink.h \
xmlversion.h
DEPS = $(top_builddir)/libxml.la
LDADDS = $(top_builddir)/libxml.la @Z_LIBS@ @M_LIBS@
tester_SOURCES=tester.c
tester_LDFLAGS =
tester_DEPENDENCIES = $(DEPS)
tester_LDADD= @RDL_LIBS@ $(LDADDS)
xmllint_SOURCES=xmllint.c
xmllint_LDFLAGS =
xmllint_DEPENDENCIES = $(DEPS)
xmllint_LDADD= @RDL_LIBS@ $(LDADDS)
testSAX_SOURCES=testSAX.c
testSAX_LDFLAGS =
......@@ -78,15 +79,23 @@ testXPath_LDFLAGS =
testXPath_DEPENDENCIES = $(DEPS)
testXPath_LDADD= $(LDADDS)
testURI_SOURCES=testURI.c
testURI_LDFLAGS =
testURI_DEPENDENCIES = $(DEPS)
testURI_LDADD= $(LDADDS)
check-local: tests
install-data: $(srcdir)/libxml
$(srcdir)/libxml:
-$(RM) $(srcdir)/libxml
ln -s $(srcdir)/. $(srcdir)/libxml
testall : tests SVGtests SAXtests XPathtests XMLenttests
tests: XMLtests HTMLtests Validtests
testURI: $(srcdir)/uri.c $(srcdir)/uri.h xmlmemory.o
$(CC) $(CFLAGS) -DSTANDALONE -o testURI $(srcdir)/uri.c xmlmemory.o
HTMLtests : testHTML
@echo "##"
@echo "## HTML regression tests"
......@@ -107,7 +116,7 @@ HTMLtests : testHTML
rm result.$$name result2.$$name error.$$name ; \
fi ; fi ; done)
XMLtests : tester
XMLtests : xmllint
@echo "##"
@echo "## XML regression tests"
@echo "##"
......@@ -116,17 +125,17 @@ XMLtests : tester
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/tester $$i > $(srcdir)/result/$$name ; \
$(top_builddir)/xmllint $$i > $(srcdir)/result/$$name ; \
else \
echo Testing $$name ; \
$(top_builddir)/tester $$i > result.$$name ; \
$(top_builddir)/xmllint $$i > result.$$name ; \
diff $(srcdir)/result/$$name result.$$name ; \
$(top_builddir)/tester result.$$name > result2.$$name ; \
$(top_builddir)/xmllint result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
XMLenttests : tester
XMLenttests : xmllint
@echo "##"
@echo "## XML entity subst regression tests"
@echo "##"
......@@ -135,12 +144,12 @@ XMLenttests : tester
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/noent/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/tester --noent $$i > $(srcdir)/result/noent/$$name ; \
$(top_builddir)/xmllint --noent $$i > $(srcdir)/result/noent/$$name ; \
else \
echo Testing $$name ; \
$(top_builddir)/tester --noent $$i > result.$$name ; \
$(top_builddir)/xmllint --noent $$i > result.$$name ; \
diff $(srcdir)/result/noent/$$name result.$$name ; \
$(top_builddir)/tester --noent result.$$name > result2.$$name ; \
$(top_builddir)/xmllint --noent result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
......@@ -177,7 +186,7 @@ XPathtests : testXPath
rm result.$$name ; \
fi ; fi ; done ; fi ; done)
SVGtests : tester
SVGtests : xmllint
@echo "##"
@echo "## SVG parsing regression tests"
@echo "##"
......@@ -186,12 +195,12 @@ SVGtests : tester
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/SVG/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/tester $$i > $(srcdir)/result/SVG/$$name ; \
$(top_builddir)/xmllint $$i > $(srcdir)/result/SVG/$$name ; \
else \
echo Testing $$name ; \
$(top_builddir)/tester $$i > result.$$name ; \
$(top_builddir)/xmllint $$i > result.$$name ; \
diff $(srcdir)/result/SVG/$$name result.$$name ; \
$(top_builddir)/tester result.$$name > result2.$$name ; \
$(top_builddir)/xmllint result.$$name > result2.$$name ; \
diff result.$$name result2.$$name ; \
rm result.$$name result2.$$name ; \
fi ; fi ; done)
......@@ -214,7 +223,7 @@ SAXtests : testSAX
fi ; fi ; done)
Validtests : tester
Validtests : xmllint
@echo "##"
@echo "## Validity checking regression tests"
@echo "##"
......@@ -223,10 +232,10 @@ Validtests : tester
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/VC/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/tester --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
$(top_builddir)/xmllint --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \
else \
echo Testing $$name ; \
$(top_builddir)/tester --noout --valid $$i 2> result.$$name ; \
$(top_builddir)/xmllint --noout --valid $$i 2> result.$$name ; \
diff $(srcdir)/result/VC/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
......@@ -238,10 +247,10 @@ Validtests : tester
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/valid/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/tester --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \
$(top_builddir)/xmllint --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \
else \
echo Testing $$name ; \
$(top_builddir)/tester --valid $$i > result.$$name 2>error.$$name ; \
$(top_builddir)/xmllint --valid $$i > result.$$name 2>error.$$name ; \
diff $(srcdir)/result/valid/$$name result.$$name ; \
diff $(srcdir)/result/valid/$$name.err error.$$name ; \
rm result.$$name error.$$name ; \
......
XML parser for Gnome
Documentation is available on-line at
http://rufus.w3.org/veillard/XML/xml.html
Full documentation is available on-line at
http://xmlsoft.org/
A mailing-list has been set-up, to subscribe:
A mailing-list is available, to subscribe:
echo "subscribe xml" | mail majordomo@rufus.w3.org
The list archive is at:
http://rufus.w3.org/veillard/XML/messages/
http://xmlsoft.org/messages/
NOTE: I use a second CVS server for experimental version of the XML code,
this mean that if you commit without a Changelog or without sending
......
......@@ -14,16 +14,16 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#include "xmlmemory.h"
#include "tree.h"
#include "parser.h"
#include "parserInternals.h"
#include "valid.h"
#include "entities.h"
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include "xml-error.h"
#include "debugXML.h"
#include "xmlIO.h"
#include "SAX.h"
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/SAX.h>
/* #define DEBUG_SAX */
/* #define DEBUG_SAX_TREE */
......
......@@ -12,8 +12,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
#include "xlink.h"
#include <libxml/parser.h>
#include <libxml/xlink.h>
#ifdef __cplusplus
#define extern "C" {
......
......@@ -2,6 +2,10 @@
TODO for the XML parser and stuff:
==================================
CVS:
====
rename tester.c to xmllint.c
TODO:
=====
......@@ -14,6 +18,9 @@ TODO:
be saved back.
- Go through erratas and do the cleanup.
http://www.w3.org/XML/xml-19980210-errata ... bummmer
- Handle undefined namespaces in entity contents better ... at least
issue a warning
- General checking of DTD validation in presence of namespaces ... hairy
TODO:
=====
......@@ -36,14 +43,6 @@ TODO:
EXTENSIONS:
===========
- Check attribute normalization especially xmlGetProp()
- Validity checking problems for NOTATIONS attributes
- Validity checking problems for ENTITY ENTITIES attributes
- dynamically adapt the alloc entry point to use g_alloc()/g_free()
if the programmer wants it:
- use xmlMemSetup() to reset the routines used.
- Parsing of a well balanced chunk
- URI module: validation, base, etc ...
- Tools to produce man pages from the SGML docs.
- Finish XPath
=> attributes addressing troubles
......@@ -79,8 +78,7 @@ EXTENSIONS:
- Add a DTD cache prefilled with xhtml DTDs and entities and a program to
manage them -> like the /usr/bin/install-catalog from SGML
right place seems $datadir/xmldtds
- turn tester into a generic program xml-test installed with xml-devel
Maybe this is better left to user apps
- Add output to XHTML in case of HTML documents.
......@@ -88,6 +86,15 @@ EXTENSIONS:
Done:
=====
- dynamically adapt the alloc entry point to use g_alloc()/g_free()
if the programmer wants it:
- use xmlMemSetup() to reset the routines used.
- Check attribute normalization especially xmlGetProp()
- Validity checking problems for NOTATIONS attributes
- Validity checking problems for ENTITY ENTITIES attributes
- Parsing of a well balanced chunk xmlParseBalancedChunkMemory()
- URI module: validation, base, etc ... see uri.[ch]
- turn tester into a generic program xmllint installed with libxml
- extend validity checks to go through entities content instead of
just labelling them PCDATA
- Save Dtds using the children list instead of dumping the tables,
......
......@@ -10,7 +10,7 @@ DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile gnome-xml."
echo "You must have autoconf installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
......@@ -18,7 +18,7 @@ DIE=0
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have libtool installed to compile gnome-xml."
echo "You must have libtool installed to compile libxml."
echo "Get ftp://alpha.gnu.org/gnu/libtool-1.0h.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
......@@ -26,7 +26,7 @@ DIE=0
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have automake installed to compile gnome-xml."
echo "You must have automake installed to compile libxml."
echo "Get ftp://ftp.cygnus.com/pub/home/tromey/automake-1.2d.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
......@@ -37,7 +37,7 @@ if test "$DIE" -eq 1; then
fi
test -f entities.h || {
echo "You must run this script in the top-level gnome-xml directory"
echo "You must run this script in the top-level libxml directory"
exit 1
}
......@@ -61,4 +61,4 @@ fi
$srcdir/configure "$@"
echo
echo "Now type 'make' to compile gnome-xml."
echo "Now type 'make' to compile libxml."
......@@ -9,13 +9,16 @@ LIBXML_MICRO_VERSION=0
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
LIBXML_VERSION_NUMBER=`expr $LIBXML_MAJOR_VERSION \* 10000 + $LIBXML_MINOR_VERSION \* 100 + $LIBXML_MICRO_VERSION`
AC_SUBST(LIBXML_MAJOR_VERSION)
AC_SUBST(LIBXML_MINOR_VERSION)
AC_SUBST(LIBXML_MICRO_VERSION)
AC_SUBST(LIBXML_VERSION)
AC_SUBST(LIBXML_VERSION_INFO)
AC_SUBST(LIBXML_VERSION_NUMBER)
VERSION=${LIBXML_VERSION}beta
VERSION=${LIBXML_VERSION}
AM_INIT_AUTOMAKE(libxml2, $VERSION)
......@@ -108,7 +111,7 @@ AC_CHECK_FUNC(isinf, , AC_CHECK_LIB(m, isinf,
[M_LIBS="-lm"; AC_DEFINE(HAVE_ISINF)]))
XML_LIBDIR='-L${libdir}'
XML_INCLUDEDIR='-I${includedir}/gnome-xml'
XML_INCLUDEDIR='-I${includedir}/libxml -I${includedir}'
XML_LIBS="-lxml $Z_LIBS $M_LIBS $LIBS"
dnl
......@@ -147,6 +150,80 @@ AC_CHECK_LIB(history, append_history,
AC_CHECK_LIB(readline, readline,
RDL_LIBS="-lreadline ${RDL_LIBS}"; AC_DEFINE(HAVE_LIBREADLINE))
dnl
dnl Aloow to disable various pieces
dnl
AC_ARG_WITH(ftp, [ --with-ftp Add the FTP support (on)])
if test "$with_ftp" = "no" ; then
echo Disabling FTP support
WITH_FTP=0
FTP_OBJ=
else
WITH_FTP=1
FTP_OBJ=nanoftp.o
fi
AC_SUBST(WITH_FTP)
AC_SUBST(FTP_OBJ)
AC_ARG_WITH(http, [ --with-http Add the HTTP support (on)])
if test "$with_http" = "no" ; then
echo Disabling HTTP support
WITH_HTTP=0
HTTP_OBJ=
else
WITH_HTTP=1
HTTP_OBJ=nanohttp.o
fi
AC_SUBST(WITH_HTTP)
AC_SUBST(HTTP_OBJ)
AC_ARG_WITH(html, [ --with-html Add the HTML support (on)])
if test "$with_html" = "no" ; then
echo Disabling HTML support
WITH_HTML=0
HTML_OBJ=
else
WITH_HTML=1
HTML_OBJ="HTMLparser.o HTMLtree.o"
fi
AC_SUBST(WITH_HTML)
AC_SUBST(HTML_OBJ)
AC_ARG_WITH(xpath, [ --with-xpath Add the XPATH support (on)])
if test "$with_xpath" = "no" ; then
echo Disabling XPATH support
WITH_XPATH=0
XPATH_OBJ=
else
WITH_XPATH=1
XPATH_OBJ=xpath.o
fi
AC_SUBST(WITH_XPATH)
AC_SUBST(XPATH_OBJ)
AC_ARG_WITH(debug, [ --with-debug Add the debugging module (on)])
if test "$with_debug" = "no" ; then
echo Disabling DEBUG support
WITH_DEBUG=0
DEBUG_OBJ=
else
WITH_DEBUG=1
DEBUG_OBJ=debugXML.o
fi
AC_SUBST(WITH_DEBUG)
AC_SUBST(DEBUG_OBJ)
AC_ARG_WITH(mem_debug, [ --with-mem-debug Add the memory debugging module (off)])
if test "$with_mem_debug" = "yes" ; then
echo Enabling memory debug support
WITH_MEM_DEBUG=1
else
WITH_MEM_DEBUG=0
fi
AC_SUBST(WITH_MEM_DEBUG)
AC_SUBST(CFLAGS)
AC_SUBST(XML_CFLAGS)
......@@ -159,5 +236,18 @@ AC_SUBST(HAVE_ISINF)
AC_SUBST(M_LIBS)
AC_SUBST(RDL_LIBS)
AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xml-config win32config.h)
dnl
dnl create the libxml link needed to get dependencies right
dnl
if test -f $srcdir/libxml
then
rm -f $srcdir/libxml libxml
(cd $srcdir ; ln -s . libxml)
(ln -s . libxml)
else
(cd $srcdir ; rm -f libxml ; ln -s . libxml)
(rm -f libxml ; ln -s . libxml)
fi
AC_OUTPUT(libxml.spec Makefile doc/Makefile example/Makefile xmlversion.h xml-config win32config.h)
......@@ -12,6 +12,10 @@
#else
#include "config.h"
#endif
#include "xmlversion.h"
#ifdef LIBXML_DEBUG_ENABLED
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
......@@ -19,13 +23,13 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "xmlmemory.h"
#include "tree.h"
#include "parser.h"
#include "valid.h"
#include "debugXML.h"
#include "HTMLtree.h"
#include "HTMLparser.h"
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/valid.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/HTMLparser.h>
#define IS_BLANK(c) \
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
......@@ -1059,10 +1063,17 @@ int
xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
xmlNodePtr node2) {
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
#ifdef LIBXML_HTML_ENABLED
if (node->type == XML_HTML_DOCUMENT_NODE)
htmlDocDump(stdout, (htmlDocPtr) node);
else
htmlNodeDumpFile(stdout, ctxt->doc, node);
#else
if (node->type == XML_DOCUMENT_NODE)
xmlDocDump(stdout, (xmlDocPtr) node);
else
xmlElemDump(stdout, ctxt->doc, node);
#endif /* LIBXML_HTML_ENABLED */
} else {
if (node->type == XML_DOCUMENT_NODE)
xmlDocDump(stdout, (xmlDocPtr) node);
......@@ -1095,7 +1106,12 @@ xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
html = (ctxt->doc->type == XML_HTML_DOCUMENT_NODE);
if (html) {
#ifdef LIBXML_HTML_ENABLED
doc = htmlParseFile(filename, NULL);
#else
printf("HTML support not compiled in\n");
doc = NULL;
#endif /* LIBXML_HTML_ENABLED */
} else {
doc = xmlParseFile(filename);
}
......@@ -1104,11 +1120,15 @@ xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
xmlFreeDoc(ctxt->doc);
}
ctxt->loaded = 1;
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeContext(ctxt->pctxt);
#endif /* LIBXML_XPATH_ENABLED */
xmlFree(ctxt->filename);
ctxt->doc = doc;
ctxt->node = (xmlNodePtr) doc;
#ifdef LIBXML_XPATH_ENABLED
ctxt->pctxt = xmlXPathNewContext(doc);
#endif /* LIBXML_XPATH_ENABLED */
ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
} else
return(-1);
......@@ -1151,10 +1171,17 @@ xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
}
break;
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_HTML_ENABLED
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
fprintf(stderr, "Failed to write to %s\n", filename);
return(-1);
}
#else
if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
fprintf(stderr, "Failed to write to %s\n", filename);
return(-1);
}
#endif /* LIBXML_HTML_ENABLED */
break;
default: {
FILE *f;
......@@ -1203,9 +1230,15 @@ xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
}
break;
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_HTML_ENABLED
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
fprintf(stderr, "Failed to save to %s\n", filename);
}
#else
if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
fprintf(stderr, "Failed to save to %s\n", filename);
}
#endif /* LIBXML_HTML_ENABLED */
break;
default:
fprintf(stderr,
......@@ -1444,11 +1477,13 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
ctxt->filename = (char *) xmlStrdup((xmlChar *) filename);
ctxt->node = (xmlNodePtr) ctxt->doc;
#ifdef LIBXML_XPATH_ENABLED
ctxt->pctxt = xmlXPathNewContext(ctxt->doc);
if (ctxt->pctxt == NULL) {
xmlFree(ctxt);
return;
}
#endif /* LIBXML_XPATH_ENABLED */
while (1) {
if (ctxt->node == (xmlNodePtr) ctxt->doc)
sprintf(prompt, "%s > ", "/");
......@@ -1503,10 +1538,14 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlShellList(ctxt, NULL, ctxt->node, NULL);
} else {
ctxt->pctxt->node = ctxt->node;
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
#endif /* LIBXML_XPATH_ENABLED */
if (list != NULL) {
switch (list->type) {
case XPATH_UNDEFINED:
......@@ -1539,8 +1578,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
fprintf(stderr, "%s: no such node\n", arg);
}
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
#endif /* LIBXML_XPATH_ENABLED */
ctxt->pctxt->nodelist = NULL;
}
} else if (!strcmp(command, "cd")) {
......@@ -1548,10 +1589,14 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
ctxt->node = (xmlNodePtr) ctxt->doc;
} else {
ctxt->pctxt->node = ctxt->node;
#ifdef LIBXML_XPATH_ENABLED
if (ctxt->pctxt->nodelist != NULL)
xmlXPathFreeNodeSet(ctxt->pctxt->nodelist);
ctxt->pctxt->nodelist = xmlXPathNodeSetCreate(ctxt->node);
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
#endif /* LIBXML_XPATH_ENABLED */
if (list != NULL) {
switch (list->type) {
case XPATH_UNDEFINED:
......@@ -1578,8 +1623,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else {
fprintf(stderr, "%s: no such node\n", arg);