Skip to content
Browse files

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

  • Loading branch information...
1 parent a65771c commit 260a68fd34302f352aa8f4c2f2901cefa3e1d2f7 Daniel Veillard committed
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
8 ChangeLog
@@ -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
16 Makefile.am
@@ -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
34 Makefile.win
@@ -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,15 +1,11 @@
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.
@@ -17,14 +13,17 @@
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
10 autogen.sh
@@ -5,7 +5,7 @@ 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
@@ -13,7 +13,7 @@ DIE=0
(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
@@ -21,7 +21,7 @@ DIE=0
(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
}
View
62 config.h
@@ -0,0 +1,62 @@
+/* config.h. Generated automatically by configure. */
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if you have the strftime function. */
+#define HAVE_STRFTIME 1
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you have the snprintf function. */
+#define HAVE_SNPRINTF 1
+
+/* Define if you have the strdup function. */
+#define HAVE_STRDUP 1
+
+/* Define if you have the strerror function. */
+#define HAVE_STRERROR 1
+
+/* Define if you have the strndup function. */
+#define HAVE_STRNDUP 1
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define if you have the <ndir.h> header file. */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define if you have the <sys/dir.h> header file. */
+/* #undef HAVE_SYS_DIR_H */
+
+/* Define if you have the <sys/ndir.h> header file. */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <zlib.h> header file. */
+#define HAVE_ZLIB_H 1
View
4 configure.in
@@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.2)
-AC_INIT(xml_entities.h)
+AC_INIT(entities.h)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libxml, 0.10)
+AM_INIT_AUTOMAKE(libxml, 0.20)
dnl Checks for programs.
AC_PROG_CC
View
426 entities.c
@@ -0,0 +1,426 @@
+/*
+ * entities.c : implementation for the XML entities handking
+ *
+ * See Copyright for the status of this software.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include "entities.h"
+
+/*
+ * The XML predefined entities.
+ */
+
+struct xmlPredefinedEntityValue {
+ const char *name;
+ const char *value;
+};
+struct xmlPredefinedEntityValue xmlPredefinedEntityValues[] = {
+ { "lt", "<" },
+ { "gt", ">" },
+ { "apos", "'" },
+ { "quot", "\"" },
+ { "amp", "&" }
+};
+
+xmlEntitiesTablePtr xmlPredefinedEntities = NULL;
+
+/*
+ * A buffer used for converting entities to their equivalent and back.
+ */
+static int buffer_size = 0;
+static CHAR *buffer = NULL;
+
+void growBuffer(void) {
+ buffer_size *= 2;
+ buffer = (CHAR *) realloc(buffer, buffer_size * sizeof(CHAR));
+ if (buffer == NULL) {
+ perror("realloc failed");
+ exit(1);
+ }
+}
+
+/*
+ * xmlFreeEntity : clean-up an entity record.
+ */
+
+void xmlFreeEntity(xmlEntityPtr entity) {
+ if (entity == NULL) return;
+
+ if (entity->name != NULL)
+ free((char *) entity->name);
+ if (entity->ExternalID != NULL)
+ free((char *) entity->ExternalID);
+ if (entity->SystemID != NULL)
+ free((char *) entity->SystemID);
+ if (entity->content != NULL)
+ free((char *) entity->content);
+ memset(entity, -1, sizeof(xmlEntity));
+}
+
+/*
+ * xmlAddDocEntity : register a new entity for an entities table.
+ *
+ * TODO !!! We should check here that the combination of type
+ * ExternalID and SystemID is valid.
+ */
+static void xmlAddEntity(xmlEntitiesTablePtr table, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content) {
+ int i;
+ xmlEntityPtr cur;
+ int len;
+
+ for (i = 0;i < table->nb_entities;i++) {
+ cur = &table->table[i];
+ if (!xmlStrcmp(cur->name, name)) {
+ /*
+ * The entity is already defined in this Dtd, the spec says to NOT
+ * override it ... Is it worth a Warning ??? !!!
+ */
+ return;
+ }
+ }
+ if (table->nb_entities >= table->max_entities) {
+ /*
+ * need more elements.
+ */
+ table->max_entities *= 2;
+ table->table = (xmlEntityPtr)
+ realloc(table->table, table->max_entities * sizeof(xmlEntity));
+ if (table->table) {
+ perror("realloc failed");
+ exit(1);
+ }
+ }
+ cur = &table->table[table->nb_entities];
+ cur->name = xmlStrdup(name);
+ for (len = 0;name[0] != 0;name++)len++;
+ cur->len = len;
+ cur->type = type;
+ if (ExternalID != NULL)
+ cur->ExternalID = xmlStrdup(ExternalID);
+ else
+ cur->ExternalID = NULL;
+ if (SystemID != NULL)
+ cur->SystemID = xmlStrdup(SystemID);
+ else
+ cur->SystemID = NULL;
+ if (content != NULL)
+ cur->content = xmlStrdup(content);
+ else
+ cur->content = NULL;
+ table->nb_entities++;
+}
+
+/*
+ * Set up xmlPredefinedEntities from xmlPredefinedEntityValues.
+ */
+void xmlInitializePredefinedEntities(void) {
+ int i;
+ CHAR name[50];
+ CHAR value[50];
+ const char *in;
+ CHAR *out;
+
+ if (xmlPredefinedEntities != NULL) return;
+
+ xmlPredefinedEntities = xmlCreateEntitiesTable();
+ for (i = 0;i < sizeof(xmlPredefinedEntityValues) /
+ sizeof(xmlPredefinedEntityValues[0]);i++) {
+ in = xmlPredefinedEntityValues[i].name;
+ out = &name[0];
+ for (;(*out++ = (CHAR) *in);)in++;
+ in = xmlPredefinedEntityValues[i].value;
+ out = &value[0];
+ for (;(*out++ = (CHAR) *in);)in++;
+ xmlAddEntity(xmlPredefinedEntities, (const CHAR *) &name[0],
+ XML_INTERNAL_GENERAL_ENTITY, NULL, NULL,
+ &value[0]);
+ }
+}
+
+
+/*
+ * xmlAddDtdEntity : register a new entity for this DTD.
+ */
+void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content) {
+ xmlEntitiesTablePtr table;
+
+ if (doc->dtd == NULL) {
+ fprintf(stderr, "xmlAddDtdEntity: document without Dtd !\n");
+ return;
+ }
+ table = (xmlEntitiesTablePtr) doc->dtd->entities;
+ if (table == NULL) {
+ table = xmlCreateEntitiesTable();
+ doc->dtd->entities = table;
+ }
+ xmlAddEntity(table, name, type, ExternalID, SystemID, content);
+}
+
+/*
+ * xmlAddDocEntity : register a new entity for this document.
+ */
+void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content) {
+ xmlEntitiesTablePtr table;
+
+ table = (xmlEntitiesTablePtr) doc->entities;
+ if (table == NULL) {
+ table = xmlCreateEntitiesTable();
+ doc->entities = table;
+ }
+ xmlAddEntity(doc->entities, name, type, ExternalID, SystemID, content);
+}
+
+/*
+ * xmlGetDtdEntity : do an entity lookup in the Dtd entity hash table and
+ * returns the corrsponding entity, if found, NULL otherwise.
+ */
+xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name) {
+ int i;
+ xmlEntityPtr cur;
+ xmlEntitiesTablePtr table;
+
+ if ((doc->dtd != NULL) && (doc->dtd->entities != NULL)) {
+ table = (xmlEntitiesTablePtr) doc->dtd->entities;
+ for (i = 0;i < table->nb_entities;i++) {
+ cur = &table->table[i];
+ if (!xmlStrcmp(cur->name, name)) return(cur);
+ }
+ }
+ return(NULL);
+}
+
+/*
+ * xmlGetDocEntity : do an entity lookup in the document entity hash table and
+ * returns the corrsponding entity, otherwise a lookup is done
+ * in the predefined entities too.
+ */
+xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
+ int i;
+ xmlEntityPtr cur;
+ xmlEntitiesTablePtr table;
+
+ if (doc->entities != NULL) {
+ table = (xmlEntitiesTablePtr) doc->entities;
+ for (i = 0;i < table->nb_entities;i++) {
+ cur = &table->table[i];
+ if (!xmlStrcmp(cur->name, name)) return(cur);
+ }
+ }
+ if (xmlPredefinedEntities == NULL)
+ xmlInitializePredefinedEntities();
+ table = xmlPredefinedEntities;
+ for (i = 0;i < table->nb_entities;i++) {
+ cur = &table->table[i];
+ if (!xmlStrcmp(cur->name, name)) return(cur);
+ }
+
+ return(NULL);
+}
+
+/*
+ * xmlEncodeEntities : do a global encoding of a string, replacing the
+ * basic content with their entities form.
+ * TODO !!!! rewite !!!
+ */
+CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input) {
+ const CHAR *cur = input;
+ CHAR *out = buffer;
+
+ if (buffer == NULL) {
+ buffer_size = 1000;
+ buffer = (CHAR *) malloc(buffer_size * sizeof(CHAR));
+ if (buffer == NULL) {
+ perror("malloc failed");
+ exit(1);
+ }
+ out = buffer;
+ }
+ while (*cur != '\0') {
+ if (out - buffer > buffer_size - 100) {
+ int index = out - buffer;
+
+ growBuffer();
+ out = &buffer[index];
+ }
+
+ /*
+ * By default one have to encode at least '<', '>', '"' and '&' !
+ * One could try a better encoding using the entities defined and
+ * used as a compression code !!!.
+ */
+ if (*cur == '<') {
+ *out++ = '&';
+ *out++ = 'l';
+ *out++ = 't';
+ *out++ = ';';
+ } else if (*cur == '>') {
+ *out++ = '&';
+ *out++ = 'g';
+ *out++ = 't';
+ *out++ = ';';
+ } else if (*cur == '&') {
+ *out++ = '&';
+ *out++ = 'a';
+ *out++ = 'm';
+ *out++ = 'p';
+ *out++ = ';';
+ } else if (*cur == '"') {
+ *out++ = '&';
+ *out++ = 'q';
+ *out++ = 'u';
+ *out++ = 'o';
+ *out++ = 't';
+ *out++ = ';';
+ } else if (*cur == '\'') {
+ *out++ = '&';
+ *out++ = 'a';
+ *out++ = 'p';
+ *out++ = 'o';
+ *out++ = 's';
+ *out++ = ';';
+ } else {
+ /*
+ * default case, just copy !
+ */
+ *out++ = *cur;
+ }
+ cur++;
+ }
+ *out++ = 0;
+ return(buffer);
+}
+
+/*
+ * xmlCreateEntitiesTable : create and initialize an enmpty hash table
+ */
+xmlEntitiesTablePtr xmlCreateEntitiesTable(void) {
+ xmlEntitiesTablePtr ret;
+
+ ret = (xmlEntitiesTablePtr)
+ malloc(sizeof(xmlEntitiesTable));
+ if (ret == NULL) {
+ fprintf(stderr, "xmlCreateEntitiesTable : malloc(%d) failed\n",
+ sizeof(xmlEntitiesTable));
+ return(NULL);
+ }
+ ret->max_entities = XML_MIN_ENTITIES_TABLE;
+ ret->nb_entities = 0;
+ ret->table = (xmlEntityPtr )
+ malloc(ret->max_entities * sizeof(xmlEntity));
+ if (ret == NULL) {
+ fprintf(stderr, "xmlCreateEntitiesTable : malloc(%d) failed\n",
+ ret->max_entities * sizeof(xmlEntity));
+ free(ret);
+ return(NULL);
+ }
+ return(ret);
+}
+
+/*
+ * xmlFreeEntitiesTable : clean up and free an entities hash table.
+ */
+void xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
+ int i;
+
+ if (table == NULL) return;
+
+ for (i = 0;i < table->nb_entities;i++) {
+ xmlFreeEntity(&table->table[i]);
+ }
+ free(table->table);
+ free(table);
+}
+
+/*
+ * Dump the content of an entity table to the document output.
+ */
+void xmlDumpEntitiesTable(xmlEntitiesTablePtr table) {
+ int i;
+ xmlEntityPtr cur;
+
+ if (table == NULL) return;
+
+ for (i = 0;i < table->nb_entities;i++) {
+ cur = &table->table[i];
+ switch (cur->type) {
+ case XML_INTERNAL_GENERAL_ENTITY:
+ xmlBufferWriteChar("<!ENTITY ");
+ xmlBufferWriteCHAR(cur->name);
+ xmlBufferWriteChar(" \"");
+ xmlBufferWriteCHAR(cur->content);
+ xmlBufferWriteChar("\">\n");
+ break;
+ case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
+ xmlBufferWriteChar("<!ENTITY ");
+ xmlBufferWriteCHAR(cur->name);
+ if (cur->ExternalID != NULL) {
+ xmlBufferWriteChar(" PUBLIC \"");
+ xmlBufferWriteCHAR(cur->ExternalID);
+ xmlBufferWriteChar("\" \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ } else {
+ xmlBufferWriteChar(" SYSTEM \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ }
+ xmlBufferWriteChar(">\n");
+ break;
+ case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
+ xmlBufferWriteChar("<!ENTITY ");
+ xmlBufferWriteCHAR(cur->name);
+ if (cur->ExternalID != NULL) {
+ xmlBufferWriteChar(" PUBLIC \"");
+ xmlBufferWriteCHAR(cur->ExternalID);
+ xmlBufferWriteChar("\" \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ } else {
+ xmlBufferWriteChar(" SYSTEM \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ }
+ if (cur->content != NULL) { /* Should be true ! */
+ xmlBufferWriteChar(" NDATA ");
+ xmlBufferWriteCHAR(cur->content);
+ }
+ xmlBufferWriteChar(">\n");
+ break;
+ case XML_INTERNAL_PARAMETER_ENTITY:
+ xmlBufferWriteChar("<!ENTITY % ");
+ xmlBufferWriteCHAR(cur->name);
+ xmlBufferWriteChar(" \"");
+ xmlBufferWriteCHAR(cur->content);
+ xmlBufferWriteChar("\">\n");
+ break;
+ case XML_EXTERNAL_PARAMETER_ENTITY:
+ xmlBufferWriteChar("<!ENTITY % ");
+ xmlBufferWriteCHAR(cur->name);
+ if (cur->ExternalID != NULL) {
+ xmlBufferWriteChar(" PUBLIC \"");
+ xmlBufferWriteCHAR(cur->ExternalID);
+ xmlBufferWriteChar("\" \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ } else {
+ xmlBufferWriteChar(" SYSTEM \"");
+ xmlBufferWriteCHAR(cur->SystemID);
+ xmlBufferWriteChar("\"");
+ }
+ xmlBufferWriteChar(">\n");
+ break;
+ default:
+ fprintf(stderr,
+ "xmlDumpEntitiesTable: internal: unknown type %d\n",
+ cur->type);
+ }
+ }
+}
View
28 xml_entities.h → entities.h
@@ -8,21 +8,31 @@
#ifndef __XML_ENTITIES_H__
#define __XML_ENTITIES_H__
-#include "xml_parser.h"
+#include "parser.h"
#ifdef __cplusplus
extern "C" {
#endif
+#define XML_INTERNAL_GENERAL_ENTITY 1
+#define XML_EXTERNAL_GENERAL_PARSED_ENTITY 2
+#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 3
+#define XML_INTERNAL_PARAMETER_ENTITY 4
+#define XML_EXTERNAL_PARAMETER_ENTITY 5
+
/*
* An unit of storage for an entity, contains the string, the value
* and the linkind data needed for the linking in the hash table.
*/
typedef struct xmlEntity {
- const CHAR *id; /* The entity name */
- CHAR *value; /* The entity CHAR equivalent */
+ int type; /* The entity type */
+ int len; /* The lenght of the name */
+ const CHAR *name; /* Name of the entity */
+ const CHAR *ExternalID; /* External identifier for PUBLIC Entity */
+ const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
+ CHAR *content; /* The entity content or ndata if unparsed */
} xmlEntity, *xmlEntityPtr;
/*
@@ -42,14 +52,16 @@ typedef struct xmlEntitiesTable {
* External functions :
*/
-extern void xmlAddDocEntity(xmlDocPtr doc, CHAR *value, const CHAR *id);
-extern void xmlAddDtdEntity(xmlDtdPtr dtd, CHAR *value, const CHAR *id);
-extern CHAR *xmlGetEntity(xmlDocPtr doc, const CHAR *id);
-extern CHAR *xmlSubstituteEntities(xmlDocPtr doc, const CHAR *input);
+extern void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
+extern void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
+extern xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
+extern xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
extern CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
-extern CHAR *xmlDecodeEntities(xmlDocPtr doc, const CHAR *input, int len);
extern xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
extern void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
+extern void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
#ifdef __cplusplus
}
View
93 error.c
@@ -0,0 +1,93 @@
+/*
+ * error.c: module displaying errors
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "parser.h"
+
+/*
+ * Display and format error messages.
+ */
+void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...) {
+ const CHAR *cur, *base;
+ va_list args;
+ int n;
+
+ va_start(args, msg);
+ if (ctxt->input->filename)
+ fprintf(stderr, "%s:%d: ", ctxt->input->filename,
+ ctxt->input->line);
+ else
+ fprintf(stderr, "line %d: ", ctxt->input->line);
+
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, msg, args);
+ va_end(ap);
+ cur = ctxt->input->cur;
+ base = ctxt->input->base;
+ while ((*cur == '\n') || (*cur == '\r')) {
+ cur--;
+ base--;
+ }
+ n = 0;
+ while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
+ cur--;
+ if ((*cur == '\n') || (*cur == '\r')) cur++;
+ base = cur;
+ n = 0;
+ while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
+ fprintf(stderr, "%c", (unsigned char) *cur++);
+ n++;
+ }
+ fprintf(stderr, "\n");
+ cur = ctxt->input->cur;
+ while ((*cur == '\n') || (*cur == '\r'))
+ cur--;
+ n = 0;
+ while ((cur != base) && (n++ < 60)) {
+ fprintf(stderr, " ");
+ base++;
+ }
+ fprintf(stderr,"^\n");
+}
+
+/*
+ * Display and format error messages.
+ */
+void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...) {
+ const CHAR *cur, *base;
+ va_list args;
+ int n;
+
+ va_start(args, msg);
+ if (ctxt->input->filename)
+ fprintf(stderr, "%s:%d: ", ctxt->input->filename,
+ ctxt->input->line);
+ else
+ fprintf(stderr, "line %d: ", ctxt->input->line);
+
+ fprintf(stderr, "warning: ");
+ vfprintf(stderr, msg, args);
+ va_end(ap);
+ cur = ctxt->input->cur;
+ base = ctxt->input->base;
+ n = 0;
+ while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
+ cur--;
+ if ((*cur != '\n') || (*cur != '\r')) cur++;
+ base = cur;
+ n = 0;
+ while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
+ fprintf(stderr, "%c", (unsigned char) *cur++);
+ n++;
+ }
+ fprintf(stderr, "\n");
+ cur = ctxt->input->cur;
+ n = 0;
+ while ((cur != base) && (n++ < 60)) {
+ fprintf(stderr, " ");
+ base++;
+ }
+ fprintf(stderr,"^\n");
+}
View
70 include/libxml/entities.h
@@ -0,0 +1,70 @@
+/*
+ * entities.h : interface for the XML entities handking
+ *
+ * See Copyright for the status of this software.
+ *
+ * $Id$
+ */
+
+#ifndef __XML_ENTITIES_H__
+#define __XML_ENTITIES_H__
+#include "parser.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define XML_INTERNAL_GENERAL_ENTITY 1
+#define XML_EXTERNAL_GENERAL_PARSED_ENTITY 2
+#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 3
+#define XML_INTERNAL_PARAMETER_ENTITY 4
+#define XML_EXTERNAL_PARAMETER_ENTITY 5
+
+/*
+ * An unit of storage for an entity, contains the string, the value
+ * and the linkind data needed for the linking in the hash table.
+ */
+
+typedef struct xmlEntity {
+ int type; /* The entity type */
+ int len; /* The lenght of the name */
+ const CHAR *name; /* Name of the entity */
+ const CHAR *ExternalID; /* External identifier for PUBLIC Entity */
+ const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
+ CHAR *content; /* The entity content or ndata if unparsed */
+} xmlEntity, *xmlEntityPtr;
+
+/*
+ * ALl entities are stored in a table there is one table per DTD
+ * and one extra per document.
+ */
+
+#define XML_MIN_ENTITIES_TABLE 32
+
+typedef struct xmlEntitiesTable {
+ int nb_entities; /* number of elements stored */
+ int max_entities; /* maximum number of elements */
+ xmlEntityPtr table; /* the table of entities */
+} xmlEntitiesTable, *xmlEntitiesTablePtr;
+
+/*
+ * External functions :
+ */
+
+extern void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
+extern void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
+ const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
+extern xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
+extern xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
+extern CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
+extern xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
+extern void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
+extern void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
+
+#ifdef __cplusplus
+}
+#endif
+
+# endif /* __XML_ENTITIES_H__ */
View
168 include/libxml/parser.h
@@ -0,0 +1,168 @@
+/*
+ * parser.h : constants and stuff related to the XML parser.
+ *
+ * See Copyright for the status of this software.
+ *
+ * $Id$
+ */
+
+#ifndef __XML_PARSER_H__
+#define __XML_PARSER_H__
+
+#include "tree.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Constants.
+ */
+#define XML_DEFAULT_VERSION "1.0"
+
+typedef struct xmlParserInput {
+ const char *filename; /* The file analyzed, if any */
+ const CHAR *base; /* Base of the array to parse */
+ const CHAR *cur; /* Current char being parsed */
+ int line; /* Current line */
+ int col; /* Current column */
+} xmlParserInput, *xmlParserInputPtr;
+
+typedef struct xmlParserNodeInfo {
+ const struct xmlNode* node;
+ /* Position & line # that text that created the node begins & ends on */
+ unsigned long begin_pos;
+ unsigned long begin_line;
+ unsigned long end_pos;
+ unsigned long end_line;
+} xmlParserNodeInfo;
+
+typedef struct xmlParserNodeInfoSeq {
+ unsigned long maximum;
+ unsigned long length;
+ xmlParserNodeInfo* buffer;
+} xmlParserNodeInfoSeq, *xmlParserNodeInfoSeqPtr;
+
+typedef struct xmlParserCtxt {
+ struct xmlSAXHandler *sax; /* The SAX handler */
+ xmlDocPtr doc; /* the document being built */
+
+ /* Input stream stack */
+ xmlParserInputPtr input; /* Current input stream */
+ int inputNr; /* Number of current input streams */
+ int inputMax; /* Max number of input streams */
+ xmlParserInputPtr *inputTab; /* stack of inputs */
+
+ /* Node analysis stack */
+ xmlNodePtr node; /* Current parsed Node */
+ int nodeNr; /* Depth of the parsing stack */
+ int nodeMax; /* Max depth of the parsing stack */
+ xmlNodePtr *nodeTab; /* array of nodes */
+
+ int record_info; /* Whether node info should be kept */
+ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
+} xmlParserCtxt, *xmlParserCtxtPtr;
+
+/*
+ * a SAX Locator.
+ */
+
+typedef struct xmlSAXLocator {
+ const CHAR *(*getPublicId)(xmlParserCtxtPtr ctxt);
+ const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt);
+ int (*getLineNumber)(xmlParserCtxtPtr ctxt);
+ int (*getColumnNumber)(xmlParserCtxtPtr ctxt);
+} xmlSAXLocator, *xmlSAXLocatorPtr;
+
+/*
+ * a SAX Exception.
+ */
+
+typedef xmlParserInputPtr (*resolveEntitySAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *publicId, const CHAR *systemId);
+typedef void (*notationDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name,
+ const CHAR *publicId, const CHAR *systemId);
+typedef void (*unparsedEntityDeclSAXFunc)(xmlParserCtxtPtr ctxt,
+ const CHAR *name, const CHAR *publicId,
+ const CHAR *systemId, const CHAR *notationName);
+typedef void (*setDocumentLocatorSAXFunc) (xmlParserCtxtPtr ctxt,
+ xmlSAXLocatorPtr loc);
+typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
+typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
+typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
+typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
+typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch,
+ int start, int len);
+typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *ch, int start, int len);
+typedef void (*processingInstructionSAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *target, const CHAR *data);
+typedef void (*warningSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+typedef void (*errorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+typedef void (*fatalErrorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+
+typedef struct xmlSAXHandler {
+ resolveEntitySAXFunc resolveEntity;
+ notationDeclSAXFunc notationDecl;
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
+ setDocumentLocatorSAXFunc setDocumentLocator;
+ startDocumentSAXFunc startDocument;
+ endDocumentSAXFunc endDocument;
+ startElementSAXFunc startElement;
+ endElementSAXFunc endElement;
+ charactersSAXFunc characters;
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
+ processingInstructionSAXFunc processingInstruction;
+ warningSAXFunc warning;
+ errorSAXFunc error;
+ fatalErrorSAXFunc fatalError;
+} xmlSAXHandler, *xmlSAXHandlerPtr;
+
+/*
+ * Global variables: just the SAX interface tables we are looking for full
+ * reentrancy of the code !
+ */
+xmlSAXLocator xmlDefaultSAXLocator;
+xmlSAXHandler xmlDefaultSAXHandler;
+
+/*
+ * Interfaces
+ */
+extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
+extern xmlDocPtr xmlParseDoc(CHAR *cur);
+extern xmlDocPtr xmlParseMemory(char *buffer, int size);
+extern xmlDocPtr xmlParseFile(const char *filename);
+extern CHAR *xmlStrdup(const CHAR *input);
+extern CHAR *xmlStrndup(const CHAR *input, int n);
+extern CHAR *xmlStrchr(const CHAR *str, CHAR val);
+extern int xmlStrcmp(const CHAR *str1, const CHAR *str2);
+extern int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
+extern int xmlStrlen(const CHAR *str);
+extern CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
+extern CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
+
+extern void xmlInitParserCtxt(xmlParserCtxtPtr ctx);
+extern void xmlClearParserCtxt(xmlParserCtxtPtr ctx);
+extern void xmlSetupParserForBuffer(xmlParserCtxtPtr ctx, const CHAR* buffer,
+ const char* filename);
+
+extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
+
+extern const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* c,
+ const xmlNode* node);
+extern void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
+extern void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
+unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
+ const xmlNode* node);
+extern void xmlParserAddNodeInfo(xmlParserCtxtPtr ctx,
+ const xmlParserNodeInfo* info);
+
+extern void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...);
+extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
+extern void xmlDefaultSAXHandlerInit(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_PARSER_H__ */
+
View
180 include/libxml/tree.h
@@ -0,0 +1,180 @@
+/*
+ * tree.h : describes the structures found in an tree resulting
+ * from an XML parsing.
+ *
+ * See Copyright for the status of this software.
+ *
+ * $Id$
+ */
+
+#ifndef __XML_TREE_H__
+#define __XML_TREE_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Type definitions
+ */
+#ifdef UNICODE
+typedef unsigned short CHAR;
+#else
+typedef unsigned char CHAR;
+#endif
+
+/*
+ * a DTD Notation definition
+ * TODO !!!!
+ */
+
+/*
+ * a DTD Attribute definition
+ * TODO !!!!
+ */
+
+/*
+ * a DTD Element definition.
+ */
+#define XML_ELEMENT_TYPE_EMPTY 1
+#define XML_ELEMENT_TYPE_ANY 2
+#define XML_ELEMENT_TYPE_MIXED 3
+#define XML_ELEMENT_TYPE_ELEMENT 4
+
+typedef struct xmlElement {
+ const CHAR *name; /* Element name */
+ int type; /* type (too simple, to extend ...) */
+ /* TODO !!! more needed */
+} xmlElement, *xmlElementPtr;
+
+/*
+ * An XML namespace.
+ * Note that prefix == NULL is valid, it defines the default namespace
+ * within the subtree (until overriden).
+ */
+
+#define XML_GLOBAL_NAMESPACE 1 /* old style global namespace */
+#define XML_LOCAL_NAMESPACE 2 /* new style local scoping */
+
+typedef struct xmlNs {
+ struct xmlNs *next; /* next Ns link for this node */
+ int type; /* global or local */
+ const CHAR *href; /* URL for the namespace */
+ const CHAR *prefix; /* prefix for the namespace */
+} xmlNs, *xmlNsPtr;
+
+/*
+ * An XML DtD, as defined by <!DOCTYPE.
+ */
+typedef struct xmlDtd {
+ const CHAR *name; /* Name of the DTD */
+ const CHAR *ExternalID; /* External identifier for PUBLIC DTD */
+ const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
+ void *elements; /* Hash table for elements if any */
+ void *entities; /* Hash table for entities if any */
+ /* struct xmlDtd *next; * next link for this document */
+} xmlDtd, *xmlDtdPtr;
+
+/*
+ * A attribute of an XML node.
+ */
+typedef struct xmlAttr {
+ struct xmlNode *node; /* attr->node link */
+ struct xmlAttr *next; /* parent->childs link */
+ const CHAR *name; /* the name of the property */
+ const CHAR *value; /* the value of the property */
+} xmlAttr, *xmlAttrPtr;
+
+/*
+ * A node in an XML tree.
+ */
+#define XML_TYPE_TEXT 1
+#define XML_TYPE_COMMENT 2
+#define XML_TYPE_ENTITY 3
+
+typedef struct xmlNode {
+ struct xmlNode *parent; /* child->parent link */
+ struct xmlNode *next; /* next sibling link */
+ struct xmlNode *childs; /* parent->childs link */
+ struct xmlAttr *properties; /* properties list */
+ int type; /* type number in the DTD */
+ const CHAR *name; /* the name of the node, or the entity */
+ xmlNs *ns; /* pointer to the associated namespace */
+ xmlNs *nsDef; /* namespace definitions on this node */
+ CHAR *content; /* the content */
+} xmlNode, *xmlNodePtr;
+
+/*
+ * An XML document.
+ */
+typedef struct xmlDoc {
+ char *name; /* name/filename/URI of the document */
+ const CHAR *version; /* the XML version string */
+ const CHAR *encoding; /* encoding, if any */
+ int standalone; /* standalone document (no external refs) */
+ struct xmlDtd *dtd; /* the document DTD if available */
+ struct xmlNs *oldNs; /* Global namespace, the old way */
+ void *entities; /* Hash table for general entities if any */
+ struct xmlNode *root; /* the document tree */
+} xmlDoc, *xmlDocPtr;
+
+/*
+ * Variables.
+ */
+extern xmlNsPtr baseDTD;
+extern int oldXMLWDcompatibility;/* maintain compatibility with old WD */
+extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
+
+/*
+ * Functions.
+ */
+extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
+ const CHAR *ExternalID, const CHAR *SystemID);
+extern void xmlFreeDtd(xmlDtdPtr cur);
+extern xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *AS);
+extern xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *AS);
+extern void xmlFreeNs(xmlNsPtr cur);
+extern xmlDocPtr xmlNewDoc(const CHAR *version);
+extern void xmlFreeDoc(xmlDocPtr cur);
+extern xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
+ const CHAR *value);
+extern xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
+ const CHAR *value);
+extern const CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
+extern void xmlFreePropList(xmlAttrPtr cur);
+extern void xmlFreeProp(xmlAttrPtr cur);
+extern xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name, CHAR *content);
+extern xmlNodePtr xmlNewText(const CHAR *content);
+extern xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
+extern xmlNodePtr xmlNewComment(CHAR *content);
+extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
+extern xmlNodePtr xmlGetLastChild(xmlNodePtr node);
+extern int xmlNodeIsText(xmlNodePtr node);
+extern void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
+extern void xmlFreeNodeList(xmlNodePtr cur);
+extern void xmlFreeNode(xmlNodePtr cur);
+extern void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
+extern void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
+extern void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
+extern void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
+extern xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
+ const CHAR *nameSpace);
+extern xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
+ const CHAR *href);
+extern void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
+extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
+ const CHAR *name, CHAR *content);
+
+extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
+extern void xmlDocDump(FILE *f, xmlDocPtr doc);
+extern void xmlBufferWriteCHAR(const CHAR *string);
+extern void xmlBufferWriteChar(const char *string);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_TREE_H__ */
+
View
3,334 parser.c
3,334 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
168 parser.h
@@ -0,0 +1,168 @@
+/*
+ * parser.h : constants and stuff related to the XML parser.
+ *
+ * See Copyright for the status of this software.
+ *
+ * $Id$
+ */
+
+#ifndef __XML_PARSER_H__
+#define __XML_PARSER_H__
+
+#include "tree.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Constants.
+ */
+#define XML_DEFAULT_VERSION "1.0"
+
+typedef struct xmlParserInput {
+ const char *filename; /* The file analyzed, if any */
+ const CHAR *base; /* Base of the array to parse */
+ const CHAR *cur; /* Current char being parsed */
+ int line; /* Current line */
+ int col; /* Current column */
+} xmlParserInput, *xmlParserInputPtr;
+
+typedef struct xmlParserNodeInfo {
+ const struct xmlNode* node;
+ /* Position & line # that text that created the node begins & ends on */
+ unsigned long begin_pos;
+ unsigned long begin_line;
+ unsigned long end_pos;
+ unsigned long end_line;
+} xmlParserNodeInfo;
+
+typedef struct xmlParserNodeInfoSeq {
+ unsigned long maximum;
+ unsigned long length;
+ xmlParserNodeInfo* buffer;
+} xmlParserNodeInfoSeq, *xmlParserNodeInfoSeqPtr;
+
+typedef struct xmlParserCtxt {
+ struct xmlSAXHandler *sax; /* The SAX handler */
+ xmlDocPtr doc; /* the document being built */
+
+ /* Input stream stack */
+ xmlParserInputPtr input; /* Current input stream */
+ int inputNr; /* Number of current input streams */
+ int inputMax; /* Max number of input streams */
+ xmlParserInputPtr *inputTab; /* stack of inputs */
+
+ /* Node analysis stack */
+ xmlNodePtr node; /* Current parsed Node */
+ int nodeNr; /* Depth of the parsing stack */
+ int nodeMax; /* Max depth of the parsing stack */
+ xmlNodePtr *nodeTab; /* array of nodes */
+
+ int record_info; /* Whether node info should be kept */
+ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
+} xmlParserCtxt, *xmlParserCtxtPtr;
+
+/*
+ * a SAX Locator.
+ */
+
+typedef struct xmlSAXLocator {
+ const CHAR *(*getPublicId)(xmlParserCtxtPtr ctxt);
+ const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt);
+ int (*getLineNumber)(xmlParserCtxtPtr ctxt);
+ int (*getColumnNumber)(xmlParserCtxtPtr ctxt);
+} xmlSAXLocator, *xmlSAXLocatorPtr;
+
+/*
+ * a SAX Exception.
+ */
+
+typedef xmlParserInputPtr (*resolveEntitySAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *publicId, const CHAR *systemId);
+typedef void (*notationDeclSAXFunc)(xmlParserCtxtPtr ctxt, const CHAR *name,
+ const CHAR *publicId, const CHAR *systemId);
+typedef void (*unparsedEntityDeclSAXFunc)(xmlParserCtxtPtr ctxt,
+ const CHAR *name, const CHAR *publicId,
+ const CHAR *systemId, const CHAR *notationName);
+typedef void (*setDocumentLocatorSAXFunc) (xmlParserCtxtPtr ctxt,
+ xmlSAXLocatorPtr loc);
+typedef void (*startDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
+typedef void (*endDocumentSAXFunc) (xmlParserCtxtPtr ctxt);
+typedef void (*startElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
+typedef void (*endElementSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *name);
+typedef void (*charactersSAXFunc) (xmlParserCtxtPtr ctxt, const CHAR *ch,
+ int start, int len);
+typedef void (*ignorableWhitespaceSAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *ch, int start, int len);
+typedef void (*processingInstructionSAXFunc) (xmlParserCtxtPtr ctxt,
+ const CHAR *target, const CHAR *data);
+typedef void (*warningSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+typedef void (*errorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+typedef void (*fatalErrorSAXFunc) (xmlParserCtxtPtr ctxt, const char *msg, ...);
+
+typedef struct xmlSAXHandler {
+ resolveEntitySAXFunc resolveEntity;
+ notationDeclSAXFunc notationDecl;
+ unparsedEntityDeclSAXFunc unparsedEntityDecl;
+ setDocumentLocatorSAXFunc setDocumentLocator;
+ startDocumentSAXFunc startDocument;
+ endDocumentSAXFunc endDocument;
+ startElementSAXFunc startElement;
+ endElementSAXFunc endElement;
+ charactersSAXFunc characters;
+ ignorableWhitespaceSAXFunc ignorableWhitespace;
+ processingInstructionSAXFunc processingInstruction;
+ warningSAXFunc warning;
+ errorSAXFunc error;
+ fatalErrorSAXFunc fatalError;
+} xmlSAXHandler, *xmlSAXHandlerPtr;
+
+/*
+ * Global variables: just the SAX interface tables we are looking for full
+ * reentrancy of the code !
+ */
+xmlSAXLocator xmlDefaultSAXLocator;
+xmlSAXHandler xmlDefaultSAXHandler;
+
+/*
+ * Interfaces
+ */
+extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
+extern xmlDocPtr xmlParseDoc(CHAR *cur);
+extern xmlDocPtr xmlParseMemory(char *buffer, int size);
+extern xmlDocPtr xmlParseFile(const char *filename);
+extern CHAR *xmlStrdup(const CHAR *input);
+extern CHAR *xmlStrndup(const CHAR *input, int n);
+extern CHAR *xmlStrchr(const CHAR *str, CHAR val);
+extern int xmlStrcmp(const CHAR *str1, const CHAR *str2);
+extern int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
+extern int xmlStrlen(const CHAR *str);
+extern CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
+extern CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
+
+extern void xmlInitParserCtxt(xmlParserCtxtPtr ctx);
+extern void xmlClearParserCtxt(xmlParserCtxtPtr ctx);
+extern void xmlSetupParserForBuffer(xmlParserCtxtPtr ctx, const CHAR* buffer,
+ const char* filename);
+
+extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
+
+extern const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* c,
+ const xmlNode* node);
+extern void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
+extern void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
+unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
+ const xmlNode* node);
+extern void xmlParserAddNodeInfo(xmlParserCtxtPtr ctx,
+ const xmlParserNodeInfo* info);
+
+extern void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...);
+extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
+extern void xmlDefaultSAXHandlerInit(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XML_PARSER_H__ */
+
View
7 result/dav1
@@ -1,10 +1,5 @@
-
-
-------- test/dav1 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.foo.bar/boxschema" prefix="R"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/" xmlns:R="http://www.foo.bar/boxschema">
<D:response>
<D:prop>
<R:bigbox>
View
6 result/dav10
@@ -1,8 +1,4 @@
-
-
-------- test/dav10 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:owner>
+<D:owner xmlns:D="http://www.ietf.org/standards/dav/">
<D:href>http://www.ics.uci.edu/~ejw/contact.html</D:href>
</D:owner>
View
6 result/dav11
@@ -1,9 +1,5 @@
-
-
-------- test/dav11 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:prop>
+<D:prop xmlns:D="http://www.ietf.org/standards/dav/">
<D:lockdiscovery>
<D:activelock>
<D:locktype>write</D:locktype>
View
6 result/dav12
@@ -1,6 +1,2 @@
-
-
-------- test/dav12 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:href>http://www.ics.uci.edu/~ejw/contact.html</D:href>
+<D:href xmlns:D="http://www.ietf.org/standards/dav/">http://www.ics.uci.edu/~ejw/contact.html</D:href>
View
6 result/dav13
@@ -1,9 +1,5 @@
-
-
-------- test/dav13 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/">
<D:response>
<D:href>
http://webdav.sb.aol.com/workspace/webdav/proposal.doc
View
17 result/dav14
@@ -1,17 +0,0 @@
-
-
-------- test/dav14 -----------
-<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/patch/" prefix="D"?>
-<D:resourceupdate>
- <D:replace XML-SPACE="PRESERVE">
- <D:octet-range>14</D:octet-range>
-003CTITLE003ENew
- Title003C/TITLE003E </D:replace>
- <D:delete>
- <D:octet-range>38-50</D:octet-range>
- </D:delete>
- <D:insert XML-SPACE="PRESERVE">
- <D:octet-range>86</D:octet-range>
-003CP003ENew paragraph003C/P003E </D:insert>
-</D:resourceupdate>
View
7 result/dav15
@@ -1,10 +1,5 @@
-
-
-------- test/dav15 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.foocorp.com/Project/" prefix="F"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:prop>
+<D:prop xmlns:D="http://www.ietf.org/standards/dav/" xmlns:F="http://www.foocorp.com/Project/">
<D:Source>
<D:link>
<F:projfiles>Source</F:projfiles>
View
6 result/dav16
@@ -1,9 +1,5 @@
-
-
-------- test/dav16 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:propfind>
+<D:propfind xmlns:D="http://www.ietf.org/standards/dav/">
<D:prop>
<lockdiscovery/>
</D:prop>
View
6 result/dav17
@@ -1,9 +1,5 @@
-
-
-------- test/dav17 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/">
<D:response>
<D:prop>
<D:lockdiscovery>
View
6 result/dav18
@@ -1,9 +1,5 @@
-
-
-------- test/dav18 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:propfind>
+<D:propfind xmlns:D="http://www.ietf.org/standards/dav/">
<D:prop>
<supportedlock/>
</D:prop>
View
6 result/dav19
@@ -1,9 +1,5 @@
-
-
-------- test/dav19 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/">
<D:response>
<D:prop>
<D:supportedlock>
View
7 result/dav2
@@ -1,10 +1,5 @@
-
-
-------- test/dav2 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.foo.bar/boxschema/" prefix="R"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="S"?>
-<S:multistatus>
+<S:multistatus xmlns:S="http://www.ietf.org/standards/dav/" xmlns:R="http://www.foo.bar/boxschema/">
<S:response>
<S:href>http://www.foo.bar/container/</S:href>
<S:prop>
View
7 result/dav3
@@ -1,10 +1,5 @@
-
-
-------- test/dav3 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.foo.bar/boxschema/" prefix="R"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/" xmlns:R="http://www.foo.bar/boxschema/">
<D:response>
<D:href>http://www.foo.bar/container/</D:href>
<D:prop>
View
7 result/dav4
@@ -1,10 +1,5 @@
-
-
-------- test/dav4 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.w3.com/standards/z39.50/" prefix="Z"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:propertyupdate>
+<D:propertyupdate xmlns:D="http://www.ietf.org/standards/dav/" xmlns:Z="http://www.w3.com/standards/z39.50/">
<D:set>
<D:prop>
<Z:authors>
View
7 result/dav5
@@ -1,10 +1,5 @@
-
-
-------- test/dav5 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.w3.com/standards/z39.50/" prefix="Z"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/" xmlns:Z="http://www.w3.com/standards/z39.50/">
<D:response>
<D:prop>
<Z:Authors/>
View
6 result/dav6
@@ -1,9 +1,5 @@
-
-
-------- test/dav6 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="D"?>
-<D:multistatus>
+<D:multistatus xmlns:D="http://www.ietf.org/standards/dav/">
<D:response>
<D:href>http://www.microsoft.com/user/yarong/dav_drafts/
</D:href>
View
6 result/dav7
@@ -1,9 +1,5 @@
-
-
-------- test/dav7 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="d"?>
-<d:multistatus>
+<d:multistatus xmlns:d="http://www.ietf.org/standards/dav/">
<d:response>
<d:href>http://www.foo.bar/container/resource1</d:href>
<d:href>http://www.foo.bar/container/resource2</d:href>
View
6 result/dav8
@@ -1,9 +1,5 @@
-
-
-------- test/dav8 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="d"?>
-<d:multistatus>
+<d:multistatus xmlns:d="http://www.ietf.org/standards/dav/">
<d:response>
<d:href>http://www.foo.bar/othercontainer/resource1</d:href>
<d:href>http://www.foo.bar/othercontainer/resource2</d:href>
View
6 result/dav9
@@ -1,9 +1,5 @@
-
-
-------- test/dav9 -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.ietf.org/standards/dav/" prefix="d"?>
-<d:multistatus>
+<d:multistatus xmlns:d="http://www.ietf.org/standards/dav/">
<d:response>
<d:href>http://www.foo.bar/container/resource1</d:href>
<d:href>http://www.foo.bar/container/resource2</d:href>
View
3 result/dtd1
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!DOCTYPE MEMO PUBLIC "-//SGMLSOURCE//DTD MEMO//EN" "http://www.sgmlsource.com/dtds/memo.dtd">
+<MEMO/>
View
7 result/ent1
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
+<!ENTITY xml "Extensible Markup Language">
+]>
+<EXAMPLE>
+ Extensible Markup Language
+</EXAMPLE>
View
10 result/ent2
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
+<!ENTITY xml "Extensible Markup Language">
+<!ENTITY title PUBLIC "-//MY-TITLE//FR" "title.xml">
+<!ENTITY image SYSTEM "img.gif" NDATA GIF>
+]>
+<EXAMPLE>
+
+ This text is about XML, the Extensible Markup Language and this is an embedded
+</EXAMPLE>
View
7 result/ent3
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE EXAMPLE SYSTEM "example.dtd" [
+<!ENTITY xml "Extensible Markup Language">
+]>
+<EXAMPLE prop1="a&amp;b" prop2="Extensible Markup Language">
+ Test of entities in attributes.
+</EXAMPLE>
View
16 result/p3p
@@ -1,26 +1,22 @@
-
-
-------- test/p3p -----------
<?xml version="1.0"?>
-<?xml:namespace ns="http://www.w3.org/TR/WD-rdf-syntax#" prefix="RDF"?>
-<RDF:RDF>
- <PROP assurance="http://www.TrustUs.org" agreeID="94df1293a3e519bb" entity="CoolCatalog" realm="http://www.CoolCatalog.com/catalogue/">
+<RDF:RDF xmlns:p3p="http//www.w3.org/TR/1998/WD-P3P10-syntax#proposal.DTD" xmlns:RDF="http://www.w3.org/TR/WD-rdf-syntax#">
+ <PROP realm="http://www.CoolCatalog.com/catalogue/" entity="CoolCatalog" agreeID="94df1293a3e519bb" assurance="http://www.TrustUs.org">
<USES>
- <STATEMENT consq="a site with clothes you&apos;d appreciate." id="0" recpnt="0" purp="2,3">
+ <STATEMENT purp="2,3" recpnt="0" id="0" consq="a site with clothes you&apos;d appreciate.">
<WITH>
<PREFIX name="User.">
<REF name="Name.First"/>
- <REF optional="1" name="Bdate.Year"/>
+ <REF name="Bdate.Year" optional="1"/>
<REF name="Gender"/>
</PREFIX>
</WITH>
</STATEMENT>
</USES>
<USES>
- <STATEMENT id="1" recpnt="0" purp="0" action="read&amp;write">
+ <STATEMENT action="read&amp;write" purp="0" recpnt="0" id="1">
<REF name="User.Shipping."/>
</STATEMENT>
</USES>
- <DISCLOSURE other="0,1" access="3" discURI="http://www.CoolCatalog.com/PrivacyPractice.html"/>
+ <DISCLOSURE discURI="http://www.CoolCatalog.com/PrivacyPractice.html" access="3" other="0,1"/>
</PROP>
</RDF:RDF>
View
81 result/rdf1
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<RDF:RDF xmlns:RPM="http://www.rpm.org/" xmlns:RDF="http://www.w3.org/TR/WD-rdf-syntax#">
+ <RDF:Description HREF="ftp://rufus.w3.org/linux/redhat/redhat-5.1/i386/RedHat/RPMS/rpm-2.5-2.i386.rpm">
+ <RPM:Name>rpm</RPM:Name>
+ <RPM:Version>2.5</RPM:Version>
+ <RPM:Release>2</RPM:Release>
+ <RPM:Arch>i386</RPM:Arch>
+ <RPM:Os>Linux</RPM:Os>
+ <RPM:Distribution>Manhattan </RPM:Distribution>
+ <RPM:Vendor>Red Hat Software</RPM:Vendor>
+ <RPM:Packager>Red Hat Software &lt;bugs@redhat.com&gt;</RPM:Packager>
+ <RPM:Group>Utilities/System</RPM:Group>
+ <RPM:Summary>Red Hat Package Manager</RPM:Summary>
+ <RPM:Description>RPM is a powerful package manager, which can be used to build, install,
+query, verify, update, and uninstall individual software packages. A
+package consists of an archive of files, and package information, including
+name, version, and description.</RPM:Description>
+ <RPM:Copyright>GPL</RPM:Copyright>
+ <RPM:Changelog>* Sun May 10 1998 Prospector System &lt;bugs@redhat.com&gt;
+ - translations modified for de, fr, tr
+</RPM:Changelog>
+ <RPM:Sources>rpm-2.5-2.src.rpm</RPM:Sources>
+ <RPM:SourcesFtp>ftp://ftp.redhat.com/pub/redhat/redhat-5.1/SRPMS</RPM:SourcesFtp>
+ <RPM:BuildDate>Sun May 10 14:52:32 1998</RPM:BuildDate>
+ <RPM:Date>894826352</RPM:Date>
+ <RPM:Size>850599</RPM:Size>
+ <RPM:BuildHost>porky.redhat.com</RPM:BuildHost>
+ <RPM:Provides>
+ <RDF:Bag>
+ <RPM:Resource>rpm</RPM:Resource>
+ </RDF:Bag>
+ </RPM:Provides>
+ <RPM:Requires>
+ <RDF:Bag>
+ <RPM:Resource>/bin/sh</RPM:Resource>
+ <RPM:Resource>ld-linux.so.2</RPM:Resource>
+ <RPM:Resource>libc.so.6</RPM:Resource>
+ <RPM:Resource>libdb.so.2</RPM:Resource>
+ <RPM:Resource>libz.so.1</RPM:Resource>
+ <RPM:Resource>/bin/bash</RPM:Resource>
+ <RPM:Resource>/bin/sh</RPM:Resource>
+ </RDF:Bag>
+ </RPM:Requires>
+ <RPM:Files>/bin/rpm
+/usr/bin/find-provides
+/usr/bin/find-requires
+/usr/bin/gendiff
+/usr/bin/rpm2cpio
+/usr/doc/rpm-2.5
+/usr/doc/rpm-2.5/CHANGES
+/usr/doc/rpm-2.5/RPM-PGP-KEY
+/usr/doc/rpm-2.5/buildroot
+/usr/doc/rpm-2.5/dependencies
+/usr/doc/rpm-2.5/format
+/usr/doc/rpm-2.5/groups
+/usr/doc/rpm-2.5/macros
+/usr/doc/rpm-2.5/queryformat
+/usr/doc/rpm-2.5/relocatable
+/usr/doc/rpm-2.5/signatures
+/usr/doc/rpm-2.5/spec
+/usr/doc/rpm-2.5/triggers
+/usr/lib/rpmpopt
+/usr/lib/rpmrc
+/usr/man/man8/rpm.8
+/usr/man/man8/rpm2cpio.8
+/usr/share/locale/de/LC_MESSAGES/rpm.mo
+/usr/share/locale/fr/LC_MESSAGES/rpm.mo
+/usr/share/locale/pt-br/LC_MESSAGES/rpm.mo
+/usr/share/locale/sv/LC_MESSAGES/rpm.mo
+/usr/share/locale/tr/LC_MESSAGES/rpm.mo
+/usr/src/redhat
+/usr/src/redhat/BUILD
+/usr/src/redhat/RPMS
+/usr/src/redhat/RPMS/i386
+/usr/src/redhat/RPMS/noarch
+/usr/src/redhat/SOURCES
+/usr/src/redhat/SPECS
+/usr/src/redhat/SRPMS
+</RPM:Files>
+ </RDF:Description>
+</RDF:RDF>
View
2 test/dav1
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href ="http://www.ietf.org/standards/dav/" AS = "D"?>
<?namespace href = "http://www.foo.bar/boxschema" AS = "R"?>
<D:multistatus>
View
2 test/dav10
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href="http://www.ietf.org/standards/dav/" AS = "D"?>
<D:owner>
<D:href>http://www.ics.uci.edu/~ejw/contact.html</D:href>
View
2 test/dav11
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href ="http://www.ietf.org/standards/dav/" AS = "D"?>
<D:prop>
<D:lockdiscovery>
View
2 test/dav12
@@ -1,3 +1,3 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href="http://www.ietf.org/standards/dav/" AS = "D"?>
<D:href>http://www.ics.uci.edu/~ejw/contact.html</D:href>
View
2 test/dav13
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<D:multistatus>
<D:response>
View
10 test/dav14
@@ -1,10 +0,0 @@
- <?XML version="1.0">
- <?namespace href = "http://www.ietf.org/standards/dav/patch/" AS =
- "D"?>
- <D:resourceupdate>
- <D:replace XML-SPACE = "PRESERVE">
- <D:octet-range>14</D:octet-range>&003CTITLE&003ENew
- Title&003C/TITLE&003E</D:replace>
- <D:delete><D:octet-range>38-50</D:octet-range></D:delete>
- <D:insert XML-SPACE = "PRESERVE"><D:octet-range>86</D:octet-range>&003CP&003ENew paragraph&003C/P&003E</D:insert>
- </D:resourceupdate>
View
2 test/dav15
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<?namespace href = "http://www.foocorp.com/Project/" AS = "F"?>
<D:prop>
View
2 test/dav16
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<D:propfind>
<D:prop><lockdiscovery/></D:prop>
View
2 test/dav17
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href ="http://www.ietf.org/standards/dav/" AS = "D"?>
<D:multistatus>
<D:response>
View
2 test/dav18
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<D:propfind>
<D:prop><supportedlock/></D:prop>
View
2 test/dav19
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href ="http://www.ietf.org/standards/dav/" AS = "D"?>
<D:multistatus>
<D:response>
View
2 test/dav2
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "S"?>
<?namespace href = "http://www.foo.bar/boxschema/" AS = "R"?>
<S:multistatus>
View
2 test/dav3
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<?namespace href = "http://www.foo.bar/boxschema/" AS = "R"?>
<D:multistatus>
View
2 test/dav4
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>
<?namespace href = "http://www.w3.com/standards/z39.50/" AS = "Z"?>
<D:propertyupdate>
View
2 test/dav5
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href="http://www.ietf.org/standards/dav/" AS = "D"?>
<?namespace href="http://www.w3.com/standards/z39.50/" AS = "Z"?>
<D:multistatus>
View
2 test/dav6
@@ -1,4 +1,4 @@
- <?XML version="1.0">
+ <?XML version="1.0"?>
<?namespace href = "http://www.ietf.org/standards/dav/" AS = "D"?>