aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2000-06-28 23:40:59 +0000
committerDaniel Veillard <veillard@src.gnome.org>2000-06-28 23:40:59 +0000
commitbe803967dbecb5534c7c7fbc1a17157ba43366b5 (patch)
treea4bb29cb23f8facd1027cd259bc48b745f968bcf /example
parentc310d5648211aed9e61af8fc8e261295c4c7000f (diff)
downloadandroid_external_libxml2-be803967dbecb5534c7c7fbc1a17157ba43366b5.tar.gz
android_external_libxml2-be803967dbecb5534c7c7fbc1a17157ba43366b5.tar.bz2
android_external_libxml2-be803967dbecb5534c7c7fbc1a17157ba43366b5.zip
- Large resync between W3C and Gnome tree
- configure.in: 2.1.0 prerelease - example/Makefile.am example/gjobread.c tree.h: work on libxml1 libxml2 convergence. - nanoftp, nanohttp.c: fixed stalled connections probs - HTMLtree.c SAX.c : support for attribute without values in HTML for andersca - valid.c: Fixed most validation + namespace problems - HTMLparser.c: start document callback for andersca - debugXML.c xpath.c: lots of XPath fixups from Picdar Technology - parser.h, SAX.c: serious speed improvement for large CDATA blocks - encoding.[ch] xmlIO.[ch]: Improved seriously saving to different encoding - config.h.in parser.c xmllint.c: added xmlCheckVersion() and the LIBXML_TEST_VERSION macro Daniel
Diffstat (limited to 'example')
-rw-r--r--example/Makefile.am6
-rw-r--r--example/gjobread.c39
2 files changed, 28 insertions, 17 deletions
diff --git a/example/Makefile.am b/example/Makefile.am
index 0978f95a..ce7a8da9 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -6,5 +6,9 @@ INCLUDES = \
LDADD = $(top_builddir)/libxml.la @Z_LIBS@
-$(top_builddir)/libxml.la:
+$(srcdir)/libxml:
+ -$(RM) $(srcdir)/libxml
+ ln -s $(srcdir)/. $(srcdir)/libxml
+
+$(top_builddir)/libxml.la: $(srcdir)/libxml
(cd .. ; $(MAKE))
diff --git a/example/gjobread.c b/example/gjobread.c
index ca386718..916fa53a 100644
--- a/example/gjobread.c
+++ b/example/gjobread.c
@@ -10,12 +10,18 @@
#include <string.h>
#include <stdlib.h>
-#include <xmlmemory.h>
-#if defined(LIBXML_VERSION) && LIBXML_VERSION >= 20000
+/*
+ * This example should compile and run indifferently with libxml-1.8.8 +
+ * and libxml2-2.1.0 +
+ * Check the COMPAT comments below
+ */
+
+/*
+ * COMPAT using xml-config --cflags to get the include path this will
+ * work with both
+ */
+#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
-#else
-#include <gnome-xml/parser.h>
-#endif
#define DEBUG(x) printf(x)
@@ -50,12 +56,13 @@ DEBUG("parsePerson\n");
memset(ret, 0, sizeof(person));
/* We don't care what the top level element name is */
- cur = cur->children;
+ /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
+ cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!strcmp(cur->name, "Person")) && (cur->ns == ns))
- ret->name = xmlNodeListGetString(doc, cur->children, 1);
+ ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Email")) && (cur->ns == ns))
- ret->email = xmlNodeListGetString(doc, cur->children, 1);
+ ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
cur = cur->next;
}
@@ -108,7 +115,7 @@ DEBUG("parseJob\n");
memset(ret, 0, sizeof(job));
/* We don't care what the top level element name is */
- cur = cur->children;
+ cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!strcmp(cur->name, "Project")) && (cur->ns == ns)) {
@@ -118,9 +125,9 @@ DEBUG("parseJob\n");
}
}
if ((!strcmp(cur->name, "Application")) && (cur->ns == ns))
- ret->application = xmlNodeListGetString(doc, cur->children, 1);
+ ret->application = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Category")) && (cur->ns == ns))
- ret->category = xmlNodeListGetString(doc, cur->children, 1);
+ ret->category = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!strcmp(cur->name, "Contact")) && (cur->ns == ns))
ret->contact = parsePerson(doc, ns, cur);
cur = cur->next;
@@ -173,8 +180,6 @@ gJobPtr parseGjobFile(char *filename) {
* Check the document is of the right kind
*/
- // cur = doc->root;
- // cur = doc->children;
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"empty document\n");
@@ -209,8 +214,7 @@ gJobPtr parseGjobFile(char *filename) {
* Now, walk the tree.
*/
/* First level we expect just Jobs */
- // cur = cur->children;
- cur = cur -> children;
+ cur = cur->xmlChildrenNode;
while ( cur && xmlIsBlankNode ( cur ) )
{
cur = cur -> next;
@@ -229,7 +233,7 @@ gJobPtr parseGjobFile(char *filename) {
}
/* Second level is a list of Job, but be laxist */
- cur = cur->children;
+ cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!strcmp(cur->name, "Job")) && (cur->ns == ns)) {
job = parseJob(doc, ns, cur);
@@ -257,6 +261,9 @@ int main(int argc, char **argv) {
int i;
gJobPtr cur;
+ /* COMPAT: Do not genrate nodes for formatting spaces */
+ xmlKeepBlanksDefault(0);
+
for (i = 1; i < argc ; i++) {
cur = parseGjobFile(argv[i]);
if ( cur )