From 35a201cc8ef0c3f5b2df88d2e528aabee1048348 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 30 Apr 2021 18:47:09 +0200 Subject: Initial/Final commit --- libxml2-2.9.10/doc/examples/Makefile.am | 136 ++++ libxml2-2.9.10/doc/examples/Makefile.in | 1026 +++++++++++++++++++++++++ libxml2-2.9.10/doc/examples/examples.xml | 751 +++++++++++++++++++ libxml2-2.9.10/doc/examples/examples.xsl | 174 +++++ libxml2-2.9.10/doc/examples/index.html | 14 + libxml2-2.9.10/doc/examples/index.py | 315 ++++++++ libxml2-2.9.10/doc/examples/io1.c | 166 +++++ libxml2-2.9.10/doc/examples/io1.res | 5 + libxml2-2.9.10/doc/examples/io2.c | 58 ++ libxml2-2.9.10/doc/examples/io2.res | 2 + libxml2-2.9.10/doc/examples/parse1.c | 56 ++ libxml2-2.9.10/doc/examples/parse2.c | 72 ++ libxml2-2.9.10/doc/examples/parse3.c | 60 ++ libxml2-2.9.10/doc/examples/parse4.c | 143 ++++ libxml2-2.9.10/doc/examples/reader1.c | 107 +++ libxml2-2.9.10/doc/examples/reader1.res | 14 + libxml2-2.9.10/doc/examples/reader2.c | 122 +++ libxml2-2.9.10/doc/examples/reader3.c | 120 +++ libxml2-2.9.10/doc/examples/reader3.res | 13 + libxml2-2.9.10/doc/examples/reader4.c | 122 +++ libxml2-2.9.10/doc/examples/reader4.res | 3 + libxml2-2.9.10/doc/examples/test1.xml | 1 + libxml2-2.9.10/doc/examples/test2.xml | 13 + libxml2-2.9.10/doc/examples/test3.xml | 39 + libxml2-2.9.10/doc/examples/testWriter.c | 1198 ++++++++++++++++++++++++++++++ libxml2-2.9.10/doc/examples/tree1.c | 94 +++ libxml2-2.9.10/doc/examples/tree1.res | 4 + libxml2-2.9.10/doc/examples/tree2.c | 117 +++ libxml2-2.9.10/doc/examples/tree2.res | 18 + libxml2-2.9.10/doc/examples/tst.xml | 7 + libxml2-2.9.10/doc/examples/writer.xml | 2 + libxml2-2.9.10/doc/examples/xpath1.c | 250 +++++++ libxml2-2.9.10/doc/examples/xpath1.res | 5 + libxml2-2.9.10/doc/examples/xpath2.c | 190 +++++ libxml2-2.9.10/doc/examples/xpath2.res | 30 + 35 files changed, 5447 insertions(+) create mode 100644 libxml2-2.9.10/doc/examples/Makefile.am create mode 100644 libxml2-2.9.10/doc/examples/Makefile.in create mode 100644 libxml2-2.9.10/doc/examples/examples.xml create mode 100644 libxml2-2.9.10/doc/examples/examples.xsl create mode 100644 libxml2-2.9.10/doc/examples/index.html create mode 100755 libxml2-2.9.10/doc/examples/index.py create mode 100644 libxml2-2.9.10/doc/examples/io1.c create mode 100644 libxml2-2.9.10/doc/examples/io1.res create mode 100644 libxml2-2.9.10/doc/examples/io2.c create mode 100644 libxml2-2.9.10/doc/examples/io2.res create mode 100644 libxml2-2.9.10/doc/examples/parse1.c create mode 100644 libxml2-2.9.10/doc/examples/parse2.c create mode 100644 libxml2-2.9.10/doc/examples/parse3.c create mode 100644 libxml2-2.9.10/doc/examples/parse4.c create mode 100644 libxml2-2.9.10/doc/examples/reader1.c create mode 100644 libxml2-2.9.10/doc/examples/reader1.res create mode 100644 libxml2-2.9.10/doc/examples/reader2.c create mode 100644 libxml2-2.9.10/doc/examples/reader3.c create mode 100644 libxml2-2.9.10/doc/examples/reader3.res create mode 100644 libxml2-2.9.10/doc/examples/reader4.c create mode 100644 libxml2-2.9.10/doc/examples/reader4.res create mode 100644 libxml2-2.9.10/doc/examples/test1.xml create mode 100644 libxml2-2.9.10/doc/examples/test2.xml create mode 100644 libxml2-2.9.10/doc/examples/test3.xml create mode 100644 libxml2-2.9.10/doc/examples/testWriter.c create mode 100644 libxml2-2.9.10/doc/examples/tree1.c create mode 100644 libxml2-2.9.10/doc/examples/tree1.res create mode 100644 libxml2-2.9.10/doc/examples/tree2.c create mode 100644 libxml2-2.9.10/doc/examples/tree2.res create mode 100644 libxml2-2.9.10/doc/examples/tst.xml create mode 100644 libxml2-2.9.10/doc/examples/writer.xml create mode 100644 libxml2-2.9.10/doc/examples/xpath1.c create mode 100644 libxml2-2.9.10/doc/examples/xpath1.res create mode 100644 libxml2-2.9.10/doc/examples/xpath2.c create mode 100644 libxml2-2.9.10/doc/examples/xpath2.res (limited to 'libxml2-2.9.10/doc/examples') diff --git a/libxml2-2.9.10/doc/examples/Makefile.am b/libxml2-2.9.10/doc/examples/Makefile.am new file mode 100644 index 0000000..ef59fce --- /dev/null +++ b/libxml2-2.9.10/doc/examples/Makefile.am @@ -0,0 +1,136 @@ +## +## This file is auto-generated by index.py +## DO NOT EDIT !!! +## + +AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)/include +AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS) +LDADD = $(RDL_LIBS) $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(ICONV_LIBS) -lm $(WIN32_EXTRA_LIBADD) + +CLEANFILES = *.tmp + +if REBUILD_DOCS +rebuild: examples.xml index.html +.PHONY: rebuild + +examples.xml: index.py $(check_PROGRAMS:=.c) + cd $(srcdir) && $(PYTHON) index.py + $(MAKE) Makefile + +index.html: examples.xml examples.xsl + cd $(srcdir) && xsltproc examples.xsl examples.xml && echo "Rebuilt web page" + -cd $(srcdir) && xmllint --valid --noout index.html +endif + +install-data-local: + $(MKDIR_P) $(DESTDIR)$(HTML_DIR) + -$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR) + +clean-local: + test -f Makefile.am || rm -f test?.xml + +EXTRA_DIST = \ + examples.xml \ + examples.xsl \ + index.html \ + index.py \ + io1.res \ + io2.res \ + reader1.res \ + reader3.res \ + reader4.res \ + test1.xml \ + test2.xml \ + test3.xml \ + tree1.res \ + tree2.res \ + tst.xml \ + writer.xml \ + xpath1.res \ + xpath2.res + +check_PROGRAMS = \ + io1 \ + io2 \ + parse1 \ + parse2 \ + parse3 \ + parse4 \ + reader1 \ + reader2 \ + reader3 \ + reader4 \ + testWriter \ + tree1 \ + tree2 \ + xpath1 \ + xpath2 + +io1_SOURCES = io1.c + +io2_SOURCES = io2.c + +parse1_SOURCES = parse1.c + +parse2_SOURCES = parse2.c + +parse3_SOURCES = parse3.c + +parse4_SOURCES = parse4.c + +reader1_SOURCES = reader1.c + +reader2_SOURCES = reader2.c + +reader3_SOURCES = reader3.c + +reader4_SOURCES = reader4.c + +testWriter_SOURCES = testWriter.c + +tree1_SOURCES = tree1.c + +tree2_SOURCES = tree2.c + +xpath1_SOURCES = xpath1.c + +xpath2_SOURCES = xpath2.c + +valgrind: + $(MAKE) CHECKER='valgrind' tests + +tests: $(check_PROGRAMS) + @test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml . + @(echo '## examples regression tests') + @(echo > .memdump) + @$(CHECKER) ./io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse1 test1.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse2 test2.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse3 + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse4 test3.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @rm *.tmp diff --git a/libxml2-2.9.10/doc/examples/Makefile.in b/libxml2-2.9.10/doc/examples/Makefile.in new file mode 100644 index 0000000..9e56e32 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/Makefile.in @@ -0,0 +1,1026 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = io1$(EXEEXT) io2$(EXEEXT) parse1$(EXEEXT) \ + parse2$(EXEEXT) parse3$(EXEEXT) parse4$(EXEEXT) \ + reader1$(EXEEXT) reader2$(EXEEXT) reader3$(EXEEXT) \ + reader4$(EXEEXT) testWriter$(EXEEXT) tree1$(EXEEXT) \ + tree2$(EXEEXT) xpath1$(EXEEXT) xpath2$(EXEEXT) +subdir = doc/examples +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am_io1_OBJECTS = io1.$(OBJEXT) +io1_OBJECTS = $(am_io1_OBJECTS) +io1_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +io1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +am_io2_OBJECTS = io2.$(OBJEXT) +io2_OBJECTS = $(am_io2_OBJECTS) +io2_LDADD = $(LDADD) +io2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_parse1_OBJECTS = parse1.$(OBJEXT) +parse1_OBJECTS = $(am_parse1_OBJECTS) +parse1_LDADD = $(LDADD) +parse1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_parse2_OBJECTS = parse2.$(OBJEXT) +parse2_OBJECTS = $(am_parse2_OBJECTS) +parse2_LDADD = $(LDADD) +parse2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_parse3_OBJECTS = parse3.$(OBJEXT) +parse3_OBJECTS = $(am_parse3_OBJECTS) +parse3_LDADD = $(LDADD) +parse3_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_parse4_OBJECTS = parse4.$(OBJEXT) +parse4_OBJECTS = $(am_parse4_OBJECTS) +parse4_LDADD = $(LDADD) +parse4_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_reader1_OBJECTS = reader1.$(OBJEXT) +reader1_OBJECTS = $(am_reader1_OBJECTS) +reader1_LDADD = $(LDADD) +reader1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_reader2_OBJECTS = reader2.$(OBJEXT) +reader2_OBJECTS = $(am_reader2_OBJECTS) +reader2_LDADD = $(LDADD) +reader2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_reader3_OBJECTS = reader3.$(OBJEXT) +reader3_OBJECTS = $(am_reader3_OBJECTS) +reader3_LDADD = $(LDADD) +reader3_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_reader4_OBJECTS = reader4.$(OBJEXT) +reader4_OBJECTS = $(am_reader4_OBJECTS) +reader4_LDADD = $(LDADD) +reader4_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_testWriter_OBJECTS = testWriter.$(OBJEXT) +testWriter_OBJECTS = $(am_testWriter_OBJECTS) +testWriter_LDADD = $(LDADD) +testWriter_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_tree1_OBJECTS = tree1.$(OBJEXT) +tree1_OBJECTS = $(am_tree1_OBJECTS) +tree1_LDADD = $(LDADD) +tree1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_tree2_OBJECTS = tree2.$(OBJEXT) +tree2_OBJECTS = $(am_tree2_OBJECTS) +tree2_LDADD = $(LDADD) +tree2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_xpath1_OBJECTS = xpath1.$(OBJEXT) +xpath1_OBJECTS = $(am_xpath1_OBJECTS) +xpath1_LDADD = $(LDADD) +xpath1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_xpath2_OBJECTS = xpath2.$(OBJEXT) +xpath2_OBJECTS = $(am_xpath2_OBJECTS) +xpath2_LDADD = $(LDADD) +xpath2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(top_builddir)/libxml2.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/io1.Po ./$(DEPDIR)/io2.Po \ + ./$(DEPDIR)/parse1.Po ./$(DEPDIR)/parse2.Po \ + ./$(DEPDIR)/parse3.Po ./$(DEPDIR)/parse4.Po \ + ./$(DEPDIR)/reader1.Po ./$(DEPDIR)/reader2.Po \ + ./$(DEPDIR)/reader3.Po ./$(DEPDIR)/reader4.Po \ + ./$(DEPDIR)/testWriter.Po ./$(DEPDIR)/tree1.Po \ + ./$(DEPDIR)/tree2.Po ./$(DEPDIR)/xpath1.Po \ + ./$(DEPDIR)/xpath2.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(io1_SOURCES) $(io2_SOURCES) $(parse1_SOURCES) \ + $(parse2_SOURCES) $(parse3_SOURCES) $(parse4_SOURCES) \ + $(reader1_SOURCES) $(reader2_SOURCES) $(reader3_SOURCES) \ + $(reader4_SOURCES) $(testWriter_SOURCES) $(tree1_SOURCES) \ + $(tree2_SOURCES) $(xpath1_SOURCES) $(xpath2_SOURCES) +DIST_SOURCES = $(io1_SOURCES) $(io2_SOURCES) $(parse1_SOURCES) \ + $(parse2_SOURCES) $(parse3_SOURCES) $(parse4_SOURCES) \ + $(reader1_SOURCES) $(reader2_SOURCES) $(reader3_SOURCES) \ + $(reader4_SOURCES) $(testWriter_SOURCES) $(tree1_SOURCES) \ + $(tree2_SOURCES) $(xpath1_SOURCES) $(xpath2_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_THREAD_LIBS = @BASE_THREAD_LIBS@ +C14N_OBJ = @C14N_OBJ@ +CATALOG_OBJ = @CATALOG_OBJ@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +CYGWIN_EXTRA_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ +CYGWIN_EXTRA_PYTHON_LIBADD = @CYGWIN_EXTRA_PYTHON_LIBADD@ +DEBUG_OBJ = @DEBUG_OBJ@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOCB_OBJ = @DOCB_OBJ@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +FGREP = @FGREP@ +FTP_OBJ = @FTP_OBJ@ +GREP = @GREP@ +HAVE_ISINF = @HAVE_ISINF@ +HAVE_ISNAN = @HAVE_ISNAN@ +HTML_DIR = @HTML_DIR@ +HTML_OBJ = @HTML_OBJ@ +HTTP_OBJ = @HTTP_OBJ@ +ICONV_LIBS = @ICONV_LIBS@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBXML_MAJOR_VERSION = @LIBXML_MAJOR_VERSION@ +LIBXML_MICRO_VERSION = @LIBXML_MICRO_VERSION@ +LIBXML_MINOR_VERSION = @LIBXML_MINOR_VERSION@ +LIBXML_VERSION = @LIBXML_VERSION@ +LIBXML_VERSION_EXTRA = @LIBXML_VERSION_EXTRA@ +LIBXML_VERSION_INFO = @LIBXML_VERSION_INFO@ +LIBXML_VERSION_NUMBER = @LIBXML_VERSION_NUMBER@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MODULE_EXTENSION = @MODULE_EXTENSION@ +MODULE_PLATFORM_LIBS = @MODULE_PLATFORM_LIBS@ +MV = @MV@ +M_LIBS = @M_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PYTHON = @PYTHON@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_LIBS = @PYTHON_LIBS@ +PYTHON_SITE_PACKAGES = @PYTHON_SITE_PACKAGES@ +PYTHON_SUBDIR = @PYTHON_SUBDIR@ +PYTHON_TESTS = @PYTHON_TESTS@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RDL_LIBS = @RDL_LIBS@ +READER_TEST = @READER_TEST@ +RELDATE = @RELDATE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STATIC_BINARIES = @STATIC_BINARIES@ +STRIP = @STRIP@ +TAR = @TAR@ +TEST_C14N = @TEST_C14N@ +TEST_CATALOG = @TEST_CATALOG@ +TEST_DEBUG = @TEST_DEBUG@ +TEST_HTML = @TEST_HTML@ +TEST_MODULES = @TEST_MODULES@ +TEST_PATTERN = @TEST_PATTERN@ +TEST_PHTML = @TEST_PHTML@ +TEST_PUSH = @TEST_PUSH@ +TEST_REGEXPS = @TEST_REGEXPS@ +TEST_SAX = @TEST_SAX@ +TEST_SCHEMAS = @TEST_SCHEMAS@ +TEST_SCHEMATRON = @TEST_SCHEMATRON@ +TEST_THREADS = @TEST_THREADS@ +TEST_VALID = @TEST_VALID@ +TEST_VTIME = @TEST_VTIME@ +TEST_XINCLUDE = @TEST_XINCLUDE@ +TEST_XPATH = @TEST_XPATH@ +TEST_XPTR = @TEST_XPTR@ +THREAD_CFLAGS = @THREAD_CFLAGS@ +THREAD_LIBS = @THREAD_LIBS@ +VERSION = @VERSION@ +VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@ +WGET = @WGET@ +WIN32_EXTRA_LDFLAGS = @WIN32_EXTRA_LDFLAGS@ +WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ +WIN32_EXTRA_PYTHON_LIBADD = @WIN32_EXTRA_PYTHON_LIBADD@ +WITH_C14N = @WITH_C14N@ +WITH_CATALOG = @WITH_CATALOG@ +WITH_DEBUG = @WITH_DEBUG@ +WITH_DOCB = @WITH_DOCB@ +WITH_FTP = @WITH_FTP@ +WITH_HTML = @WITH_HTML@ +WITH_HTTP = @WITH_HTTP@ +WITH_ICONV = @WITH_ICONV@ +WITH_ICU = @WITH_ICU@ +WITH_ISO8859X = @WITH_ISO8859X@ +WITH_LEGACY = @WITH_LEGACY@ +WITH_LZMA = @WITH_LZMA@ +WITH_MEM_DEBUG = @WITH_MEM_DEBUG@ +WITH_MODULES = @WITH_MODULES@ +WITH_OUTPUT = @WITH_OUTPUT@ +WITH_PATTERN = @WITH_PATTERN@ +WITH_PUSH = @WITH_PUSH@ +WITH_READER = @WITH_READER@ +WITH_REGEXPS = @WITH_REGEXPS@ +WITH_RUN_DEBUG = @WITH_RUN_DEBUG@ +WITH_SAX1 = @WITH_SAX1@ +WITH_SCHEMAS = @WITH_SCHEMAS@ +WITH_SCHEMATRON = @WITH_SCHEMATRON@ +WITH_THREADS = @WITH_THREADS@ +WITH_THREAD_ALLOC = @WITH_THREAD_ALLOC@ +WITH_TREE = @WITH_TREE@ +WITH_TRIO = @WITH_TRIO@ +WITH_VALID = @WITH_VALID@ +WITH_WRITER = @WITH_WRITER@ +WITH_XINCLUDE = @WITH_XINCLUDE@ +WITH_XPATH = @WITH_XPATH@ +WITH_XPTR = @WITH_XPTR@ +WITH_ZLIB = @WITH_ZLIB@ +XINCLUDE_OBJ = @XINCLUDE_OBJ@ +XMLLINT = @XMLLINT@ +XML_CFLAGS = @XML_CFLAGS@ +XML_INCLUDEDIR = @XML_INCLUDEDIR@ +XML_LIBDIR = @XML_LIBDIR@ +XML_LIBS = @XML_LIBS@ +XML_LIBTOOLLIBS = @XML_LIBTOOLLIBS@ +XML_PRIVATE_LIBS = @XML_PRIVATE_LIBS@ +XPATH_OBJ = @XPATH_OBJ@ +XPTR_OBJ = @XPTR_OBJ@ +XSLTPROC = @XSLTPROC@ +Z_CFLAGS = @Z_CFLAGS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)/include +AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS) +LDADD = $(RDL_LIBS) $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(ICONV_LIBS) -lm $(WIN32_EXTRA_LIBADD) +CLEANFILES = *.tmp +EXTRA_DIST = \ + examples.xml \ + examples.xsl \ + index.html \ + index.py \ + io1.res \ + io2.res \ + reader1.res \ + reader3.res \ + reader4.res \ + test1.xml \ + test2.xml \ + test3.xml \ + tree1.res \ + tree2.res \ + tst.xml \ + writer.xml \ + xpath1.res \ + xpath2.res + +io1_SOURCES = io1.c +io2_SOURCES = io2.c +parse1_SOURCES = parse1.c +parse2_SOURCES = parse2.c +parse3_SOURCES = parse3.c +parse4_SOURCES = parse4.c +reader1_SOURCES = reader1.c +reader2_SOURCES = reader2.c +reader3_SOURCES = reader3.c +reader4_SOURCES = reader4.c +testWriter_SOURCES = testWriter.c +tree1_SOURCES = tree1.c +tree2_SOURCES = tree2.c +xpath1_SOURCES = xpath1.c +xpath2_SOURCES = xpath2.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/examples/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +io1$(EXEEXT): $(io1_OBJECTS) $(io1_DEPENDENCIES) $(EXTRA_io1_DEPENDENCIES) + @rm -f io1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(io1_OBJECTS) $(io1_LDADD) $(LIBS) + +io2$(EXEEXT): $(io2_OBJECTS) $(io2_DEPENDENCIES) $(EXTRA_io2_DEPENDENCIES) + @rm -f io2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(io2_OBJECTS) $(io2_LDADD) $(LIBS) + +parse1$(EXEEXT): $(parse1_OBJECTS) $(parse1_DEPENDENCIES) $(EXTRA_parse1_DEPENDENCIES) + @rm -f parse1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(parse1_OBJECTS) $(parse1_LDADD) $(LIBS) + +parse2$(EXEEXT): $(parse2_OBJECTS) $(parse2_DEPENDENCIES) $(EXTRA_parse2_DEPENDENCIES) + @rm -f parse2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(parse2_OBJECTS) $(parse2_LDADD) $(LIBS) + +parse3$(EXEEXT): $(parse3_OBJECTS) $(parse3_DEPENDENCIES) $(EXTRA_parse3_DEPENDENCIES) + @rm -f parse3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(parse3_OBJECTS) $(parse3_LDADD) $(LIBS) + +parse4$(EXEEXT): $(parse4_OBJECTS) $(parse4_DEPENDENCIES) $(EXTRA_parse4_DEPENDENCIES) + @rm -f parse4$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(parse4_OBJECTS) $(parse4_LDADD) $(LIBS) + +reader1$(EXEEXT): $(reader1_OBJECTS) $(reader1_DEPENDENCIES) $(EXTRA_reader1_DEPENDENCIES) + @rm -f reader1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(reader1_OBJECTS) $(reader1_LDADD) $(LIBS) + +reader2$(EXEEXT): $(reader2_OBJECTS) $(reader2_DEPENDENCIES) $(EXTRA_reader2_DEPENDENCIES) + @rm -f reader2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(reader2_OBJECTS) $(reader2_LDADD) $(LIBS) + +reader3$(EXEEXT): $(reader3_OBJECTS) $(reader3_DEPENDENCIES) $(EXTRA_reader3_DEPENDENCIES) + @rm -f reader3$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(reader3_OBJECTS) $(reader3_LDADD) $(LIBS) + +reader4$(EXEEXT): $(reader4_OBJECTS) $(reader4_DEPENDENCIES) $(EXTRA_reader4_DEPENDENCIES) + @rm -f reader4$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(reader4_OBJECTS) $(reader4_LDADD) $(LIBS) + +testWriter$(EXEEXT): $(testWriter_OBJECTS) $(testWriter_DEPENDENCIES) $(EXTRA_testWriter_DEPENDENCIES) + @rm -f testWriter$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(testWriter_OBJECTS) $(testWriter_LDADD) $(LIBS) + +tree1$(EXEEXT): $(tree1_OBJECTS) $(tree1_DEPENDENCIES) $(EXTRA_tree1_DEPENDENCIES) + @rm -f tree1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tree1_OBJECTS) $(tree1_LDADD) $(LIBS) + +tree2$(EXEEXT): $(tree2_OBJECTS) $(tree2_DEPENDENCIES) $(EXTRA_tree2_DEPENDENCIES) + @rm -f tree2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tree2_OBJECTS) $(tree2_LDADD) $(LIBS) + +xpath1$(EXEEXT): $(xpath1_OBJECTS) $(xpath1_DEPENDENCIES) $(EXTRA_xpath1_DEPENDENCIES) + @rm -f xpath1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(xpath1_OBJECTS) $(xpath1_LDADD) $(LIBS) + +xpath2$(EXEEXT): $(xpath2_OBJECTS) $(xpath2_DEPENDENCIES) $(EXTRA_xpath2_DEPENDENCIES) + @rm -f xpath2$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(xpath2_OBJECTS) $(xpath2_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testWriter.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tree1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tree2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xpath1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xpath2.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/io1.Po + -rm -f ./$(DEPDIR)/io2.Po + -rm -f ./$(DEPDIR)/parse1.Po + -rm -f ./$(DEPDIR)/parse2.Po + -rm -f ./$(DEPDIR)/parse3.Po + -rm -f ./$(DEPDIR)/parse4.Po + -rm -f ./$(DEPDIR)/reader1.Po + -rm -f ./$(DEPDIR)/reader2.Po + -rm -f ./$(DEPDIR)/reader3.Po + -rm -f ./$(DEPDIR)/reader4.Po + -rm -f ./$(DEPDIR)/testWriter.Po + -rm -f ./$(DEPDIR)/tree1.Po + -rm -f ./$(DEPDIR)/tree2.Po + -rm -f ./$(DEPDIR)/xpath1.Po + -rm -f ./$(DEPDIR)/xpath2.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-data-local + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/io1.Po + -rm -f ./$(DEPDIR)/io2.Po + -rm -f ./$(DEPDIR)/parse1.Po + -rm -f ./$(DEPDIR)/parse2.Po + -rm -f ./$(DEPDIR)/parse3.Po + -rm -f ./$(DEPDIR)/parse4.Po + -rm -f ./$(DEPDIR)/reader1.Po + -rm -f ./$(DEPDIR)/reader2.Po + -rm -f ./$(DEPDIR)/reader3.Po + -rm -f ./$(DEPDIR)/reader4.Po + -rm -f ./$(DEPDIR)/testWriter.Po + -rm -f ./$(DEPDIR)/tree1.Po + -rm -f ./$(DEPDIR)/tree2.Po + -rm -f ./$(DEPDIR)/xpath1.Po + -rm -f ./$(DEPDIR)/xpath2.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool clean-local \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-data-local install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +@REBUILD_DOCS_TRUE@rebuild: examples.xml index.html +@REBUILD_DOCS_TRUE@.PHONY: rebuild + +@REBUILD_DOCS_TRUE@examples.xml: index.py $(check_PROGRAMS:=.c) +@REBUILD_DOCS_TRUE@ cd $(srcdir) && $(PYTHON) index.py +@REBUILD_DOCS_TRUE@ $(MAKE) Makefile + +@REBUILD_DOCS_TRUE@index.html: examples.xml examples.xsl +@REBUILD_DOCS_TRUE@ cd $(srcdir) && xsltproc examples.xsl examples.xml && echo "Rebuilt web page" +@REBUILD_DOCS_TRUE@ -cd $(srcdir) && xmllint --valid --noout index.html + +install-data-local: + $(MKDIR_P) $(DESTDIR)$(HTML_DIR) + -$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR) + +clean-local: + test -f Makefile.am || rm -f test?.xml + +valgrind: + $(MAKE) CHECKER='valgrind' tests + +tests: $(check_PROGRAMS) + @test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml . + @(echo '## examples regression tests') + @(echo > .memdump) + @$(CHECKER) ./io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse1 test1.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse2 test2.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse3 + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./parse4 test3.xml + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @$(CHECKER) ./xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res + @grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0 + @rm *.tmp + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libxml2-2.9.10/doc/examples/examples.xml b/libxml2-2.9.10/doc/examples/examples.xml new file mode 100644 index 0000000..cc791ed --- /dev/null +++ b/libxml2-2.9.10/doc/examples/examples.xml @@ -0,0 +1,751 @@ + + + Example of custom Input/Output + Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way. + io1 + io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res + Daniel Veillard + see Copyright for the status of this software. +
InputOutput
+ + <libxml/parser.h> + <libxml/xmlIO.h> + <libxml/xinclude.h> + <libxml/tree.h> + + + + + + + + + + + + +
+ + Output to char buffer + Demonstrate the use of xmlDocDumpMemory to output document to a character buffer + io2 + io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res + John Fleck + see Copyright for the status of this software. +
InputOutput
+ + <libxml/parser.h> + + + + + + + + + + + + +
+ + Parse an XML file to a tree and free it + Demonstrate the use of xmlReadFile() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree + parse1 test1.xml + parse1 test1.xml + Daniel Veillard + see Copyright for the status of this software. +
Parsing
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + + + + +
+ + Parse and validate an XML file to a tree and free the result + Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree. + parse2 test2.xml + parse2 test2.xml + Daniel Veillard + see Copyright for the status of this software. +
Parsing
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + + + + + + + + +
+ + Parse an XML document in memory to a tree and free it + Demonstrate the use of xmlReadMemory() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree + parse3 + parse3 + Daniel Veillard + see Copyright for the status of this software. +
Parsing
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + + + + +
+ + Parse an XML document chunk by chunk to a tree and free it + Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and xmlFreeDoc() to free the resulting tree + parse4 test3.xml + parse4 test3.xml + Daniel Veillard + see Copyright for the status of this software. +
Parsing
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + + + + + + + +
+ + Parse an XML file with an xmlReader + Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the informations about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.) + reader1 <filename> + reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + Daniel Veillard + see Copyright for the status of this software. +
xmlReader
+ + <libxml/xmlreader.h> + + + + + + + + + + + + + + + + + +
+ + Parse and validate an XML file with an xmlReader + Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.) + reader2 <valid_xml_filename> + reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + Daniel Veillard + see Copyright for the status of this software. +
xmlReader
+ + <libxml/xmlreader.h> + + + + + + + + + + + + + + + + + + +
+ + Show how to extract subdocuments with xmlReader + Demonstrate the use of xmlTextReaderPreservePattern() to parse an XML file with the xmlReader while collecting only some subparts of the document. (Note that the XMLReader functions require libxml2 version later than 2.6.) + reader3 + reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res + Daniel Veillard + see Copyright for the status of this software. +
xmlReader
+ + <libxml/xmlreader.h> + + + + + + + + + + +
+ + Parse multiple XML files reusing an xmlReader + Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context. (Note that the XMLReader functions require libxml2 version later than 2.6.) + reader4 <filename> [ filename ... ] + reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res + Graham Bennett + see Copyright for the status of this software. +
xmlReader
+ + <libxml/xmlreader.h> + + + + + + + + + +
+ + use various APIs for the xmlWriter + tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized. + testWriter + testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done + Alfred Mickautsch + see Copyright for the status of this software. +
xmlWriter
+ + <libxml/encoding.h> + <libxml/xmlwriter.h> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Navigates a tree to print element names + Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order. + tree1 filename_or_URL + tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res + Dodji Seketeli + see Copyright for the status of this software. +
Tree
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + +
+ + Creates a tree + Shows how to create document, nodes and dump it to stdout or file. + tree2 <filename> -Default output: stdout + tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res + Lucas Brasilino <brasilino@recife.pe.gov.br> + see Copyright for the status of this software +
Tree
+ + <libxml/tree.h> + <libxml/parser.h> + + + + + + + + + + + + +
+ + Evaluate XPath expression and prints result node set. + Shows how to evaluate XPath expression and register known namespaces in XPath context. + xpath1 <xml-file> <xpath-expr> [<known-ns-list>] + xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res + Aleksey Sanin + see Copyright for the status of this software. +
XPath
+ + <libxml/parser.h> + <libxml/xpath.h> + <libxml/xpathInternals.h> + <libxml/tree.h> + + + + + + + + + + + + + + + + + + + +
+ + Load a document, locate subelements with XPath, modify said elements and save the resulting document. + Shows how to make a full round-trip from a load/edit/save + xpath2 <xml-file> <xpath-expr> <new-value> + xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res + Aleksey Sanin and Daniel Veillard + see Copyright for the status of this software. +
XPath
+ + <libxml/parser.h> + <libxml/xpath.h> + <libxml/xpathInternals.h> + <libxml/tree.h> + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ +
+
+
diff --git a/libxml2-2.9.10/doc/examples/examples.xsl b/libxml2-2.9.10/doc/examples/examples.xsl new file mode 100644 index 0000000..bc93a3d --- /dev/null +++ b/libxml2-2.9.10/doc/examples/examples.xsl @@ -0,0 +1,174 @@ + + + + + + ../ + Examples Menu + + +
+ + +
+ +
+ + + + +
  • +
    + + + + + +
  • line : Type from
  • +
    + + + + + +
  • line : Function from
  • +
    + + + + + +
  • line : Macro from
  • +
    + + + +

    :

    +

    +

    Includes:

    +
      + + + +
    +

    Uses:

    +
      + + + + +
    +

    Usage:

    +

    +

    Author:

    +
    + + +
  • :

    +
      + + + +
    • :
    • +
      +
    +
  • +
    + + +

    The examples are stored per section depending on the main focus + of the example:

    +
      + + + + +
    +

    Getting the compilation options and libraries dependencies needed +to generate binaries from the examples is best done on Linux/Unix by using +the xml2-config script which should have been installed as part of make +install step or when installing the libxml2 development package:

    +
    gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`
    +
    + + + + +

    Examples

    + +
    +
    + + + Libxml2 set of examples + + + + + + + + + + + + + + + + +
    + + + + + +
    + + + + + + +
    + + + + +
    + + + + +
    + + +

    Daniel Veillard

    +
    +
    +
    +
    +
    + + +
    +
    + +
    diff --git a/libxml2-2.9.10/doc/examples/index.html b/libxml2-2.9.10/doc/examples/index.html new file mode 100644 index 0000000..9707759 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/index.html @@ -0,0 +1,14 @@ + + +Libxml2 set of examples
    Action against software patentsGnome2 LogoW3C LogoRed Hat Logo
    Made with Libxml2 Logo

    Libxml2 set of examples

    Examples Menu
    Related links

    The examples are stored per section depending on the main focus + of the example:

    • xmlWriter :

    • InputOutput :

      • io1.c: Example of custom Input/Output
      • io2.c: Output to char buffer
    • Tree :

      • tree1.c: Navigates a tree to print element names
      • tree2.c: Creates a tree
    • XPath :

      • xpath1.c: Evaluate XPath expression and prints result node set.
      • xpath2.c: Load a document, locate subelements with XPath, modify said elements and save the resulting document.
    • Parsing :

      • parse1.c: Parse an XML file to a tree and free it
      • parse2.c: Parse and validate an XML file to a tree and free the result
      • parse3.c: Parse an XML document in memory to a tree and free it
      • parse4.c: Parse an XML document chunk by chunk to a tree and free it
    • xmlReader :

      • reader1.c: Parse an XML file with an xmlReader
      • reader2.c: Parse and validate an XML file with an xmlReader
      • reader3.c: Show how to extract subdocuments with xmlReader
      • reader4.c: Parse multiple XML files reusing an xmlReader

    Getting the compilation options and libraries dependencies needed +to generate binaries from the examples is best done on Linux/Unix by using +the xml2-config script which should have been installed as part of make +install step or when installing the libxml2 development package:

    gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`

    InputOutput Examples

    io1.c: Example of custom Input/Output

    Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.

    Includes:

    Uses:

    Usage:

    io1

    Author: Daniel Veillard

    io2.c: Output to char buffer

    Demonstrate the use of xmlDocDumpMemory to output document to a character buffer

    Includes:

    Uses:

    Usage:

    io2

    Author: John Fleck

    Parsing Examples

    parse1.c: Parse an XML file to a tree and free it

    Demonstrate the use of xmlReadFile() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree

    Includes:

    Uses:

    Usage:

    parse1 test1.xml

    Author: Daniel Veillard

    parse2.c: Parse and validate an XML file to a tree and free the result

    Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.

    Includes:

    Uses:

    Usage:

    parse2 test2.xml

    Author: Daniel Veillard

    parse3.c: Parse an XML document in memory to a tree and free it

    Demonstrate the use of xmlReadMemory() to read an XML file into a tree and xmlFreeDoc() to free the resulting tree

    Includes:

    Uses:

    Usage:

    parse3

    Author: Daniel Veillard

    parse4.c: Parse an XML document chunk by chunk to a tree and free it

    Demonstrate the use of xmlCreatePushParserCtxt() and xmlParseChunk() to read an XML file progressively into a tree and xmlFreeDoc() to free the resulting tree

    Includes:

    Uses:

    Usage:

    parse4 test3.xml

    Author: Daniel Veillard

    Tree Examples

    tree1.c: Navigates a tree to print element names

    Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.

    Includes:

    Uses:

    Usage:

    tree1 filename_or_URL

    Author: Dodji Seketeli

    tree2.c: Creates a tree

    Shows how to create document, nodes and dump it to stdout or file.

    Includes:

    Uses:

    Usage:

    tree2 <filename> -Default output: stdout

    Author: Lucas Brasilino <brasilino@recife.pe.gov.br>

    XPath Examples

    xpath1.c: Evaluate XPath expression and prints result node set.

    Shows how to evaluate XPath expression and register known namespaces in XPath context.

    Includes:

    Uses:

    Usage:

    xpath1 <xml-file> <xpath-expr> [<known-ns-list>]

    Author: Aleksey Sanin

    xpath2.c: Load a document, locate subelements with XPath, modify said elements and save the resulting document.

    Shows how to make a full round-trip from a load/edit/save

    Includes:

    Uses:

    Usage:

    xpath2 <xml-file> <xpath-expr> <new-value>

    Author: Aleksey Sanin and Daniel Veillard

    xmlReader Examples

    reader1.c: Parse an XML file with an xmlReader

    Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the informations about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    Includes:

    Uses:

    Usage:

    reader1 <filename>

    Author: Daniel Veillard

    reader2.c: Parse and validate an XML file with an xmlReader

    Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    Includes:

    Uses:

    Usage:

    reader2 <valid_xml_filename>

    Author: Daniel Veillard

    reader3.c: Show how to extract subdocuments with xmlReader

    Demonstrate the use of xmlTextReaderPreservePattern() to parse an XML file with the xmlReader while collecting only some subparts of the document. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    Includes:

    Uses:

    Usage:

    reader3

    Author: Daniel Veillard

    reader4.c: Parse multiple XML files reusing an xmlReader

    Demonstrate the use of xmlReaderForFile() and xmlReaderNewFile to parse XML files while reusing the reader object and parser context. (Note that the XMLReader functions require libxml2 version later than 2.6.)

    Includes:

    Uses:

    Usage:

    reader4 <filename> [ filename ... ]

    Author: Graham Bennett

    xmlWriter Examples

    testWriter.c: use various APIs for the xmlWriter

    tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized.

    Includes:

    Uses:

    Usage:

    testWriter

    Author: Alfred Mickautsch

    Daniel Veillard

    diff --git a/libxml2-2.9.10/doc/examples/index.py b/libxml2-2.9.10/doc/examples/index.py new file mode 100755 index 0000000..ac44ec5 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/index.py @@ -0,0 +1,315 @@ +#!/usr/bin/python -u +# +# Indexes the examples and build an XML description +# +import string +import glob +import sys +try: + import libxml2 +except: + sys.exit(1) +sys.path.insert(0, "..") +from apibuild import CParser, escape + +examples = [] +extras = ['examples.xsl', 'index.html', 'index.py'] +tests = [] +sections = {} +symbols = {} +api_dict = None +api_doc = None + +def load_api(): + global api_dict + global api_doc + + if api_dict != None: + return + api_dict = {} + try: + print "loading ../libxml2-api.xml" + api_doc = libxml2.parseFile("../libxml2-api.xml") + except: + print "failed to parse ../libxml2-api.xml" + sys.exit(1) + +def find_symbol(name): + global api_dict + global api_doc + + if api_doc == None: + load_api() + + if name == None: + return + if api_dict.has_key(name): + return api_dict[name] + ctxt = api_doc.xpathNewContext() + res = ctxt.xpathEval("/api/symbols/*[@name = '%s']" % (name)) + if type(res) == type([]) and len(res) >= 1: + if len(res) > 1: + print "Found %d references to %s in the API" % (len(res), name) + node = res[0] + typ = node.name + file = node.xpathEval("string(@file)") + info = node.xpathEval("string(info)") + else: + print "Reference %s not found in the API" % (name) + return None + ret = (typ, file, info) + api_dict[name] = ret + return ret + +def parse_top_comment(filename, comment): + res = {} + lines = string.split(comment, "\n") + item = None + for line in lines: + while line != "" and (line[0] == ' ' or line[0] == '\t'): + line = line[1:] + while line != "" and line[0] == '*': + line = line[1:] + while line != "" and (line[0] == ' ' or line[0] == '\t'): + line = line[1:] + try: + (it, line) = string.split(line, ":", 1) + item = it + while line != "" and (line[0] == ' ' or line[0] == '\t'): + line = line[1:] + if res.has_key(item): + res[item] = res[item] + " " + line + else: + res[item] = line + except: + if item != None: + if res.has_key(item): + res[item] = res[item] + " " + line + else: + res[item] = line + return res + +def parse(filename, output): + global symbols + global sections + + parser = CParser(filename) + parser.collect_references() + idx = parser.parse() + info = parse_top_comment(filename, parser.top_comment) + output.write(" \n" % filename) + try: + synopsis = info['synopsis'] + output.write(" %s\n" % escape(synopsis)); + except: + print "Example %s lacks a synopsis description" % (filename) + try: + purpose = info['purpose'] + output.write(" %s\n" % escape(purpose)); + except: + print "Example %s lacks a purpose description" % (filename) + try: + usage = info['usage'] + output.write(" %s\n" % escape(usage)); + except: + print "Example %s lacks an usage description" % (filename) + try: + test = info['test'] + output.write(" %s\n" % escape(test)); + progname=filename[0:-2] + command=string.replace(test, progname, './' + progname, 1) + tests.append(command) + except: + pass + try: + author = info['author'] + output.write(" %s\n" % escape(author)); + except: + print "Example %s lacks an author description" % (filename) + try: + copy = info['copy'] + output.write(" %s\n" % escape(copy)); + except: + print "Example %s lacks a copyright description" % (filename) + try: + section = info['section'] + output.write("
    %s
    \n" % escape(section)); + if sections.has_key(section): + sections[section].append(filename) + else: + sections[section] = [filename] + except: + print "Example %s lacks a section description" % (filename) + for topic in info.keys(): + if topic != "purpose" and topic != "usage" and \ + topic != "author" and topic != "copy" and \ + topic != "section" and topic != "synopsis" and topic != "test": + str = info[topic] + output.write(" %s\n" % ( + escape(topic), escape(str))) + output.write(" \n") + for include in idx.includes.keys(): + if include.find("libxml") != -1: + output.write(" %s\n" % (escape(include))) + output.write(" \n") + output.write(" \n") + for ref in idx.references.keys(): + id = idx.references[ref] + name = id.get_name() + line = id.get_lineno() + if symbols.has_key(name): + sinfo = symbols[name] + refs = sinfo[0] + # gather at most 5 references per symbols + if refs > 5: + continue + sinfo.append(filename) + sinfo[0] = refs + 1 + else: + symbols[name] = [1, filename] + info = find_symbol(name) + if info != None: + type = info[0] + file = info[1] + output.write(" <%s line='%d' file='%s' name='%s'/>\n" % (type, + line, file, name)) + else: + type = id.get_type() + output.write(" <%s line='%d' name='%s'/>\n" % (type, + line, name)) + + output.write(" \n") + output.write("
    \n") + + return idx + +def dump_symbols(output): + global symbols + + output.write(" \n") + keys = symbols.keys() + keys.sort() + for symbol in keys: + output.write(" \n" % (symbol)) + info = symbols[symbol] + i = 1 + while i < len(info): + output.write(" \n" % (info[i])) + i = i + 1 + output.write(" \n") + output.write(" \n") + +def dump_sections(output): + global sections + + output.write(" \n") + keys = sections.keys() + keys.sort() + for section in keys: + output.write("
    \n" % (section)) + info = sections[section] + i = 0 + while i < len(info): + output.write(" \n" % (info[i])) + i = i + 1 + output.write("
    \n") + output.write("
    \n") + +def dump_Makefile(): + for file in glob.glob('*.xml'): + extras.append(file) + for file in glob.glob('*.res'): + extras.append(file) + Makefile="""## +## This file is auto-generated by index.py +## DO NOT EDIT !!! +## + +AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)/include +AM_CFLAGS = $(THREAD_CFLAGS) $(Z_CFLAGS) +LDADD = $(RDL_LIBS) $(STATIC_BINARIES) $(top_builddir)/libxml2.la $(THREAD_LIBS) $(Z_LIBS) $(ICONV_LIBS) -lm $(WIN32_EXTRA_LIBADD) + +CLEANFILES = *.tmp + +if REBUILD_DOCS +rebuild: examples.xml index.html +.PHONY: rebuild + +examples.xml: index.py $(check_PROGRAMS:=.c) + cd $(srcdir) && $(PYTHON) index.py + $(MAKE) Makefile + +index.html: examples.xml examples.xsl + cd $(srcdir) && xsltproc examples.xsl examples.xml && echo "Rebuilt web page" + -cd $(srcdir) && xmllint --valid --noout index.html +endif + +install-data-local: + $(MKDIR_P) $(DESTDIR)$(HTML_DIR) + -$(INSTALL) -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR) + +clean-local: + test -f Makefile.am || rm -f test?.xml + +""" + examples.sort() + extras.sort() + tests.sort() + EXTRA_DIST="" + for extra in extras: + EXTRA_DIST = EXTRA_DIST + " \\\n\t" + extra + Makefile = Makefile + "EXTRA_DIST =%s\n\n" % (EXTRA_DIST) + check_PROGRAMS="" + for example in examples: + check_PROGRAMS = check_PROGRAMS + " \\\n\t" + example + Makefile = Makefile + "check_PROGRAMS =%s\n\n" % (check_PROGRAMS) + for example in examples: + Makefile = Makefile + "%s_SOURCES = %s.c\n\n" % (example, example) + Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind' tests\n\n" + Makefile = Makefile + "tests: $(check_PROGRAMS)\n" + Makefile = Makefile + "\t@test -f Makefile.am || test -f test1.xml || $(LN_S) $(srcdir)/test?.xml .\n" + Makefile = Makefile + "\t@(echo '## examples regression tests')\n" + Makefile = Makefile + "\t@(echo > .memdump)\n" + for test in tests: + Makefile = Makefile + "\t@$(CHECKER) %s\n" % (test) + Makefile = Makefile + '\t@grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0\n' + Makefile = Makefile + "\t@rm *.tmp\n" + try: + old = open("Makefile.am", "r").read() + if old != Makefile: + n = open("Makefile.am", "w").write(Makefile) + print "Updated Makefile.am" + except: + print "Failed to read or save Makefile.am" +# # +# # Autogenerate the .cvsignore too ... DEPRECATED +# # +# ignore = """.memdump +#Makefile.in +#Makefile +#""" +# for example in examples: +# ignore = ignore + "%s\n" % (example) +# try: +# old = open(".cvsignore", "r").read() +# if old != ignore: +# n = open(".cvsignore", "w").write(ignore) +# print "Updated .cvsignore" +# except: +# print "Failed to read or save .cvsignore" + +if __name__ == "__main__": + load_api() + output = open("examples.xml", "w") + output.write("\n") + + for file in sorted(glob.glob('*.c')): + parse(file, output) + examples.append(file[:-2]) + + dump_symbols(output) + dump_sections(output) + output.write("\n") + output.close() + dump_Makefile() + diff --git a/libxml2-2.9.10/doc/examples/io1.c b/libxml2-2.9.10/doc/examples/io1.c new file mode 100644 index 0000000..d077cd8 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/io1.c @@ -0,0 +1,166 @@ +/** + * section: InputOutput + * synopsis: Example of custom Input/Output + * purpose: Demonstrate the use of xmlRegisterInputCallbacks + * to build a custom I/O layer, this is used in an + * XInclude method context to show how dynamic document can + * be built in a clean way. + * usage: io1 + * test: io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef LIBXML_XINCLUDE_ENABLED +static const char *result = "ab"; +static const char *cur = NULL; +static int rlen; + +/** + * sqlMatch: + * @URI: an URI to test + * + * Check for an sql: query + * + * Returns 1 if yes and 0 if another Input module should be used + */ +static int +sqlMatch(const char * URI) { + if ((URI != NULL) && (!strncmp(URI, "sql:", 4))) + return(1); + return(0); +} + +/** + * sqlOpen: + * @URI: an URI to test + * + * Return a pointer to the sql: query handler, in this example simply + * the current pointer... + * + * Returns an Input context or NULL in case or error + */ +static void * +sqlOpen(const char * URI) { + if ((URI == NULL) || (strncmp(URI, "sql:", 4))) + return(NULL); + cur = result; + rlen = strlen(result); + return((void *) cur); +} + +/** + * sqlClose: + * @context: the read context + * + * Close the sql: query handler + * + * Returns 0 or -1 in case of error + */ +static int +sqlClose(void * context) { + if (context == NULL) return(-1); + cur = NULL; + rlen = 0; + return(0); +} + +/** + * sqlRead: + * @context: the read context + * @buffer: where to store data + * @len: number of bytes to read + * + * Implement an sql: query read. + * + * Returns the number of bytes read or -1 in case of error + */ +static int +sqlRead(void * context, char * buffer, int len) { + const char *ptr = (const char *) context; + + if ((context == NULL) || (buffer == NULL) || (len < 0)) + return(-1); + + if (len > rlen) len = rlen; + memcpy(buffer, ptr, len); + rlen -= len; + return(len); +} + +const char *include = "\n\ +\n\ +

    List of people:

    \n\ + \n\ +
    \n"; + +int main(void) { + xmlDocPtr doc; + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /* + * register the new I/O handlers + */ + if (xmlRegisterInputCallbacks(sqlMatch, sqlOpen, sqlRead, sqlClose) < 0) { + fprintf(stderr, "failed to register SQL handler\n"); + exit(1); + } + /* + * parse include into a document + */ + doc = xmlReadMemory(include, strlen(include), "include.xml", NULL, 0); + if (doc == NULL) { + fprintf(stderr, "failed to parse the including file\n"); + exit(1); + } + + /* + * apply the XInclude process, this should trigger the I/O just + * registered. + */ + if (xmlXIncludeProcess(doc) <= 0) { + fprintf(stderr, "XInclude processing failed\n"); + exit(1); + } + +#ifdef LIBXML_OUTPUT_ENABLED + /* + * save the output for checking to stdout + */ + xmlDocDump(stdout, doc); +#endif + + /* + * Free the document + */ + xmlFreeDoc(doc); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} +#else +int main(void) { + fprintf(stderr, "XInclude support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/io1.res b/libxml2-2.9.10/doc/examples/io1.res new file mode 100644 index 0000000..4a4c036 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/io1.res @@ -0,0 +1,5 @@ + + +

    List of people:

    + ab +
    diff --git a/libxml2-2.9.10/doc/examples/io2.c b/libxml2-2.9.10/doc/examples/io2.c new file mode 100644 index 0000000..4676f4a --- /dev/null +++ b/libxml2-2.9.10/doc/examples/io2.c @@ -0,0 +1,58 @@ +/** + * section: InputOutput + * synopsis: Output to char buffer + * purpose: Demonstrate the use of xmlDocDumpMemory + * to output document to a character buffer + * usage: io2 + * test: io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res + * author: John Fleck + * copy: see Copyright for the status of this software. + */ + +#include + +#if defined(LIBXML_TREE_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) +int +main(void) +{ + + xmlNodePtr n; + xmlDocPtr doc; + xmlChar *xmlbuff; + int buffersize; + + /* + * Create the document. + */ + doc = xmlNewDoc(BAD_CAST "1.0"); + n = xmlNewNode(NULL, BAD_CAST "root"); + xmlNodeSetContent(n, BAD_CAST "content"); + xmlDocSetRootElement(doc, n); + + /* + * Dump the document to a buffer and print it + * for demonstration purposes. + */ + xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1); + printf("%s", (char *) xmlbuff); + + /* + * Free associated memory. + */ + xmlFree(xmlbuff); + xmlFreeDoc(doc); + + return (0); + +} +#else +#include + +int +main(void) +{ + fprintf(stderr, + "library not configured with tree and output support\n"); + return (1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/io2.res b/libxml2-2.9.10/doc/examples/io2.res new file mode 100644 index 0000000..8737b87 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/io2.res @@ -0,0 +1,2 @@ + +content diff --git a/libxml2-2.9.10/doc/examples/parse1.c b/libxml2-2.9.10/doc/examples/parse1.c new file mode 100644 index 0000000..e3c9d3a --- /dev/null +++ b/libxml2-2.9.10/doc/examples/parse1.c @@ -0,0 +1,56 @@ +/** + * section: Parsing + * synopsis: Parse an XML file to a tree and free it + * purpose: Demonstrate the use of xmlReadFile() to read an XML file + * into a tree and xmlFreeDoc() to free the resulting tree + * usage: parse1 test1.xml + * test: parse1 test1.xml + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include + +/** + * example1Func: + * @filename: a filename or an URL + * + * Parse the resource and free the resulting tree + */ +static void +example1Func(const char *filename) { + xmlDocPtr doc; /* the resulting document tree */ + + doc = xmlReadFile(filename, NULL, 0); + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + return; + } + xmlFreeDoc(doc); +} + +int main(int argc, char **argv) { + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + example1Func(argv[1]); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} diff --git a/libxml2-2.9.10/doc/examples/parse2.c b/libxml2-2.9.10/doc/examples/parse2.c new file mode 100644 index 0000000..4dcbfde --- /dev/null +++ b/libxml2-2.9.10/doc/examples/parse2.c @@ -0,0 +1,72 @@ +/** + * section: Parsing + * synopsis: Parse and validate an XML file to a tree and free the result + * purpose: Create a parser context for an XML file, then parse and validate + * the file, creating a tree, check the validation result + * and xmlFreeDoc() to free the resulting tree. + * usage: parse2 test2.xml + * test: parse2 test2.xml + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include + +/** + * exampleFunc: + * @filename: a filename or an URL + * + * Parse and validate the resource and free the resulting tree + */ +static void +exampleFunc(const char *filename) { + xmlParserCtxtPtr ctxt; /* the parser context */ + xmlDocPtr doc; /* the resulting document tree */ + + /* create a parser context */ + ctxt = xmlNewParserCtxt(); + if (ctxt == NULL) { + fprintf(stderr, "Failed to allocate parser context\n"); + return; + } + /* parse the file, activating the DTD validation option */ + doc = xmlCtxtReadFile(ctxt, filename, NULL, XML_PARSE_DTDVALID); + /* check if parsing succeeded */ + if (doc == NULL) { + fprintf(stderr, "Failed to parse %s\n", filename); + } else { + /* check if validation succeeded */ + if (ctxt->valid == 0) + fprintf(stderr, "Failed to validate %s\n", filename); + /* free up the resulting document */ + xmlFreeDoc(doc); + } + /* free up the parser context */ + xmlFreeParserCtxt(ctxt); +} + +int main(int argc, char **argv) { + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + exampleFunc(argv[1]); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} diff --git a/libxml2-2.9.10/doc/examples/parse3.c b/libxml2-2.9.10/doc/examples/parse3.c new file mode 100644 index 0000000..076a786 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/parse3.c @@ -0,0 +1,60 @@ +/** + * section: Parsing + * synopsis: Parse an XML document in memory to a tree and free it + * purpose: Demonstrate the use of xmlReadMemory() to read an XML file + * into a tree and xmlFreeDoc() to free the resulting tree + * usage: parse3 + * test: parse3 + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include + +static const char *document = ""; + +/** + * example3Func: + * @content: the content of the document + * @length: the length in bytes + * + * Parse the in memory document and free the resulting tree + */ +static void +example3Func(const char *content, int length) { + xmlDocPtr doc; /* the resulting document tree */ + + /* + * The document being in memory, it have no base per RFC 2396, + * and the "noname.xml" argument will serve as its base. + */ + doc = xmlReadMemory(content, length, "noname.xml", NULL, 0); + if (doc == NULL) { + fprintf(stderr, "Failed to parse document\n"); + return; + } + xmlFreeDoc(doc); +} + +int main(void) { + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + example3Func(document, 6); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} diff --git a/libxml2-2.9.10/doc/examples/parse4.c b/libxml2-2.9.10/doc/examples/parse4.c new file mode 100644 index 0000000..c7095e5 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/parse4.c @@ -0,0 +1,143 @@ +/** + * section: Parsing + * synopsis: Parse an XML document chunk by chunk to a tree and free it + * purpose: Demonstrate the use of xmlCreatePushParserCtxt() and + * xmlParseChunk() to read an XML file progressively + * into a tree and xmlFreeDoc() to free the resulting tree + * usage: parse4 test3.xml + * test: parse4 test3.xml + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include +#include + +#ifdef LIBXML_PUSH_ENABLED +static FILE *desc; + +/** + * readPacket: + * @mem: array to store the packet + * @size: the packet size + * + * read at most @size bytes from the document and store it in @mem + * + * Returns the number of bytes read + */ +static int +readPacket(char *mem, int size) { + int res; + + res = fread(mem, 1, size, desc); + return(res); +} + +/** + * example4Func: + * @filename: a filename or an URL + * + * Parse the resource and free the resulting tree + */ +static void +example4Func(const char *filename) { + xmlParserCtxtPtr ctxt; + char chars[4]; + xmlDocPtr doc; /* the resulting document tree */ + int res; + + /* + * Read a few first byte to check the input used for the + * encoding detection at the parser level. + */ + res = readPacket(chars, 4); + if (res <= 0) { + fprintf(stderr, "Failed to parse %s\n", filename); + return; + } + + /* + * Create a progressive parsing context, the 2 first arguments + * are not used since we want to build a tree and not use a SAX + * parsing interface. We also pass the first bytes of the document + * to allow encoding detection when creating the parser but this + * is optional. + */ + ctxt = xmlCreatePushParserCtxt(NULL, NULL, + chars, res, filename); + if (ctxt == NULL) { + fprintf(stderr, "Failed to create parser context !\n"); + return; + } + + /* + * loop on the input getting the document data, of course 4 bytes + * at a time is not realistic but allows to verify testing on small + * documents. + */ + while ((res = readPacket(chars, 4)) > 0) { + xmlParseChunk(ctxt, chars, res, 0); + } + + /* + * there is no more input, indicate the parsing is finished. + */ + xmlParseChunk(ctxt, chars, 0, 1); + + /* + * collect the document back and if it was wellformed + * and destroy the parser context. + */ + doc = ctxt->myDoc; + res = ctxt->wellFormed; + xmlFreeParserCtxt(ctxt); + + if (!res) { + fprintf(stderr, "Failed to parse %s\n", filename); + } + + /* + * since we don't use the document, destroy it now. + */ + xmlFreeDoc(doc); +} + +int main(int argc, char **argv) { + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /* + * simulate a progressive parsing using the input file. + */ + desc = fopen(argv[1], "rb"); + if (desc != NULL) { + example4Func(argv[1]); + fclose(desc); + } else { + fprintf(stderr, "Failed to parse %s\n", argv[1]); + } + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} +#else /* ! LIBXML_PUSH_ENABLED */ +int main(int argc, char **argv) { + fprintf(stderr, "Library not compiled with push parser support\n"); + return(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/reader1.c b/libxml2-2.9.10/doc/examples/reader1.c new file mode 100644 index 0000000..e8a005a --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader1.c @@ -0,0 +1,107 @@ +/** + * section: xmlReader + * synopsis: Parse an XML file with an xmlReader + * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file + * and dump the informations about the nodes found in the process. + * (Note that the XMLReader functions require libxml2 version later + * than 2.6.) + * usage: reader1 + * test: reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include + +#ifdef LIBXML_READER_ENABLED + +/** + * processNode: + * @reader: the xmlReader + * + * Dump information about the current node + */ +static void +processNode(xmlTextReaderPtr reader) { + const xmlChar *name, *value; + + name = xmlTextReaderConstName(reader); + if (name == NULL) + name = BAD_CAST "--"; + + value = xmlTextReaderConstValue(reader); + + printf("%d %d %s %d %d", + xmlTextReaderDepth(reader), + xmlTextReaderNodeType(reader), + name, + xmlTextReaderIsEmptyElement(reader), + xmlTextReaderHasValue(reader)); + if (value == NULL) + printf("\n"); + else { + if (xmlStrlen(value) > 40) + printf(" %.40s...\n", value); + else + printf(" %s\n", value); + } +} + +/** + * streamFile: + * @filename: the file name to parse + * + * Parse and print information about an XML file. + */ +static void +streamFile(const char *filename) { + xmlTextReaderPtr reader; + int ret; + + reader = xmlReaderForFile(filename, NULL, 0); + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + processNode(reader); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + if (ret != 0) { + fprintf(stderr, "%s : failed to parse\n", filename); + } + } else { + fprintf(stderr, "Unable to open %s\n", filename); + } +} + +int main(int argc, char **argv) { + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + streamFile(argv[1]); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} + +#else +int main(void) { + fprintf(stderr, "XInclude support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/reader1.res b/libxml2-2.9.10/doc/examples/reader1.res new file mode 100644 index 0000000..eb48d85 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader1.res @@ -0,0 +1,14 @@ +0 10 doc 0 0 +0 1 doc 0 0 +1 14 #text 0 1 + +1 1 src 1 0 +1 14 #text 0 1 + +1 1 dest 1 0 +1 14 #text 0 1 + +1 1 src 1 0 +1 14 #text 0 1 + +0 15 doc 0 0 diff --git a/libxml2-2.9.10/doc/examples/reader2.c b/libxml2-2.9.10/doc/examples/reader2.c new file mode 100644 index 0000000..043b137 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader2.c @@ -0,0 +1,122 @@ +/** + * section: xmlReader + * synopsis: Parse and validate an XML file with an xmlReader + * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file + * validating the content in the process and activating options + * like entities substitution, and DTD attributes defaulting. + * (Note that the XMLReader functions require libxml2 version later + * than 2.6.) + * usage: reader2 + * test: reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include + +#ifdef LIBXML_READER_ENABLED + +/** + * processNode: + * @reader: the xmlReader + * + * Dump information about the current node + */ +static void +processNode(xmlTextReaderPtr reader) { + const xmlChar *name, *value; + + name = xmlTextReaderConstName(reader); + if (name == NULL) + name = BAD_CAST "--"; + + value = xmlTextReaderConstValue(reader); + + printf("%d %d %s %d %d", + xmlTextReaderDepth(reader), + xmlTextReaderNodeType(reader), + name, + xmlTextReaderIsEmptyElement(reader), + xmlTextReaderHasValue(reader)); + if (value == NULL) + printf("\n"); + else { + if (xmlStrlen(value) > 40) + printf(" %.40s...\n", value); + else + printf(" %s\n", value); + } +} + +/** + * streamFile: + * @filename: the file name to parse + * + * Parse, validate and print information about an XML file. + */ +static void +streamFile(const char *filename) { + xmlTextReaderPtr reader; + int ret; + + + /* + * Pass some special parsing options to activate DTD attribute defaulting, + * entities substitution and DTD validation + */ + reader = xmlReaderForFile(filename, NULL, + XML_PARSE_DTDATTR | /* default DTD attributes */ + XML_PARSE_NOENT | /* substitute entities */ + XML_PARSE_DTDVALID); /* validate with the DTD */ + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + processNode(reader); + ret = xmlTextReaderRead(reader); + } + /* + * Once the document has been fully parsed check the validation results + */ + if (xmlTextReaderIsValid(reader) != 1) { + fprintf(stderr, "Document %s does not validate\n", filename); + } + xmlFreeTextReader(reader); + if (ret != 0) { + fprintf(stderr, "%s : failed to parse\n", filename); + } + } else { + fprintf(stderr, "Unable to open %s\n", filename); + } +} + +int main(int argc, char **argv) { + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + streamFile(argv[1]); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} + +#else +int main(void) { + fprintf(stderr, "XInclude support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/reader3.c b/libxml2-2.9.10/doc/examples/reader3.c new file mode 100644 index 0000000..1899474 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader3.c @@ -0,0 +1,120 @@ +/** + * section: xmlReader + * synopsis: Show how to extract subdocuments with xmlReader + * purpose: Demonstrate the use of xmlTextReaderPreservePattern() + * to parse an XML file with the xmlReader while collecting + * only some subparts of the document. + * (Note that the XMLReader functions require libxml2 version later + * than 2.6.) + * usage: reader3 + * test: reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res + * author: Daniel Veillard + * copy: see Copyright for the status of this software. + */ + +#include +#include + +#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + + +/** + * streamFile: + * @filename: the file name to parse + * + * Parse and print information about an XML file. + * + * Returns the resulting doc with just the elements preserved. + */ +static xmlDocPtr +extractFile(const char *filename, const xmlChar *pattern) { + xmlDocPtr doc; + xmlTextReaderPtr reader; + int ret; + + /* + * build an xmlReader for that file + */ + reader = xmlReaderForFile(filename, NULL, 0); + if (reader != NULL) { + /* + * add the pattern to preserve + */ + if (xmlTextReaderPreservePattern(reader, pattern, NULL) < 0) { + fprintf(stderr, "%s : failed add preserve pattern %s\n", + filename, (const char *) pattern); + } + /* + * Parse and traverse the tree, collecting the nodes in the process + */ + ret = xmlTextReaderRead(reader); + while (ret == 1) { + ret = xmlTextReaderRead(reader); + } + if (ret != 0) { + fprintf(stderr, "%s : failed to parse\n", filename); + xmlFreeTextReader(reader); + return(NULL); + } + /* + * get the resulting nodes + */ + doc = xmlTextReaderCurrentDoc(reader); + /* + * Free up the reader + */ + xmlFreeTextReader(reader); + } else { + fprintf(stderr, "Unable to open %s\n", filename); + return(NULL); + } + return(doc); +} + +int main(int argc, char **argv) { + const char *filename = "test3.xml"; + const char *pattern = "preserved"; + xmlDocPtr doc; + + if (argc == 3) { + filename = argv[1]; + pattern = argv[2]; + } + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + doc = extractFile(filename, (const xmlChar *) pattern); + if (doc != NULL) { + /* + * output the result. + */ + xmlDocDump(stdout, doc); + /* + * don't forget to free up the doc + */ + xmlFreeDoc(doc); + } + + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} + +#else +int main(void) { + fprintf(stderr, "Reader, Pattern or output support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/reader3.res b/libxml2-2.9.10/doc/examples/reader3.res new file mode 100644 index 0000000..20e2e82 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader3.res @@ -0,0 +1,13 @@ + + + content1 + + content2 + too + content3 + + content4 + + content5 + content6 + diff --git a/libxml2-2.9.10/doc/examples/reader4.c b/libxml2-2.9.10/doc/examples/reader4.c new file mode 100644 index 0000000..5ed5883 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader4.c @@ -0,0 +1,122 @@ +/** + * section: xmlReader + * synopsis: Parse multiple XML files reusing an xmlReader + * purpose: Demonstrate the use of xmlReaderForFile() and + * xmlReaderNewFile to parse XML files while reusing the reader object + * and parser context. (Note that the XMLReader functions require + * libxml2 version later than 2.6.) + * usage: reader4 [ filename ... ] + * test: reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res + * author: Graham Bennett + * copy: see Copyright for the status of this software. + */ + +#include +#include + +#ifdef LIBXML_READER_ENABLED + +static void processDoc(xmlTextReaderPtr readerPtr) { + int ret; + xmlDocPtr docPtr; + const xmlChar *URL; + + ret = xmlTextReaderRead(readerPtr); + while (ret == 1) { + ret = xmlTextReaderRead(readerPtr); + } + + /* + * One can obtain the document pointer to get interesting + * information about the document like the URL, but one must also + * be sure to clean it up at the end (see below). + */ + docPtr = xmlTextReaderCurrentDoc(readerPtr); + if (NULL == docPtr) { + fprintf(stderr, "failed to obtain document\n"); + return; + } + + URL = docPtr->URL; + if (NULL == URL) { + fprintf(stderr, "Failed to obtain URL\n"); + } + + if (ret != 0) { + fprintf(stderr, "%s: Failed to parse\n", URL); + return; + } + + printf("%s: Processed ok\n", (const char *)URL); +} + +int main(int argc, char **argv) { + xmlTextReaderPtr readerPtr; + int i; + xmlDocPtr docPtr; + + if (argc < 2) + return(1); + + /* + * this initialises the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /* + * Create a new reader for the first file and process the + * document. + */ + readerPtr = xmlReaderForFile(argv[1], NULL, 0); + if (NULL == readerPtr) { + fprintf(stderr, "%s: failed to create reader\n", argv[1]); + return(1); + } + processDoc(readerPtr); + + /* + * The reader can be reused for subsequent files. + */ + for (i=2; i < argc; ++i) { + xmlReaderNewFile(readerPtr, argv[i], NULL, 0); + if (NULL == readerPtr) { + fprintf(stderr, "%s: failed to create reader\n", argv[i]); + return(1); + } + processDoc(readerPtr); + } + + /* + * Since we've called xmlTextReaderCurrentDoc, we now have to + * clean up after ourselves. We only have to do this the last + * time, because xmlReaderNewFile calls xmlCtxtReset which takes + * care of it. + */ + docPtr = xmlTextReaderCurrentDoc(readerPtr); + if (docPtr != NULL) + xmlFreeDoc(docPtr); + + /* + * Clean up the reader. + */ + xmlFreeTextReader(readerPtr); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} + +#else +int main(void) { + fprintf(stderr, "xmlReader support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/reader4.res b/libxml2-2.9.10/doc/examples/reader4.res new file mode 100644 index 0000000..b793f82 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/reader4.res @@ -0,0 +1,3 @@ +test1.xml: Processed ok +test2.xml: Processed ok +test3.xml: Processed ok diff --git a/libxml2-2.9.10/doc/examples/test1.xml b/libxml2-2.9.10/doc/examples/test1.xml new file mode 100644 index 0000000..69d62f2 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/test1.xml @@ -0,0 +1 @@ + diff --git a/libxml2-2.9.10/doc/examples/test2.xml b/libxml2-2.9.10/doc/examples/test2.xml new file mode 100644 index 0000000..7390f5e --- /dev/null +++ b/libxml2-2.9.10/doc/examples/test2.xml @@ -0,0 +1,13 @@ + + + + + +]> + + + + + + diff --git a/libxml2-2.9.10/doc/examples/test3.xml b/libxml2-2.9.10/doc/examples/test3.xml new file mode 100644 index 0000000..4d0828f --- /dev/null +++ b/libxml2-2.9.10/doc/examples/test3.xml @@ -0,0 +1,39 @@ + + + + + + + This text node must be discarded + + + + + content1 + + content2 + too + content3 + + content4 + + content5 + content6 + + This text node must be discarded + + + + This text node must be discarded + + This text node must be discarded + + This text node must be discarded + + + + This text node must be discarded + + + + diff --git a/libxml2-2.9.10/doc/examples/testWriter.c b/libxml2-2.9.10/doc/examples/testWriter.c new file mode 100644 index 0000000..82e8d3a --- /dev/null +++ b/libxml2-2.9.10/doc/examples/testWriter.c @@ -0,0 +1,1198 @@ +/** + * section: xmlWriter + * synopsis: use various APIs for the xmlWriter + * purpose: tests a number of APIs for the xmlWriter, especially + * the various methods to write to a filename, to a memory + * buffer, to a new document, or to a subtree. It shows how to + * do encoding string conversions too. The resulting + * documents are then serialized. + * usage: testWriter + * test: testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done + * author: Alfred Mickautsch + * copy: see Copyright for the status of this software. + */ +#include +#include +#include +#include + +#if defined(LIBXML_WRITER_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + +#define MY_ENCODING "ISO-8859-1" + +void testXmlwriterFilename(const char *uri); +void testXmlwriterMemory(const char *file); +void testXmlwriterDoc(const char *file); +void testXmlwriterTree(const char *file); +xmlChar *ConvertInput(const char *in, const char *encoding); + +int +main(void) +{ + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /* first, the file version */ + testXmlwriterFilename("writer1.tmp"); + + /* next, the memory version */ + testXmlwriterMemory("writer2.tmp"); + + /* next, the DOM version */ + testXmlwriterDoc("writer3.tmp"); + + /* next, the tree version */ + testXmlwriterTree("writer4.tmp"); + + /* + * Cleanup function for the XML library. + */ + xmlCleanupParser(); + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return 0; +} + +/** + * testXmlwriterFilename: + * @uri: the output URI + * + * test the xmlWriter interface when writing to a new file + */ +void +testXmlwriterFilename(const char *uri) +{ + int rc; + xmlTextWriterPtr writer; + xmlChar *tmp; + + /* Create a new XmlWriter for uri, with no compression. */ + writer = xmlNewTextWriterFilename(uri, 0); + if (writer == NULL) { + printf("testXmlwriterFilename: Error creating the xml writer\n"); + return; + } + + /* Start the document with the xml default for the version, + * encoding ISO 8859-1 and the default for the standalone + * declaration. */ + rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartDocument\n"); + return; + } + + /* Start an element named "EXAMPLE". Since thist is the first + * element, this will be the root element of the document. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write a comment as child of EXAMPLE. + * Please observe, that the input to the xmlTextWriter functions + * HAS to be in UTF-8, even if the output XML is encoded + * in iso-8859-1 */ + tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>", + MY_ENCODING); + rc = xmlTextWriterWriteComment(writer, tmp); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "ORDER" as child of EXAMPLE. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Add an attribute with name "version" and value "1.0" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version", + BAD_CAST "1.0"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Add an attribute with name "xml:lang" and value "de" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", + BAD_CAST "de"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Write a comment as child of ORDER */ + tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING); + rc = xmlTextWriterWriteFormatComment(writer, + "This is another comment with special chars: %s", + tmp); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "HEADER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "X_ORDER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID", + "%010d", 53535); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "CUSTOMER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID", + "%d", 1010); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "NAME_1" as child of HEADER. */ + tmp = ConvertInput("M\xFCller", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Write an element named "NAME_2" as child of HEADER. */ + tmp = ConvertInput("J\xF6rg", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Close the element named HEADER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRIES" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 10); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 20); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Close the element named ENTRIES. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "FOOTER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER"); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "TEXT" as child of FOOTER. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT", + BAD_CAST "This is a text."); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Close the element named FOOTER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Here we could close the elements ORDER and EXAMPLE using the + * function xmlTextWriterEndElement, but since we do not want to + * write any other elements, we simply call xmlTextWriterEndDocument, + * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); + if (rc < 0) { + printf + ("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n"); + return; + } + + xmlFreeTextWriter(writer); +} + +/** + * testXmlwriterMemory: + * @file: the output file + * + * test the xmlWriter interface when writing to memory + */ +void +testXmlwriterMemory(const char *file) +{ + int rc; + xmlTextWriterPtr writer; + xmlBufferPtr buf; + xmlChar *tmp; + FILE *fp; + + /* Create a new XML buffer, to which the XML document will be + * written */ + buf = xmlBufferCreate(); + if (buf == NULL) { + printf("testXmlwriterMemory: Error creating the xml buffer\n"); + return; + } + + /* Create a new XmlWriter for memory, with no compression. + * Remark: there is no compression for this kind of xmlTextWriter */ + writer = xmlNewTextWriterMemory(buf, 0); + if (writer == NULL) { + printf("testXmlwriterMemory: Error creating the xml writer\n"); + return; + } + + /* Start the document with the xml default for the version, + * encoding ISO 8859-1 and the default for the standalone + * declaration. */ + rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartDocument\n"); + return; + } + + /* Start an element named "EXAMPLE". Since thist is the first + * element, this will be the root element of the document. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write a comment as child of EXAMPLE. + * Please observe, that the input to the xmlTextWriter functions + * HAS to be in UTF-8, even if the output XML is encoded + * in iso-8859-1 */ + tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>", + MY_ENCODING); + rc = xmlTextWriterWriteComment(writer, tmp); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "ORDER" as child of EXAMPLE. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Add an attribute with name "version" and value "1.0" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version", + BAD_CAST "1.0"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Add an attribute with name "xml:lang" and value "de" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", + BAD_CAST "de"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Write a comment as child of ORDER */ + tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING); + rc = xmlTextWriterWriteFormatComment(writer, + "This is another comment with special chars: %s", + tmp); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "HEADER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "X_ORDER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID", + "%010d", 53535); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "CUSTOMER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID", + "%d", 1010); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "NAME_1" as child of HEADER. */ + tmp = ConvertInput("M\xFCller", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Write an element named "NAME_2" as child of HEADER. */ + tmp = ConvertInput("J\xF6rg", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp); + + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Close the element named HEADER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRIES" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 10); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 20); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Close the element named ENTRIES. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "FOOTER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER"); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "TEXT" as child of FOOTER. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT", + BAD_CAST "This is a text."); + if (rc < 0) { + printf + ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Close the element named FOOTER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Here we could close the elements ORDER and EXAMPLE using the + * function xmlTextWriterEndElement, but since we do not want to + * write any other elements, we simply call xmlTextWriterEndDocument, + * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); + if (rc < 0) { + printf("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n"); + return; + } + + xmlFreeTextWriter(writer); + + fp = fopen(file, "w"); + if (fp == NULL) { + printf("testXmlwriterMemory: Error at fopen\n"); + return; + } + + fprintf(fp, "%s", (const char *) buf->content); + + fclose(fp); + + xmlBufferFree(buf); +} + +/** + * testXmlwriterDoc: + * @file: the output file + * + * test the xmlWriter interface when creating a new document + */ +void +testXmlwriterDoc(const char *file) +{ + int rc; + xmlTextWriterPtr writer; + xmlChar *tmp; + xmlDocPtr doc; + + + /* Create a new XmlWriter for DOM, with no compression. */ + writer = xmlNewTextWriterDoc(&doc, 0); + if (writer == NULL) { + printf("testXmlwriterDoc: Error creating the xml writer\n"); + return; + } + + /* Start the document with the xml default for the version, + * encoding ISO 8859-1 and the default for the standalone + * declaration. */ + rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartDocument\n"); + return; + } + + /* Start an element named "EXAMPLE". Since thist is the first + * element, this will be the root element of the document. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write a comment as child of EXAMPLE. + * Please observe, that the input to the xmlTextWriter functions + * HAS to be in UTF-8, even if the output XML is encoded + * in iso-8859-1 */ + tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>", + MY_ENCODING); + rc = xmlTextWriterWriteComment(writer, tmp); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "ORDER" as child of EXAMPLE. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Add an attribute with name "version" and value "1.0" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version", + BAD_CAST "1.0"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Add an attribute with name "xml:lang" and value "de" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", + BAD_CAST "de"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Write a comment as child of ORDER */ + tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING); + rc = xmlTextWriterWriteFormatComment(writer, + "This is another comment with special chars: %s", + tmp); + if (rc < 0) { + printf + ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "HEADER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "X_ORDER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID", + "%010d", 53535); + if (rc < 0) { + printf + ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "CUSTOMER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID", + "%d", 1010); + if (rc < 0) { + printf + ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "NAME_1" as child of HEADER. */ + tmp = ConvertInput("M\xFCller", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Write an element named "NAME_2" as child of HEADER. */ + tmp = ConvertInput("J\xF6rg", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Close the element named HEADER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRIES" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 10); + if (rc < 0) { + printf + ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 20); + if (rc < 0) { + printf + ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Close the element named ENTRIES. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "FOOTER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER"); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "TEXT" as child of FOOTER. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT", + BAD_CAST "This is a text."); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Close the element named FOOTER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Here we could close the elements ORDER and EXAMPLE using the + * function xmlTextWriterEndElement, but since we do not want to + * write any other elements, we simply call xmlTextWriterEndDocument, + * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); + if (rc < 0) { + printf("testXmlwriterDoc: Error at xmlTextWriterEndDocument\n"); + return; + } + + xmlFreeTextWriter(writer); + + xmlSaveFileEnc(file, doc, MY_ENCODING); + + xmlFreeDoc(doc); +} + +/** + * testXmlwriterTree: + * @file: the output file + * + * test the xmlWriter interface when writing to a subtree + */ +void +testXmlwriterTree(const char *file) +{ + int rc; + xmlTextWriterPtr writer; + xmlDocPtr doc; + xmlNodePtr node; + xmlChar *tmp; + + /* Create a new XML DOM tree, to which the XML document will be + * written */ + doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION); + if (doc == NULL) { + printf + ("testXmlwriterTree: Error creating the xml document tree\n"); + return; + } + + /* Create a new XML node, to which the XML document will be + * appended */ + node = xmlNewDocNode(doc, NULL, BAD_CAST "EXAMPLE", NULL); + if (node == NULL) { + printf("testXmlwriterTree: Error creating the xml node\n"); + return; + } + + /* Make ELEMENT the root node of the tree */ + xmlDocSetRootElement(doc, node); + + /* Create a new XmlWriter for DOM tree, with no compression. */ + writer = xmlNewTextWriterTree(doc, node, 0); + if (writer == NULL) { + printf("testXmlwriterTree: Error creating the xml writer\n"); + return; + } + + /* Start the document with the xml default for the version, + * encoding ISO 8859-1 and the default for the standalone + * declaration. */ + rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartDocument\n"); + return; + } + + /* Write a comment as child of EXAMPLE. + * Please observe, that the input to the xmlTextWriter functions + * HAS to be in UTF-8, even if the output XML is encoded + * in iso-8859-1 */ + tmp = ConvertInput("This is a comment with special chars: <\xE4\xF6\xFC>", + MY_ENCODING); + rc = xmlTextWriterWriteComment(writer, tmp); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "ORDER" as child of EXAMPLE. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Add an attribute with name "version" and value "1.0" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version", + BAD_CAST "1.0"); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Add an attribute with name "xml:lang" and value "de" to ORDER. */ + rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang", + BAD_CAST "de"); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n"); + return; + } + + /* Write a comment as child of ORDER */ + tmp = ConvertInput("<\xE4\xF6\xFC>", MY_ENCODING); + rc = xmlTextWriterWriteFormatComment(writer, + "This is another comment with special chars: %s", + tmp); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteFormatComment\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Start an element named "HEADER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "X_ORDER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID", + "%010d", 53535); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "CUSTOMER_ID" as child of HEADER. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID", + "%d", 1010); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Write an element named "NAME_1" as child of HEADER. */ + tmp = ConvertInput("M\xFCller", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1", tmp); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Write an element named "NAME_2" as child of HEADER. */ + tmp = ConvertInput("J\xF6rg", MY_ENCODING); + rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2", tmp); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n"); + return; + } + if (tmp != NULL) xmlFree(tmp); + + /* Close the element named HEADER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRIES" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 10); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "ENTRY" as child of ENTRIES. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "ARTICLE" as child of ENTRY. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE", + BAD_CAST ""); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Write an element named "ENTRY_NO" as child of ENTRY. */ + rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d", + 20); + if (rc < 0) { + printf + ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n"); + return; + } + + /* Close the element named ENTRY. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Close the element named ENTRIES. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Start an element named "FOOTER" as child of ORDER. */ + rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER"); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n"); + return; + } + + /* Write an element named "TEXT" as child of FOOTER. */ + rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT", + BAD_CAST "This is a text."); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n"); + return; + } + + /* Close the element named FOOTER. */ + rc = xmlTextWriterEndElement(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n"); + return; + } + + /* Here we could close the elements ORDER and EXAMPLE using the + * function xmlTextWriterEndElement, but since we do not want to + * write any other elements, we simply call xmlTextWriterEndDocument, + * which will do all the work. */ + rc = xmlTextWriterEndDocument(writer); + if (rc < 0) { + printf("testXmlwriterTree: Error at xmlTextWriterEndDocument\n"); + return; + } + + xmlFreeTextWriter(writer); + + xmlSaveFileEnc(file, doc, MY_ENCODING); + + xmlFreeDoc(doc); +} + +/** + * ConvertInput: + * @in: string in a given encoding + * @encoding: the encoding used + * + * Converts @in into UTF-8 for processing with libxml2 APIs + * + * Returns the converted UTF-8 string, or NULL in case of error. + */ +xmlChar * +ConvertInput(const char *in, const char *encoding) +{ + xmlChar *out; + int ret; + int size; + int out_size; + int temp; + xmlCharEncodingHandlerPtr handler; + + if (in == 0) + return 0; + + handler = xmlFindCharEncodingHandler(encoding); + + if (!handler) { + printf("ConvertInput: no encoding handler found for '%s'\n", + encoding ? encoding : ""); + return 0; + } + + size = (int) strlen(in) + 1; + out_size = size * 2 - 1; + out = (unsigned char *) xmlMalloc((size_t) out_size); + + if (out != 0) { + temp = size - 1; + ret = handler->input(out, &out_size, (const xmlChar *) in, &temp); + if ((ret < 0) || (temp - size + 1)) { + if (ret < 0) { + printf("ConvertInput: conversion wasn't successful.\n"); + } else { + printf + ("ConvertInput: conversion wasn't successful. converted: %i octets.\n", + temp); + } + + xmlFree(out); + out = 0; + } else { + out = (unsigned char *) xmlRealloc(out, out_size + 1); + out[out_size] = 0; /*null terminating out */ + } + } else { + printf("ConvertInput: no mem\n"); + } + + return out; +} + +#else +int main(void) { + fprintf(stderr, "Writer or output support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/tree1.c b/libxml2-2.9.10/doc/examples/tree1.c new file mode 100644 index 0000000..e6faefc --- /dev/null +++ b/libxml2-2.9.10/doc/examples/tree1.c @@ -0,0 +1,94 @@ +/** + * section: Tree + * synopsis: Navigates a tree to print element names + * purpose: Parse a file to a tree, use xmlDocGetRootElement() to + * get the root element, then walk the document and print + * all the element name in document order. + * usage: tree1 filename_or_URL + * test: tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res + * author: Dodji Seketeli + * copy: see Copyright for the status of this software. + */ +#include +#include +#include + +#ifdef LIBXML_TREE_ENABLED + +/* + *To compile this file using gcc you can type + *gcc `xml2-config --cflags --libs` -o xmlexample libxml2-example.c + */ + +/** + * print_element_names: + * @a_node: the initial xml node to consider. + * + * Prints the names of the all the xml elements + * that are siblings or children of a given xml node. + */ +static void +print_element_names(xmlNode * a_node) +{ + xmlNode *cur_node = NULL; + + for (cur_node = a_node; cur_node; cur_node = cur_node->next) { + if (cur_node->type == XML_ELEMENT_NODE) { + printf("node type: Element, name: %s\n", cur_node->name); + } + + print_element_names(cur_node->children); + } +} + + +/** + * Simple example to parse a file called "file.xml", + * walk down the DOM, and print the name of the + * xml elements nodes. + */ +int +main(int argc, char **argv) +{ + xmlDoc *doc = NULL; + xmlNode *root_element = NULL; + + if (argc != 2) + return(1); + + /* + * this initialize the library and check potential ABI mismatches + * between the version it was compiled for and the actual shared + * library used. + */ + LIBXML_TEST_VERSION + + /*parse the file and get the DOM */ + doc = xmlReadFile(argv[1], NULL, 0); + + if (doc == NULL) { + printf("error: could not parse file %s\n", argv[1]); + } + + /*Get the root element node */ + root_element = xmlDocGetRootElement(doc); + + print_element_names(root_element); + + /*free the document */ + xmlFreeDoc(doc); + + /* + *Free the global variables that may + *have been allocated by the parser. + */ + xmlCleanupParser(); + + return 0; +} +#else +int main(void) { + fprintf(stderr, "Tree support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/tree1.res b/libxml2-2.9.10/doc/examples/tree1.res new file mode 100644 index 0000000..7b14ad0 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/tree1.res @@ -0,0 +1,4 @@ +node type: Element, name: doc +node type: Element, name: src +node type: Element, name: dest +node type: Element, name: src diff --git a/libxml2-2.9.10/doc/examples/tree2.c b/libxml2-2.9.10/doc/examples/tree2.c new file mode 100644 index 0000000..6548e29 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/tree2.c @@ -0,0 +1,117 @@ +/* + * section: Tree + * synopsis: Creates a tree + * purpose: Shows how to create document, nodes and dump it to stdout or file. + * usage: tree2 -Default output: stdout + * test: tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res + * author: Lucas Brasilino + * copy: see Copyright for the status of this software + */ + +#include +#include +#include + +#if defined(LIBXML_TREE_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) + +/* + *To compile this file using gcc you can type + *gcc `xml2-config --cflags --libs` -o tree2 tree2.c + */ + +/* A simple example how to create DOM. Libxml2 automagically + * allocates the necessary amount of memory to it. +*/ +int +main(int argc, char **argv) +{ + xmlDocPtr doc = NULL; /* document pointer */ + xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */ + char buff[256]; + int i, j; + + LIBXML_TEST_VERSION; + + /* + * Creates a new document, a node and set it as a root node + */ + doc = xmlNewDoc(BAD_CAST "1.0"); + root_node = xmlNewNode(NULL, BAD_CAST "root"); + xmlDocSetRootElement(doc, root_node); + + /* + * Creates a DTD declaration. Isn't mandatory. + */ + xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd"); + + /* + * xmlNewChild() creates a new node, which is "attached" as child node + * of root_node node. + */ + xmlNewChild(root_node, NULL, BAD_CAST "node1", + BAD_CAST "content of node 1"); + /* + * The same as above, but the new child node doesn't have a content + */ + xmlNewChild(root_node, NULL, BAD_CAST "node2", NULL); + + /* + * xmlNewProp() creates attributes, which is "attached" to an node. + * It returns xmlAttrPtr, which isn't used here. + */ + node = + xmlNewChild(root_node, NULL, BAD_CAST "node3", + BAD_CAST "this node has attributes"); + xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes"); + xmlNewProp(node, BAD_CAST "foo", BAD_CAST "bar"); + + /* + * Here goes another way to create nodes. xmlNewNode() and xmlNewText + * creates a node and a text node separately. They are "attached" + * by xmlAddChild() + */ + node = xmlNewNode(NULL, BAD_CAST "node4"); + node1 = xmlNewText(BAD_CAST + "other way to create content (which is also a node)"); + xmlAddChild(node, node1); + xmlAddChild(root_node, node); + + /* + * A simple loop that "automates" nodes creation + */ + for (i = 5; i < 7; i++) { + sprintf(buff, "node%d", i); + node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL); + for (j = 1; j < 4; j++) { + sprintf(buff, "node%d%d", i, j); + node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL); + xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes")); + } + } + + /* + * Dumping document to stdio or file + */ + xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1); + + /*free the document */ + xmlFreeDoc(doc); + + /* + *Free the global variables that may + *have been allocated by the parser. + */ + xmlCleanupParser(); + + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return(0); +} +#else +int main(void) { + fprintf(stderr, "tree support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/tree2.res b/libxml2-2.9.10/doc/examples/tree2.res new file mode 100644 index 0000000..ed00195 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/tree2.res @@ -0,0 +1,18 @@ + + + + content of node 1 + + this node has attributes + other way to create content (which is also a node) + + + + + + + + + + + diff --git a/libxml2-2.9.10/doc/examples/tst.xml b/libxml2-2.9.10/doc/examples/tst.xml new file mode 100644 index 0000000..1cc6c95 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/tst.xml @@ -0,0 +1,7 @@ + + hello + + + goodbye + + diff --git a/libxml2-2.9.10/doc/examples/writer.xml b/libxml2-2.9.10/doc/examples/writer.xml new file mode 100644 index 0000000..6ab05fd --- /dev/null +++ b/libxml2-2.9.10/doc/examples/writer.xml @@ -0,0 +1,2 @@ + +
    00000535351010MüllerJörg
    <Test>
    10
    <Test 2>
    20
    This is a text.
    diff --git a/libxml2-2.9.10/doc/examples/xpath1.c b/libxml2-2.9.10/doc/examples/xpath1.c new file mode 100644 index 0000000..0a31650 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/xpath1.c @@ -0,0 +1,250 @@ +/** + * section: XPath + * synopsis: Evaluate XPath expression and prints result node set. + * purpose: Shows how to evaluate XPath expression and register + * known namespaces in XPath context. + * usage: xpath1 [] + * test: xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res + * author: Aleksey Sanin + * copy: see Copyright for the status of this software. + */ +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED) + + +static void usage(const char *name); +int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList); +int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList); +void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output); + +int +main(int argc, char **argv) { + /* Parse command line and process file */ + if((argc < 3) || (argc > 4)) { + fprintf(stderr, "Error: wrong number of arguments.\n"); + usage(argv[0]); + return(-1); + } + + /* Init libxml */ + xmlInitParser(); + LIBXML_TEST_VERSION + + /* Do the main job */ + if(execute_xpath_expression(argv[1], BAD_CAST argv[2], (argc > 3) ? BAD_CAST argv[3] : NULL) < 0) { + usage(argv[0]); + return(-1); + } + + /* Shutdown libxml */ + xmlCleanupParser(); + + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return 0; +} + +/** + * usage: + * @name: the program name. + * + * Prints usage information. + */ +static void +usage(const char *name) { + assert(name); + + fprintf(stderr, "Usage: %s []\n", name); + fprintf(stderr, "where is a list of known namespaces\n"); + fprintf(stderr, "in \"= =href2> ...\" format\n"); +} + +/** + * execute_xpath_expression: + * @filename: the input XML filename. + * @xpathExpr: the xpath expression for evaluation. + * @nsList: the optional list of known namespaces in + * "= =href2> ..." format. + * + * Parses input XML file, evaluates XPath expression and prints results. + * + * Returns 0 on success and a negative value otherwise. + */ +int +execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList) { + xmlDocPtr doc; + xmlXPathContextPtr xpathCtx; + xmlXPathObjectPtr xpathObj; + + assert(filename); + assert(xpathExpr); + + /* Load XML document */ + doc = xmlParseFile(filename); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); + return(-1); + } + + /* Create xpath evaluation context */ + xpathCtx = xmlXPathNewContext(doc); + if(xpathCtx == NULL) { + fprintf(stderr,"Error: unable to create new XPath context\n"); + xmlFreeDoc(doc); + return(-1); + } + + /* Register namespaces from list (if any) */ + if((nsList != NULL) && (register_namespaces(xpathCtx, nsList) < 0)) { + fprintf(stderr,"Error: failed to register namespaces list \"%s\"\n", nsList); + xmlXPathFreeContext(xpathCtx); + xmlFreeDoc(doc); + return(-1); + } + + /* Evaluate xpath expression */ + xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); + if(xpathObj == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr); + xmlXPathFreeContext(xpathCtx); + xmlFreeDoc(doc); + return(-1); + } + + /* Print results */ + print_xpath_nodes(xpathObj->nodesetval, stdout); + + /* Cleanup */ + xmlXPathFreeObject(xpathObj); + xmlXPathFreeContext(xpathCtx); + xmlFreeDoc(doc); + + return(0); +} + +/** + * register_namespaces: + * @xpathCtx: the pointer to an XPath context. + * @nsList: the list of known namespaces in + * "= =href2> ..." format. + * + * Registers namespaces from @nsList in @xpathCtx. + * + * Returns 0 on success and a negative value otherwise. + */ +int +register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList) { + xmlChar* nsListDup; + xmlChar* prefix; + xmlChar* href; + xmlChar* next; + + assert(xpathCtx); + assert(nsList); + + nsListDup = xmlStrdup(nsList); + if(nsListDup == NULL) { + fprintf(stderr, "Error: unable to strdup namespaces list\n"); + return(-1); + } + + next = nsListDup; + while(next != NULL) { + /* skip spaces */ + while((*next) == ' ') next++; + if((*next) == '\0') break; + + /* find prefix */ + prefix = next; + next = (xmlChar*)xmlStrchr(next, '='); + if(next == NULL) { + fprintf(stderr,"Error: invalid namespaces list format\n"); + xmlFree(nsListDup); + return(-1); + } + *(next++) = '\0'; + + /* find href */ + href = next; + next = (xmlChar*)xmlStrchr(next, ' '); + if(next != NULL) { + *(next++) = '\0'; + } + + /* do register namespace */ + if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0) { + fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href); + xmlFree(nsListDup); + return(-1); + } + } + + xmlFree(nsListDup); + return(0); +} + +/** + * print_xpath_nodes: + * @nodes: the nodes set. + * @output: the output file handle. + * + * Prints the @nodes content to @output. + */ +void +print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) { + xmlNodePtr cur; + int size; + int i; + + assert(output); + size = (nodes) ? nodes->nodeNr : 0; + + fprintf(output, "Result (%d nodes):\n", size); + for(i = 0; i < size; ++i) { + assert(nodes->nodeTab[i]); + + if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) { + xmlNsPtr ns; + + ns = (xmlNsPtr)nodes->nodeTab[i]; + cur = (xmlNodePtr)ns->next; + if(cur->ns) { + fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n", + ns->prefix, ns->href, cur->ns->href, cur->name); + } else { + fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n", + ns->prefix, ns->href, cur->name); + } + } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) { + cur = nodes->nodeTab[i]; + if(cur->ns) { + fprintf(output, "= element node \"%s:%s\"\n", + cur->ns->href, cur->name); + } else { + fprintf(output, "= element node \"%s\"\n", + cur->name); + } + } else { + cur = nodes->nodeTab[i]; + fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type); + } + } +} + +#else +int main(void) { + fprintf(stderr, "XPath support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/xpath1.res b/libxml2-2.9.10/doc/examples/xpath1.res new file mode 100644 index 0000000..76af3a9 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/xpath1.res @@ -0,0 +1,5 @@ +Result (4 nodes): += element node "child2" += element node "child2" += element node "child2" += element node "child2" diff --git a/libxml2-2.9.10/doc/examples/xpath2.c b/libxml2-2.9.10/doc/examples/xpath2.c new file mode 100644 index 0000000..f604114 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/xpath2.c @@ -0,0 +1,190 @@ +/** + * section: XPath + * synopsis: Load a document, locate subelements with XPath, modify + * said elements and save the resulting document. + * purpose: Shows how to make a full round-trip from a load/edit/save + * usage: xpath2 + * test: xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res + * author: Aleksey Sanin and Daniel Veillard + * copy: see Copyright for the status of this software. + */ +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED) && \ + defined(LIBXML_OUTPUT_ENABLED) + + +static void usage(const char *name); +static int example4(const char *filename, const xmlChar * xpathExpr, + const xmlChar * value); +static void update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar * value); + + +int +main(int argc, char **argv) { + /* Parse command line and process file */ + if (argc != 4) { + fprintf(stderr, "Error: wrong number of arguments.\n"); + usage(argv[0]); + return(-1); + } + + /* Init libxml */ + xmlInitParser(); + LIBXML_TEST_VERSION + + /* Do the main job */ + if (example4(argv[1], BAD_CAST argv[2], BAD_CAST argv[3])) { + usage(argv[0]); + return(-1); + } + + /* Shutdown libxml */ + xmlCleanupParser(); + + /* + * this is to debug memory for regression tests + */ + xmlMemoryDump(); + return 0; +} + +/** + * usage: + * @name: the program name. + * + * Prints usage information. + */ +static void +usage(const char *name) { + assert(name); + + fprintf(stderr, "Usage: %s \n", name); +} + +/** + * example4: + * @filename: the input XML filename. + * @xpathExpr: the xpath expression for evaluation. + * @value: the new node content. + * + * Parses input XML file, evaluates XPath expression and update the nodes + * then print the result. + * + * Returns 0 on success and a negative value otherwise. + */ +static int +example4(const char* filename, const xmlChar* xpathExpr, const xmlChar* value) { + xmlDocPtr doc; + xmlXPathContextPtr xpathCtx; + xmlXPathObjectPtr xpathObj; + + assert(filename); + assert(xpathExpr); + assert(value); + + /* Load XML document */ + doc = xmlParseFile(filename); + if (doc == NULL) { + fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); + return(-1); + } + + /* Create xpath evaluation context */ + xpathCtx = xmlXPathNewContext(doc); + if(xpathCtx == NULL) { + fprintf(stderr,"Error: unable to create new XPath context\n"); + xmlFreeDoc(doc); + return(-1); + } + + /* Evaluate xpath expression */ + xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); + if(xpathObj == NULL) { + fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr); + xmlXPathFreeContext(xpathCtx); + xmlFreeDoc(doc); + return(-1); + } + + /* update selected nodes */ + update_xpath_nodes(xpathObj->nodesetval, value); + + + /* Cleanup of XPath data */ + xmlXPathFreeObject(xpathObj); + xmlXPathFreeContext(xpathCtx); + + /* dump the resulting document */ + xmlDocDump(stdout, doc); + + + /* free the document */ + xmlFreeDoc(doc); + + return(0); +} + +/** + * update_xpath_nodes: + * @nodes: the nodes set. + * @value: the new value for the node(s) + * + * Prints the @nodes content to @output. + */ +static void +update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar* value) { + int size; + int i; + + assert(value); + size = (nodes) ? nodes->nodeNr : 0; + + /* + * NOTE: the nodes are processed in reverse order, i.e. reverse document + * order because xmlNodeSetContent can actually free up descendant + * of the node and such nodes may have been selected too ! Handling + * in reverse order ensure that descendant are accessed first, before + * they get removed. Mixing XPath and modifications on a tree must be + * done carefully ! + */ + for(i = size - 1; i >= 0; i--) { + assert(nodes->nodeTab[i]); + + xmlNodeSetContent(nodes->nodeTab[i], value); + /* + * All the elements returned by an XPath query are pointers to + * elements from the tree *except* namespace nodes where the XPath + * semantic is different from the implementation in libxml2 tree. + * As a result when a returned node set is freed when + * xmlXPathFreeObject() is called, that routine must check the + * element type. But node from the returned set may have been removed + * by xmlNodeSetContent() resulting in access to freed data. + * This can be exercised by running + * valgrind xpath2 test3.xml '//discarded' discarded + * There is 2 ways around it: + * - make a copy of the pointers to the nodes from the result set + * then call xmlXPathFreeObject() and then modify the nodes + * or + * - remove the reference to the modified nodes from the node set + * as they are processed, if they are not namespace nodes. + */ + if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL) + nodes->nodeTab[i] = NULL; + } +} + +#else +int main(void) { + fprintf(stderr, "XPath support not compiled in\n"); + exit(1); +} +#endif diff --git a/libxml2-2.9.10/doc/examples/xpath2.res b/libxml2-2.9.10/doc/examples/xpath2.res new file mode 100644 index 0000000..4e89699 --- /dev/null +++ b/libxml2-2.9.10/doc/examples/xpath2.res @@ -0,0 +1,30 @@ + + + + discarded + + This text node must be discarded + discarded + + content1 + + content2 + too + content3 + + content4 + + content5 + content6 + + This text node must be discarded + discarded + This text node must be discarded + + This text node must be discarded + + This text node must be discarded + discarded + This text node must be discarded + + -- cgit v1.2.3