Permalink
Browse files

Release 0.2, 80% rewrite, nothing left intact ... Daniel

  • Loading branch information...
Daniel Veillard
Daniel Veillard committed Aug 13, 1998
1 parent a65771c commit 260a68fd34302f352aa8f4c2f2901cefa3e1d2f7
Showing with 6,508 additions and 2,661 deletions.
  1. +8 −0 ChangeLog
  2. +10 −6 Makefile.am
  3. +34 −0 Makefile.win
  4. +223 −0 SAX.c
  5. +12 −13 TODO
  6. +5 −5 autogen.sh
  7. +62 −0 config.h
  8. +2 −2 configure.in
  9. +426 −0 entities.c
  10. +20 −8 xml_entities.h → entities.h
  11. +93 −0 error.c
  12. +70 −0 include/libxml/entities.h
  13. +168 −0 include/libxml/parser.h
  14. +180 −0 include/libxml/tree.h
  15. +3,334 −0 parser.c
  16. +168 −0 parser.h
  17. +1 −6 result/dav1
  18. +1 −5 result/dav10
  19. +1 −5 result/dav11
  20. +1 −5 result/dav12
  21. +1 −5 result/dav13
  22. +0 −17 result/dav14
  23. +1 −6 result/dav15
  24. +1 −5 result/dav16
  25. +1 −5 result/dav17
  26. +1 −5 result/dav18
  27. +1 −5 result/dav19
  28. +1 −6 result/dav2
  29. +1 −6 result/dav3
  30. +1 −6 result/dav4
  31. +1 −6 result/dav5
  32. +1 −5 result/dav6
  33. +1 −5 result/dav7
  34. +1 −5 result/dav8
  35. +1 −5 result/dav9
  36. +3 −0 result/dtd1
  37. +7 −0 result/ent1
  38. +10 −0 result/ent2
  39. +7 −0 result/ent3
  40. +6 −10 result/p3p
  41. +81 −0 result/rdf1
  42. +1 −1 test/dav1
  43. +1 −1 test/dav10
  44. +1 −1 test/dav11
  45. +1 −1 test/dav12
  46. +1 −1 test/dav13
  47. +0 −10 test/dav14
  48. +1 −1 test/dav15
  49. +1 −1 test/dav16
  50. +1 −1 test/dav17
  51. +1 −1 test/dav18
  52. +1 −1 test/dav19
  53. +1 −1 test/dav2
  54. +1 −1 test/dav3
  55. +1 −1 test/dav4
  56. +1 −1 test/dav5
  57. +1 −1 test/dav6
  58. +1 −1 test/dav7
  59. +1 −1 test/dav8
  60. +1 −1 test/dav9
  61. +5 −0 test/dtd1
  62. +7 −0 test/ent1
  63. +11 −0 test/ent2
  64. +8 −0 test/ent3
  65. +1 −0 test/p3p
  66. +83 −0 test/rdf1
  67. +39 −35 tester.c
  68. +1,209 −0 tree.c
  69. +180 −0 tree.h
  70. +0 −353 xml_entities.c
  71. +0 −1,183 xml_parser.c
  72. +0 −61 xml_parser.h
  73. +0 −731 xml_tree.c
  74. +0 −113 xml_tree.h
View
@@ -1,3 +1,11 @@
+Wed Aug 12 23:12:58 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
+
+ * New release 0.2, removed the old xml_* files so that it's
+ coherent with the other CVS base (W3C), far better conformance
+ to standard, new namespaces, decent entities support, beginning
+ of a SAX-like interface. Nearly nothing left intact, even the
+ test examples ...
+
1998-07-30 Christopher Blizzard <blizzard@appliedtheory.com>
* .cvsignore: Add .deps dir
View
@@ -5,14 +5,18 @@ noinst_PROGRAMS=tester
lib_LTLIBRARIES = libxml.la
libxml_la_SOURCES = \
- xml_entities.c \
- xml_parser.c \
- xml_tree.c
+ SAX.c \
+ entities.c \
+ error.c \
+ parser.c \
+ tester.c \
+ tree.c
+
include_HEADERS = \
- xml_entities.h \
- xml_parser.h \
- xml_tree.h
+ entities.h \
+ parser.h \
+ tree.h
DEPS = $(top_builddir)/libxml.la
LDADDS = $(top_builddir)/libxml.la @Z_LIBS@
View
@@ -0,0 +1,34 @@
+# This is a makefile for win32 systems (VC 5.0).
+# Christopher Blizzard
+# http://odin.appliedtheory.com/
+
+CC = cl
+CFLAGS = /c /GB /Gi /nologo /I. /DWIN32 /MT /Zi
+
+LD = link
+LDFLAGS = /DEBUG /NODEFAULTLIB:libc
+
+AR = lib
+
+all: xml.lib
+
+test: tester.exe
+
+SHARED_OBJS = entities.obj parser.obj tree.obj SAX.obj
+
+xml.lib: $(SHARED_OBJS)
+ $(AR) /out:xml.lib $(SHARED_OBJS)
+
+tester.obj: $(SHARED_OBJS)
+ $(CC) $(CFLAGS) tester.c /out:tester.obj
+
+tester.exe: tester.obj xml.lib
+ $(LD) $(LDFLAGS) /out:tester.exe tester.obj xml.lib
+
+clean:
+ -del /f $(SHARED_OBJS) tester.obj
+ -del /f tester.exe
+ -del /f xml.lib
+ -del /f *.pdb
+ -del /f *.idb
+ -del /f *.ilk
View
223 SAX.c
@@ -0,0 +1,223 @@
+/*
+ * SAX.c : Default SAX handler to build a tree.
+ */
+
+#include <stdio.h>
+#include <malloc.h>
+#include "tree.h"
+#include "parser.h"
+#include "error.h"
+
+/* #define DEBUG_SAX */
+
+/*
+ * Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
+ */
+const CHAR *getPublicId(xmlParserCtxtPtr ctxt) {
+ return(NULL);
+}
+
+/*
+ * Return the system ID, basically URI or filename e.g.
+ * http://www.sgmlsource.com/dtds/memo.dtd
+ */
+const CHAR *getSystemId(xmlParserCtxtPtr ctxt) {
+ return(ctxt->input->filename);
+}
+
+/*
+ * Return the line number of the current parsing point.
+ */
+int getLineNumber(xmlParserCtxtPtr ctxt) {
+ return(ctxt->input->line);
+}
+/*
+ * Return the column number of the current parsing point.
+ */
+int getColumnNumber(xmlParserCtxtPtr ctxt) {
+ return(ctxt->input->col);
+}
+
+/*
+ * The default SAX Locator.
+ */
+
+xmlSAXLocator xmlDefaultSAXLocator = {
+ getPublicId, getSystemId, getLineNumber, getColumnNumber
+};
+
+/*
+ * Special entity resolver, better left to the parser, it has
+ * more context than the application layer.
+ */
+xmlParserInputPtr resolveEntity(xmlParserCtxtPtr ctxt,
+ const CHAR *publicId, const CHAR *systemId) {
+
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId);
+#endif
+ return(NULL);
+}
+
+/*
+ * What to do when a notation declaration has been parsed.
+ * TODO Not handled currently.
+ */
+void notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
+ const CHAR *publicId, const CHAR *systemId) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
+#endif
+}
+
+/*
+ * What to do when an unparsed entity declaration is parsed
+ * TODO Create an Entity node.
+ */
+void unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
+ const CHAR *publicId, const CHAR *systemId,
+ const CHAR *notationName) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
+ name, publicId, systemId, notationName);
+#endif
+}
+
+/*
+ * Receive the document locator at startup, actually xmlDefaultSAXLocator
+ * Everything is available on the context, so this is useless in our case.
+ */
+void setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.setDocumentLocator()\n");
+#endif
+}
+
+/*
+ * called when the document start being processed.
+ */
+void startDocument(xmlParserCtxtPtr ctxt) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.startDocument()\n");
+#endif
+}
+
+/*
+ * called when the document end has been detected.
+ */
+void endDocument(xmlParserCtxtPtr ctxt) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.endDocument()\n");
+#endif
+}
+
+/*
+ * called when an opening tag has been processed.
+ * TODO We currently have a small pblm with the arguments ...
+ */
+void startElement(xmlParserCtxtPtr ctxt, const CHAR *name) {
+ xmlNodePtr parent;
+
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.startElement(%s)\n", name);
+#endif
+ if (ctxt->nodeNr < 2) return;
+ parent = ctxt->nodeTab[ctxt->nodeNr - 2];
+ if (parent != NULL)
+ xmlAddChild(parent, ctxt->node);
+
+}
+
+/*
+ * called when the end of an element has been detected.
+ */
+void endElement(xmlParserCtxtPtr ctxt, const CHAR *name) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.endElement(%s)\n", name);
+#endif
+}
+
+/*
+ * receiving some chars from the parser.
+ * Question: how much at a time ???
+ */
+void characters(xmlParserCtxtPtr ctxt, const CHAR *ch,
+ int start, int len) {
+ xmlNodePtr lastChild;
+
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.characters(%.30s, %d, %d)\n", ch, start, len);
+#endif
+ /*
+ * Handle the data if any. If there is no child
+ * add it as content, otherwise if the last child is text,
+ * concatenate it, else create a new node of type text.
+ */
+
+ lastChild = xmlGetLastChild(ctxt->node);
+ if (lastChild == NULL)
+ xmlNodeAddContentLen(ctxt->node, &ch[start], len);
+ else {
+ if (xmlNodeIsText(lastChild))
+ xmlTextConcat(lastChild, &ch[start], len);
+ else {
+ lastChild = xmlNewTextLen(&ch[start], len);
+ xmlAddChild(ctxt->node, lastChild);
+ }
+ }
+}
+
+/*
+ * receiving some ignorable whitespaces from the parser.
+ * Question: how much at a time ???
+ */
+void ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch,
+ int start, int len) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d, %d)\n", ch, start, len);
+#endif
+}
+
+/*
+ * A processing instruction has beem parsed.
+ */
+void processingInstruction(xmlParserCtxtPtr ctxt, const CHAR *target,
+ const CHAR *data) {
+#ifdef DEBUG_SAX
+ fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data);
+#endif
+}
+
+xmlSAXHandler xmlDefaultSAXHandler = {
+ resolveEntity,
+ notationDecl,
+ unparsedEntityDecl,
+ setDocumentLocator,
+ startDocument,
+ endDocument,
+ startElement,
+ endElement,
+ characters,
+ ignorableWhitespace,
+ processingInstruction,
+ xmlParserWarning,
+ xmlParserError,
+ xmlParserError,
+};
+
+void xmlDefaultSAXHandlerInit(void) {
+ xmlDefaultSAXHandler.resolveEntity = resolveEntity;
+ xmlDefaultSAXHandler.notationDecl = notationDecl;
+ xmlDefaultSAXHandler.unparsedEntityDecl = unparsedEntityDecl;
+ xmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
+ xmlDefaultSAXHandler.startDocument = startDocument;
+ xmlDefaultSAXHandler.endDocument = endDocument;
+ xmlDefaultSAXHandler.startElement = startElement;
+ xmlDefaultSAXHandler.endElement = endElement;
+ xmlDefaultSAXHandler.characters = characters;
+ xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
+ xmlDefaultSAXHandler.processingInstruction = processingInstruction;
+ xmlDefaultSAXHandler.warning = xmlParserWarning;
+ xmlDefaultSAXHandler.error = xmlParserError;
+ xmlDefaultSAXHandler.fatalError = xmlParserError;
+}
View
25 TODO
@@ -1,30 +1,29 @@
TODO for the XML parser:
-- Support for UTF-8 encoding
-- progressive parsing. Currently the parser uses a single
- string containing the full document. The good point is
- that there is no context associated with the parser, the
- full state is in the stack. The bad point is that such a
- recursive design is hard to make progressive ...
-- Better error handling, use a dedicated, overridable error
- handling function.
-- Keep track of line numbers for better error reporting.
+- Support for UTF-8 and UTF-16 encoding (Urgent !!!).
+- progressive parsing. The entity support is a first step toward
+ asbtraction of an input stream. A large part of the context is still
+ located on the stack, moving to a state machine and putting everyting
+ in the parsing context should provide an adequate solution.
- DOM support, instead of using a proprietary in memory
format for the document representation, the parser should
call a DOM API to actually build the resulting document.
Then the parser becomes independent of the in-memory
representation of the document. Even better using RPC's
the parser can actually build the document in another
program.
-- finish the support for Entities.
- Support for Comments (bad, should be in ASAP, they are parsed
- but not stored).
-- Support for PI.
-- Support for CDATA.
+ but not stored), should be configurable.
+- Improve the support of entities on save (+SAX).
Done:
- C++ support : John Ehresman <jehresma@dsg.harvard.edu>
- Updated code to follow more recent specs, added compatibility flag
+- Better error handling, use a dedicated, overridable error
+ handling function.
+- Support for CDATA.
+- Keep track of line numbers for better error reporting.
+- Support for PI (SAX one).
$Id$
View
@@ -5,23 +5,23 @@ DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
- echo "You must have autoconf installed to compile GLIB."
+ echo "You must have autoconf installed to compile gnome-xml."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
- echo "You must have libtool installed to compile GLIB."
+ echo "You must have libtool installed to compile gnome-xml."
echo "Get ftp://alpha.gnu.org/gnu/libtool-1.0h.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
- echo "You must have automake installed to compile GLIB."
+ echo "You must have automake installed to compile gnome-xml."
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
@@ -31,8 +31,8 @@ if test "$DIE" -eq 1; then
exit 1
fi
-test -f xml_entities.h || {
- echo "You must run this script in the top-level GLIB directory"
+test -f entities.h || {
+ echo "You must run this script in the top-level gnome-xml directory"
exit 1
}
Oops, something went wrong.

0 comments on commit 260a68f

Please sign in to comment.