Kitxuuu commited on
Commit
d40595c
·
verified ·
1 Parent(s): 0f9037c

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/Dockerfile +32 -0
  2. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/Test-Msvc.ps1 +49 -0
  3. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/downstream-nokogiri.sh +14 -0
  4. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/downstream-perl.sh +18 -0
  5. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/llvm-symbolizer +9 -0
  6. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/setup_mingw.sh +17 -0
  7. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test.sh +8 -0
  8. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test_cmake.sh +18 -0
  9. local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test_meson.sh +18 -0
  10. local-test-libxml2-delta-01/afc-libxml2/doc/Makefile.am +28 -0
  11. local-test-libxml2-delta-01/afc-libxml2/doc/apibuild.py +1928 -0
  12. local-test-libxml2-delta-01/afc-libxml2/doc/libxml2-api.xml +0 -0
  13. local-test-libxml2-delta-01/afc-libxml2/doc/meson.build +12 -0
  14. local-test-libxml2-delta-01/afc-libxml2/doc/xml2-config.1 +32 -0
  15. local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.1 +356 -0
  16. local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.html +144 -0
  17. local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.xml +475 -0
  18. local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.1 +642 -0
  19. local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.html +167 -0
  20. local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.xml +1045 -0
  21. local-test-libxml2-delta-01/afc-libxml2/example/.gitignore +16 -0
  22. local-test-libxml2-delta-01/afc-libxml2/example/Makefile.am +44 -0
  23. local-test-libxml2-delta-01/afc-libxml2/example/gjobread.c +301 -0
  24. local-test-libxml2-delta-01/afc-libxml2/example/gjobs.xml +57 -0
  25. local-test-libxml2-delta-01/afc-libxml2/example/icu.c +241 -0
  26. local-test-libxml2-delta-01/afc-libxml2/example/io1.c +159 -0
  27. local-test-libxml2-delta-01/afc-libxml2/example/io2.c +58 -0
  28. local-test-libxml2-delta-01/afc-libxml2/example/meson.build +27 -0
  29. local-test-libxml2-delta-01/afc-libxml2/example/parse1.c +48 -0
  30. local-test-libxml2-delta-01/afc-libxml2/example/parse2.c +64 -0
  31. local-test-libxml2-delta-01/afc-libxml2/example/parse3.c +52 -0
  32. local-test-libxml2-delta-01/afc-libxml2/example/parse4.c +135 -0
  33. local-test-libxml2-delta-01/afc-libxml2/example/reader1.c +99 -0
  34. local-test-libxml2-delta-01/afc-libxml2/example/reader2.c +115 -0
  35. local-test-libxml2-delta-01/afc-libxml2/example/reader3.c +111 -0
  36. local-test-libxml2-delta-01/afc-libxml2/example/reader4.c +114 -0
  37. local-test-libxml2-delta-01/afc-libxml2/example/test1.xml +1 -0
  38. local-test-libxml2-delta-01/afc-libxml2/example/test2.xml +13 -0
  39. local-test-libxml2-delta-01/afc-libxml2/example/test3.xml +39 -0
  40. local-test-libxml2-delta-01/afc-libxml2/example/testWriter.c +1068 -0
  41. local-test-libxml2-delta-01/afc-libxml2/example/tree1.c +80 -0
  42. local-test-libxml2-delta-01/afc-libxml2/example/tree2.c +107 -0
  43. local-test-libxml2-delta-01/afc-libxml2/example/xpath1.c +243 -0
  44. local-test-libxml2-delta-01/afc-libxml2/example/xpath2.c +183 -0
  45. local-test-libxml2-delta-01/afc-libxml2/include/Makefile.am +5 -0
  46. local-test-libxml2-delta-01/afc-libxml2/include/meson.build +2 -0
  47. local-test-libxml2-delta-01/afc-libxml2/include/wsockcompat.h +49 -0
  48. local-test-libxml2-delta-01/afc-libxml2/m4/ax_append_flag.m4 +50 -0
  49. local-test-libxml2-delta-01/afc-libxml2/m4/ax_append_link_flags.m4 +44 -0
  50. local-test-libxml2-delta-01/afc-libxml2/m4/ax_check_link_flag.m4 +53 -0
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The image is also used for libxslt, that's why we need git and
2
+ # libgcrypt-dev.
3
+
4
+ FROM ubuntu:24.04
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ RUN apt-get update && \
7
+ apt-get upgrade -y && \
8
+ apt-get install -y --no-install-recommends \
9
+ curl git ca-certificates \
10
+ autoconf automake libtool pkg-config \
11
+ make gcc clang llvm libclang-rt-dev \
12
+ zlib1g-dev liblzma-dev libgcrypt-dev \
13
+ python3-dev \
14
+ cmake meson
15
+ WORKDIR /tests
16
+ RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
17
+
18
+ # XML::LibXML uses Alien::Libxml2 which has a huge dependency chain.
19
+ # We try to install most dependencies with apt. We also require
20
+ # libxml2-dev to stop Alien::Libxml2 from downloading and building
21
+ # libxml2 on its own.
22
+ RUN apt-get install -y --no-install-recommends \
23
+ libperl-dev libxml2-dev cpanminus \
24
+ libalien-build-perl \
25
+ libio-socket-ssl-perl \
26
+ libsort-versions-perl \
27
+ liburi-perl \
28
+ libxml-namespacesupport-perl \
29
+ libxml-sax-perl \
30
+ libyaml-perl
31
+ RUN cpanm -n Alien::Libxml2
32
+ RUN apt-get remove -y libxml2-dev
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/Test-Msvc.ps1 ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
2
+
3
+ if (-not (Test-Path cmake-$Env:CMAKE_VERSION-win64-x64)) {
4
+ Invoke-WebRequest `
5
+ -Uri http://github.com/Kitware/CMake/releases/download/v$Env:CMAKE_VERSION/cmake-$Env:CMAKE_VERSION-win64-x64.zip `
6
+ -OutFile cmake-$Env:CMAKE_VERSION-win64-x64.zip
7
+ Expand-Archive cmake-$Env:CMAKE_VERSION-win64-x64.zip -DestinationPath .
8
+ }
9
+ $Env:Path="$Env:CI_PROJECT_DIR\cmake-$Env:CMAKE_VERSION-win64-x64\bin;$Env:Path"
10
+
11
+ if (-not (Test-Path 7za.exe)) {
12
+ Invoke-WebRequest `
13
+ -Uri https://www.7-zip.org/a/7z1900-extra.7z `
14
+ -OutFile 7z1900-extra.7z
15
+ cmake -E tar xf 7z1900-extra.7z 7za.exe
16
+ }
17
+
18
+ if (-not (Test-Path libxml2-build/xmlconf)) {
19
+ Invoke-WebRequest `
20
+ -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz `
21
+ -OutFile xmlts20080827.tar.gz ;
22
+ .\7za.exe x xmlts20080827.tar.gz -olibxml2-build
23
+ }
24
+
25
+ cmake `
26
+ -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" `
27
+ -DCMAKE_INSTALL_PREFIX=libxml2-install `
28
+ -DLIBXML2_WITH_ICONV=OFF `
29
+ -DLIBXML2_WITH_LZMA=OFF `
30
+ -DLIBXML2_WITH_PYTHON=OFF `
31
+ -DLIBXML2_WITH_ZLIB=OFF `
32
+ -S . -B libxml2-build
33
+ cmake --build libxml2-build --config Debug --target install
34
+ cmake --build libxml2-build --config Release --target install
35
+ New-Item -ItemType Directory libxml2-install\share\libxml2
36
+ Copy-Item Copyright libxml2-install\share\libxml2
37
+
38
+ cd libxml2-build
39
+ ctest -C Debug -VV
40
+ if ($LastExitCode -ne 0) {
41
+ throw "ctest failed"
42
+ }
43
+ ctest -C Release -VV
44
+ if ($LastExitCode -ne 0) {
45
+ throw "ctest failed"
46
+ }
47
+ cd ..
48
+
49
+ .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/downstream-nokogiri.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ export LIBXML_DIR=$(pwd)
6
+ export MAKEFLAGS=-j$(nproc)
7
+ export NOCONFIGURE=1
8
+ ./autogen.sh
9
+
10
+ git clone https://github.com/sparklemotion/nokogiri
11
+ cd nokogiri
12
+ bundle install
13
+ bundle exec rake compile -- --with-xml2-source-dir=${LIBXML_DIR}
14
+ bundle exec rake test
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/downstream-perl.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ sh autogen.sh --without-python
6
+ make -j$(nproc)
7
+
8
+ srcdir=$(pwd)
9
+ incdir=$srcdir/include
10
+ libdir=$srcdir/.libs
11
+
12
+ curl -L https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0210.tar.gz |tar xz
13
+ cd XML-LibXML-2.0210
14
+
15
+ perl Makefile.PL INC="-I$incdir" LIBS="-L$libdir -lxml2"
16
+ make
17
+ # Known to fail
18
+ LD_LIBRARY_PATH=$libdir make test || true
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/llvm-symbolizer ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ # Newer versions of llvm-symbolizer require libxml2 themselves. Running
4
+ # a test program with LD_LIBRARY_PATH set to .libs makes llvm-symbolizer
5
+ # pick up the tested development version of libxml2 which breaks
6
+ # completely if the build is instrumented with ASan. This wrapper script
7
+ # invokes llvm-symbolizer with an empty LD_LIBRARY_PATH.
8
+
9
+ LD_LIBRARY_PATH='' llvm-symbolizer "$@"
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/setup_mingw.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ pacman --noconfirm -Syu
4
+
5
+ prefix=
6
+ if [ -n "$MINGW_PACKAGE_PREFIX" ]; then
7
+ prefix="${MINGW_PACKAGE_PREFIX}-"
8
+ fi
9
+ for module in libiconv python xz zlib "$@"; do
10
+ pacman --noconfirm -S --needed ${prefix}$module
11
+ done
12
+
13
+ if [ ! -e libxml2-build/xmlconf ]; then
14
+ mkdir -p libxml2-build
15
+ wget https://www.w3.org/XML/Test/xmlts20080827.tar -O - |
16
+ tar -x -C libxml2-build
17
+ fi
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ cd libxml2-build
6
+ sh ../autogen.sh $BASE_CONFIG $CONFIG || cat config.log
7
+ make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
8
+ make CFLAGS="$CFLAGS -Werror" check
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test_cmake.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ CFLAGS="-Werror $CFLAGS" \
6
+ cmake "$@" \
7
+ -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
8
+ -DCMAKE_INSTALL_PREFIX=libxml2-install \
9
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
10
+ -S . -B libxml2-build
11
+ cmake --build libxml2-build --target install
12
+
13
+ (cd libxml2-build && ctest -VV)
14
+
15
+ mkdir -p libxml2-install/share/libxml2
16
+ cp Copyright libxml2-install/share/libxml2
17
+ (cd libxml2-install &&
18
+ tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz *)
local-test-libxml2-delta-01/afc-libxml2/.gitlab-ci/test_meson.sh ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ # compile with the following warnings:
6
+ # --warnlevel 3 : passes to the compiler -Wall -Wextra -Wpedantic
7
+ # --werror : passes to the compiler -Werror
8
+ # --default-library : can be 'shared', 'static' or 'both'
9
+ meson setup \
10
+ --warnlevel 3 \
11
+ --werror \
12
+ --buildtype=debugoptimized \
13
+ --default-library shared \
14
+ -Dlegacy=enabled \
15
+ builddir
16
+
17
+ ninja -C builddir test
18
+
local-test-libxml2-delta-01/afc-libxml2/doc/Makefile.am ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Process this file with automake to produce Makefile.in
2
+ SUBDIRS = . devhelp
3
+
4
+ nobase_dist_doc_DATA = \
5
+ xmlcatalog.html \
6
+ xmllint.html
7
+
8
+ dist_man_MANS = xml2-config.1 xmllint.1 xmlcatalog.1
9
+
10
+ EXTRA_DIST = \
11
+ apibuild.py \
12
+ libxml2-api.xml \
13
+ xmlcatalog.xml \
14
+ xmllint.xml \
15
+ meson.build
16
+
17
+ DOCBOOK_HTML = http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
18
+
19
+ rebuild:
20
+ cd $(srcdir) && ./apibuild.py
21
+ cd $(srcdir) && $(XSLTPROC) --nonet xmllint.xml
22
+ cd $(srcdir) && $(XSLTPROC) --nonet -o xmllint.html $(DOCBOOK_HTML) xmllint.xml
23
+ cd $(srcdir) && $(XSLTPROC) --nonet xmlcatalog.xml
24
+ cd $(srcdir) && $(XSLTPROC) --nonet -o xmlcatalog.html $(DOCBOOK_HTML) xmlcatalog.xml
25
+ cd devhelp && $(MAKE) rebuild
26
+ cd .. && $(MAKE) rebuild_testapi
27
+
28
+ .PHONY: rebuild
local-test-libxml2-delta-01/afc-libxml2/doc/apibuild.py ADDED
@@ -0,0 +1,1928 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ #
3
+ # This is the API builder, it parses the C sources and build the
4
+ # API formal description in XML.
5
+ #
6
+ # See Copyright for the status of this software.
7
+ #
8
+ # daniel@veillard.com
9
+ #
10
+ import os, sys
11
+ import string
12
+ import glob
13
+
14
+ debug=0
15
+ #debugsym='ignorableWhitespaceSAXFunc'
16
+ debugsym=None
17
+
18
+ #
19
+ # C parser analysis code
20
+ #
21
+ ignored_files = {
22
+ "config.h": "generated portability layer",
23
+ "libxml.h": "internal only",
24
+ "testModule.c": "test tool",
25
+ "testapi.c": "generated regression tests",
26
+ "runtest.c": "regression tests program",
27
+ "runsuite.c": "regression tests program",
28
+ "tst.c": "not part of the library",
29
+ "test.c": "not part of the library",
30
+ "testdso.c": "test for dynamid shared libraries",
31
+ "testrecurse.c": "test for entities recursions",
32
+ "timsort.h": "Internal header only for xpath.c 2.9.0",
33
+ "nanoftp.h": "empty",
34
+ "SAX.h": "empty",
35
+ }
36
+
37
+ ignored_words = {
38
+ "WINAPI": (0, "Windows keyword"),
39
+ "LIBXML_DLL_IMPORT": (0, "Special macro to flag external keywords"),
40
+ "XMLPUBVAR": (0, "Special macro for extern vars for win32"),
41
+ "XSLTPUBVAR": (0, "Special macro for extern vars for win32"),
42
+ "EXSLTPUBVAR": (0, "Special macro for extern vars for win32"),
43
+ "XMLPUBFUN": (0, "Special macro for extern funcs for win32"),
44
+ "XSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
45
+ "EXSLTPUBFUN": (0, "Special macro for extern funcs for win32"),
46
+ "XSLTCALL": (0, "Special macro for win32 calls"),
47
+ "EXSLTCALL": (0, "Special macro for win32 calls"),
48
+ "__declspec": (3, "Windows keyword"),
49
+ "__stdcall": (0, "Windows keyword"),
50
+ "ATTRIBUTE_UNUSED": (0, "macro keyword"),
51
+ "ATTRIBUTE_DESTRUCTOR": (0, "macro keyword"),
52
+ "LIBEXSLT_PUBLIC": (0, "macro keyword"),
53
+ "X_IN_Y": (5, "macro function builder"),
54
+ "ATTRIBUTE_ALLOC_SIZE": (3, "macro for gcc checking extension"),
55
+ "ATTRIBUTE_PRINTF": (5, "macro for gcc printf args checking extension"),
56
+ "LIBXML_ATTR_FORMAT": (5, "macro for gcc printf args checking extension"),
57
+ "LIBXML_ATTR_ALLOC_SIZE": (3, "macro for gcc checking extension"),
58
+ "ATTRIBUTE_NO_SANITIZE": (3, "macro keyword"),
59
+ "ATTRIBUTE_NO_SANITIZE_INTEGER": (0, "macro keyword"),
60
+ "XML_DEPRECATED": (0, "macro keyword"),
61
+ "XML_DEPRECATED_MEMBER": (0, "macro keyword"),
62
+ "XML_GLOBALS_ALLOC": (0, "macro keyword"),
63
+ "XML_GLOBALS_ERROR": (0, "macro keyword"),
64
+ "XML_GLOBALS_IO": (0, "macro keyword"),
65
+ "XML_GLOBALS_PARSER": (0, "macro keyword"),
66
+ "XML_GLOBALS_TREE": (0, "macro keyword"),
67
+ "XML_THREAD_LOCAL": (0, "macro keyword"),
68
+ }
69
+
70
+ def escape(raw):
71
+ raw = raw.replace('&', '&')
72
+ raw = raw.replace('<', '&lt;')
73
+ raw = raw.replace('>', '&gt;')
74
+ raw = raw.replace("'", '&apos;')
75
+ raw = raw.replace('"', '&quot;')
76
+ return raw
77
+
78
+ class identifier:
79
+ def __init__(self, name, header=None, module=None, type=None, lineno = 0,
80
+ info=None, extra=None, conditionals = None):
81
+ self.name = name
82
+ self.header = header
83
+ self.module = module
84
+ self.type = type
85
+ self.info = info
86
+ self.extra = extra
87
+ self.lineno = lineno
88
+ self.static = 0
89
+ if conditionals == None or len(conditionals) == 0:
90
+ self.conditionals = None
91
+ else:
92
+ self.conditionals = conditionals[:]
93
+ if self.name == debugsym:
94
+ print("=> define %s : %s" % (debugsym, (module, type, info,
95
+ extra, conditionals)))
96
+
97
+ def __repr__(self):
98
+ r = "%s %s:" % (self.type, self.name)
99
+ if self.static:
100
+ r = r + " static"
101
+ if self.module != None:
102
+ r = r + " from %s" % (self.module)
103
+ if self.info != None:
104
+ r = r + " " + repr(self.info)
105
+ if self.extra != None:
106
+ r = r + " " + repr(self.extra)
107
+ if self.conditionals != None:
108
+ r = r + " " + repr(self.conditionals)
109
+ return r
110
+
111
+
112
+ def set_header(self, header):
113
+ self.header = header
114
+ def set_module(self, module):
115
+ self.module = module
116
+ def set_type(self, type):
117
+ self.type = type
118
+ def set_info(self, info):
119
+ self.info = info
120
+ def set_extra(self, extra):
121
+ self.extra = extra
122
+ def set_lineno(self, lineno):
123
+ self.lineno = lineno
124
+ def set_static(self, static):
125
+ self.static = static
126
+ def set_conditionals(self, conditionals):
127
+ if conditionals == None or len(conditionals) == 0:
128
+ self.conditionals = None
129
+ else:
130
+ self.conditionals = conditionals[:]
131
+
132
+ def get_name(self):
133
+ return self.name
134
+ def get_header(self):
135
+ return self.module
136
+ def get_module(self):
137
+ return self.module
138
+ def get_type(self):
139
+ return self.type
140
+ def get_info(self):
141
+ return self.info
142
+ def get_lineno(self):
143
+ return self.lineno
144
+ def get_extra(self):
145
+ return self.extra
146
+ def get_static(self):
147
+ return self.static
148
+ def get_conditionals(self):
149
+ return self.conditionals
150
+
151
+ def update(self, header, module, type = None, info = None, extra=None,
152
+ conditionals=None):
153
+ if self.name == debugsym:
154
+ print("=> update %s : %s" % (debugsym, (module, type, info,
155
+ extra, conditionals)))
156
+ if header != None and self.header == None:
157
+ self.set_header(module)
158
+ if module != None and (self.module == None or self.header == self.module):
159
+ self.set_module(module)
160
+ if type != None and self.type == None:
161
+ self.set_type(type)
162
+ if info != None:
163
+ self.set_info(info)
164
+ if extra != None:
165
+ self.set_extra(extra)
166
+ if conditionals != None:
167
+ self.set_conditionals(conditionals)
168
+
169
+ class index:
170
+ def __init__(self, name = "noname"):
171
+ self.name = name
172
+ self.identifiers = {}
173
+ self.functions = {}
174
+ self.variables = {}
175
+ self.includes = {}
176
+ self.structs = {}
177
+ self.enums = {}
178
+ self.typedefs = {}
179
+ self.macros = {}
180
+ self.references = {}
181
+ self.info = {}
182
+
183
+ def add_ref(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
184
+ if name[0:2] == '__':
185
+ return None
186
+ d = None
187
+ if name in self.identifiers:
188
+ d = self.identifiers[name]
189
+ d.update(header, module, type, info, extra, conditionals)
190
+ else:
191
+ d = identifier(name, header, module, type, lineno, info, extra, conditionals)
192
+ self.identifiers[name] = d
193
+
194
+ if d != None and static == 1:
195
+ d.set_static(1)
196
+
197
+ if d != None and name != None and type != None:
198
+ self.references[name] = d
199
+
200
+ if name == debugsym:
201
+ print("New ref: %s" % (d))
202
+
203
+ return d
204
+
205
+ def add(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals = None):
206
+ if name[0:2] == '__':
207
+ return None
208
+ d = None
209
+ if name in self.identifiers:
210
+ d = self.identifiers[name]
211
+ d.update(header, module, type, info, extra, conditionals)
212
+ else:
213
+ d = identifier(name, header, module, type, lineno, info, extra, conditionals)
214
+ self.identifiers[name] = d
215
+
216
+ if d != None and static == 1:
217
+ d.set_static(1)
218
+
219
+ if d != None and name != None and type != None:
220
+ if type == "function":
221
+ self.functions[name] = d
222
+ elif type == "functype":
223
+ self.functions[name] = d
224
+ elif type == "variable":
225
+ self.variables[name] = d
226
+ elif type == "include":
227
+ self.includes[name] = d
228
+ elif type == "struct":
229
+ self.structs[name] = d
230
+ elif type == "enum":
231
+ self.enums[name] = d
232
+ elif type == "typedef":
233
+ self.typedefs[name] = d
234
+ elif type == "macro":
235
+ self.macros[name] = d
236
+ else:
237
+ print("Unable to register type ", type)
238
+
239
+ if name == debugsym:
240
+ print("New symbol: %s" % (d))
241
+
242
+ return d
243
+
244
+ def merge(self, idx):
245
+ for id in list(idx.functions.keys()):
246
+ #
247
+ # macro might be used to override functions or variables
248
+ # definitions
249
+ #
250
+ if id in self.macros:
251
+ del self.macros[id]
252
+ if id in self.functions:
253
+ print("function %s from %s redeclared in %s" % (
254
+ id, self.functions[id].header, idx.functions[id].header))
255
+ else:
256
+ self.functions[id] = idx.functions[id]
257
+ self.identifiers[id] = idx.functions[id]
258
+ for id in list(idx.variables.keys()):
259
+ #
260
+ # macro might be used to override functions or variables
261
+ # definitions
262
+ #
263
+ if id in self.macros:
264
+ del self.macros[id]
265
+ if id in self.variables:
266
+ print("variable %s from %s redeclared in %s" % (
267
+ id, self.variables[id].header, idx.variables[id].header))
268
+ else:
269
+ self.variables[id] = idx.variables[id]
270
+ self.identifiers[id] = idx.variables[id]
271
+ for id in list(idx.structs.keys()):
272
+ if id in self.structs:
273
+ print("struct %s from %s redeclared in %s" % (
274
+ id, self.structs[id].header, idx.structs[id].header))
275
+ else:
276
+ self.structs[id] = idx.structs[id]
277
+ self.identifiers[id] = idx.structs[id]
278
+ for id in list(idx.typedefs.keys()):
279
+ if id in self.typedefs:
280
+ print("typedef %s from %s redeclared in %s" % (
281
+ id, self.typedefs[id].header, idx.typedefs[id].header))
282
+ else:
283
+ self.typedefs[id] = idx.typedefs[id]
284
+ self.identifiers[id] = idx.typedefs[id]
285
+ for id in list(idx.macros.keys()):
286
+ #
287
+ # macro might be used to override functions or variables
288
+ # definitions
289
+ #
290
+ if id in self.variables:
291
+ continue
292
+ if id in self.functions:
293
+ continue
294
+ if id in self.enums:
295
+ continue
296
+ if id in self.macros and id != 'XML_OP':
297
+ print("macro %s from %s redeclared in %s" % (
298
+ id, self.macros[id].header, idx.macros[id].header))
299
+ else:
300
+ self.macros[id] = idx.macros[id]
301
+ self.identifiers[id] = idx.macros[id]
302
+ for id in list(idx.enums.keys()):
303
+ if id in self.enums:
304
+ print("enum %s from %s redeclared in %s" % (
305
+ id, self.enums[id].header, idx.enums[id].header))
306
+ else:
307
+ self.enums[id] = idx.enums[id]
308
+ self.identifiers[id] = idx.enums[id]
309
+
310
+ def merge_public(self, idx):
311
+ for id in list(idx.functions.keys()):
312
+ if id in self.functions:
313
+ # check that function condition agrees with header
314
+ if idx.functions[id].conditionals != \
315
+ self.functions[id].conditionals:
316
+ print("Header condition differs from Function for %s:" \
317
+ % id)
318
+ print(" H: %s" % self.functions[id].conditionals)
319
+ print(" C: %s" % idx.functions[id].conditionals)
320
+ up = idx.functions[id]
321
+ self.functions[id].update(None, up.module, up.type, up.info, up.extra)
322
+ # else:
323
+ # print "Function %s from %s is not declared in headers" % (
324
+ # id, idx.functions[id].module)
325
+
326
+ for id in list(idx.variables.keys()):
327
+ if id in self.variables:
328
+ # check that variable condition agrees with header
329
+ # TODO: produces many false positives
330
+ #if idx.variables[id].conditionals != \
331
+ # self.variables[id].conditionals:
332
+ # print("Header condition differs from Variable for %s:" \
333
+ # % id)
334
+ # print(" H: %s" % self.variables[id].conditionals)
335
+ # print(" C: %s" % idx.variables[id].conditionals)
336
+ up = idx.variables[id]
337
+ self.variables[id].update(None, up.module, up.type, up.info, up.extra)
338
+
339
+ def analyze_dict(self, type, dict):
340
+ count = 0
341
+ public = 0
342
+ for name in list(dict.keys()):
343
+ id = dict[name]
344
+ count = count + 1
345
+ if id.static == 0:
346
+ public = public + 1
347
+ if count != public:
348
+ print(" %d %s , %d public" % (count, type, public))
349
+ elif count != 0:
350
+ print(" %d public %s" % (count, type))
351
+
352
+
353
+ def analyze(self):
354
+ self.analyze_dict("functions", self.functions)
355
+ self.analyze_dict("variables", self.variables)
356
+ self.analyze_dict("structs", self.structs)
357
+ self.analyze_dict("typedefs", self.typedefs)
358
+ self.analyze_dict("macros", self.macros)
359
+
360
+ class CLexer:
361
+ """A lexer for the C language, tokenize the input by reading and
362
+ analyzing it line by line"""
363
+ def __init__(self, input):
364
+ self.input = input
365
+ self.tokens = []
366
+ self.line = ""
367
+ self.lineno = 0
368
+
369
+ def getline(self):
370
+ line = ''
371
+ while line == '':
372
+ line = self.input.readline()
373
+ if not line:
374
+ return None
375
+ self.lineno = self.lineno + 1
376
+ line = line.lstrip()
377
+ line = line.rstrip()
378
+ if line == '':
379
+ continue
380
+ while line[-1] == '\\':
381
+ line = line[:-1]
382
+ n = self.input.readline()
383
+ self.lineno = self.lineno + 1
384
+ n = n.lstrip()
385
+ n = n.rstrip()
386
+ if not n:
387
+ break
388
+ else:
389
+ line = line + n
390
+ return line
391
+
392
+ def getlineno(self):
393
+ return self.lineno
394
+
395
+ def push(self, token):
396
+ self.tokens.insert(0, token);
397
+
398
+ def debug(self):
399
+ print("Last token: ", self.last)
400
+ print("Token queue: ", self.tokens)
401
+ print("Line %d end: " % (self.lineno), self.line)
402
+
403
+ def token(self):
404
+ while self.tokens == []:
405
+ if self.line == "":
406
+ line = self.getline()
407
+ else:
408
+ line = self.line
409
+ self.line = ""
410
+ if line == None:
411
+ return None
412
+
413
+ if line[0] == '#':
414
+ self.tokens = list(map((lambda x: ('preproc', x)),
415
+ line.split()))
416
+ break;
417
+ l = len(line)
418
+ if line[0] == '"' or line[0] == "'":
419
+ end = line[0]
420
+ line = line[1:]
421
+ found = 0
422
+ tok = ""
423
+ while found == 0:
424
+ i = 0
425
+ l = len(line)
426
+ while i < l:
427
+ if line[i] == end:
428
+ self.line = line[i+1:]
429
+ line = line[:i]
430
+ l = i
431
+ found = 1
432
+ break
433
+ if line[i] == '\\':
434
+ i = i + 1
435
+ i = i + 1
436
+ tok = tok + line
437
+ if found == 0:
438
+ line = self.getline()
439
+ if line == None:
440
+ return None
441
+ self.last = ('string', tok)
442
+ return self.last
443
+
444
+ if l >= 2 and line[0] == '/' and line[1] == '*':
445
+ line = line[2:]
446
+ found = 0
447
+ tok = ""
448
+ while found == 0:
449
+ i = 0
450
+ l = len(line)
451
+ while i < l:
452
+ if line[i] == '*' and i+1 < l and line[i+1] == '/':
453
+ self.line = line[i+2:]
454
+ line = line[:i-1]
455
+ l = i
456
+ found = 1
457
+ break
458
+ i = i + 1
459
+ if tok != "":
460
+ tok = tok + "\n"
461
+ tok = tok + line
462
+ if found == 0:
463
+ line = self.getline()
464
+ if line == None:
465
+ return None
466
+ self.last = ('comment', tok)
467
+ return self.last
468
+ if l >= 2 and line[0] == '/' and line[1] == '/':
469
+ line = line[2:]
470
+ self.last = ('comment', line)
471
+ return self.last
472
+ i = 0
473
+ while i < l:
474
+ if line[i] == '/' and i+1 < l and line[i+1] == '/':
475
+ self.line = line[i:]
476
+ line = line[:i]
477
+ break
478
+ if line[i] == '/' and i+1 < l and line[i+1] == '*':
479
+ self.line = line[i:]
480
+ line = line[:i]
481
+ break
482
+ if line[i] == '"' or line[i] == "'":
483
+ self.line = line[i:]
484
+ line = line[:i]
485
+ break
486
+ i = i + 1
487
+ l = len(line)
488
+ i = 0
489
+ while i < l:
490
+ if line[i] == ' ' or line[i] == '\t':
491
+ i = i + 1
492
+ continue
493
+ o = ord(line[i])
494
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
495
+ (o >= 48 and o <= 57):
496
+ s = i
497
+ while i < l:
498
+ o = ord(line[i])
499
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
500
+ (o >= 48 and o <= 57) or \
501
+ (" \t(){}:;,+-*/%&!|[]=><".find(line[i])) == -1:
502
+ i = i + 1
503
+ else:
504
+ break
505
+ self.tokens.append(('name', line[s:i]))
506
+ continue
507
+ if "(){}:;,[]".find(line[i]) != -1:
508
+ # if line[i] == '(' or line[i] == ')' or line[i] == '{' or \
509
+ # line[i] == '}' or line[i] == ':' or line[i] == ';' or \
510
+ # line[i] == ',' or line[i] == '[' or line[i] == ']':
511
+ self.tokens.append(('sep', line[i]))
512
+ i = i + 1
513
+ continue
514
+ if "+-*><=/%&!|.".find(line[i]) != -1:
515
+ # if line[i] == '+' or line[i] == '-' or line[i] == '*' or \
516
+ # line[i] == '>' or line[i] == '<' or line[i] == '=' or \
517
+ # line[i] == '/' or line[i] == '%' or line[i] == '&' or \
518
+ # line[i] == '!' or line[i] == '|' or line[i] == '.':
519
+ if line[i] == '.' and i + 2 < l and \
520
+ line[i+1] == '.' and line[i+2] == '.':
521
+ self.tokens.append(('name', '...'))
522
+ i = i + 3
523
+ continue
524
+
525
+ j = i + 1
526
+ if j < l and (
527
+ "+-*><=/%&!|".find(line[j]) != -1):
528
+ # line[j] == '+' or line[j] == '-' or line[j] == '*' or \
529
+ # line[j] == '>' or line[j] == '<' or line[j] == '=' or \
530
+ # line[j] == '/' or line[j] == '%' or line[j] == '&' or \
531
+ # line[j] == '!' or line[j] == '|'):
532
+ self.tokens.append(('op', line[i:j+1]))
533
+ i = j + 1
534
+ else:
535
+ self.tokens.append(('op', line[i]))
536
+ i = i + 1
537
+ continue
538
+ s = i
539
+ while i < l:
540
+ o = ord(line[i])
541
+ if (o >= 97 and o <= 122) or (o >= 65 and o <= 90) or \
542
+ (o >= 48 and o <= 57) or (
543
+ " \t(){}:;,+-*/%&!|[]=><".find(line[i]) == -1):
544
+ # line[i] != ' ' and line[i] != '\t' and
545
+ # line[i] != '(' and line[i] != ')' and
546
+ # line[i] != '{' and line[i] != '}' and
547
+ # line[i] != ':' and line[i] != ';' and
548
+ # line[i] != ',' and line[i] != '+' and
549
+ # line[i] != '-' and line[i] != '*' and
550
+ # line[i] != '/' and line[i] != '%' and
551
+ # line[i] != '&' and line[i] != '!' and
552
+ # line[i] != '|' and line[i] != '[' and
553
+ # line[i] != ']' and line[i] != '=' and
554
+ # line[i] != '*' and line[i] != '>' and
555
+ # line[i] != '<'):
556
+ i = i + 1
557
+ else:
558
+ break
559
+ self.tokens.append(('name', line[s:i]))
560
+
561
+ tok = self.tokens[0]
562
+ self.tokens = self.tokens[1:]
563
+ self.last = tok
564
+ return tok
565
+
566
+ class CParser:
567
+ """The C module parser"""
568
+ def __init__(self, filename, idx = None):
569
+ self.filename = filename
570
+ if len(filename) > 2 and filename[-2:] == '.h':
571
+ self.is_header = 1
572
+ else:
573
+ self.is_header = 0
574
+ self.input = open(filename)
575
+ self.lexer = CLexer(self.input)
576
+ if idx == None:
577
+ self.index = index()
578
+ else:
579
+ self.index = idx
580
+ self.top_comment = ""
581
+ self.last_comment = ""
582
+ self.comment = None
583
+ self.collect_ref = 0
584
+ self.doc_disable = 0
585
+ self.conditionals = []
586
+ self.defines = []
587
+
588
+ def collect_references(self):
589
+ self.collect_ref = 1
590
+
591
+ def disable(self):
592
+ self.doc_disable = 1
593
+
594
+ def enable(self):
595
+ self.doc_disable = 0
596
+
597
+ def lineno(self):
598
+ return self.lexer.getlineno()
599
+
600
+ def index_add(self, name, module, static, type, info=None, extra = None):
601
+ if self.doc_disable:
602
+ return
603
+ if self.is_header == 1:
604
+ self.index.add(name, module, module, static, type, self.lineno(),
605
+ info, extra, self.conditionals)
606
+ else:
607
+ self.index.add(name, None, module, static, type, self.lineno(),
608
+ info, extra, self.conditionals)
609
+
610
+ def index_add_ref(self, name, module, static, type, info=None,
611
+ extra = None):
612
+ if self.is_header == 1:
613
+ self.index.add_ref(name, module, module, static, type,
614
+ self.lineno(), info, extra, self.conditionals)
615
+ else:
616
+ self.index.add_ref(name, None, module, static, type, self.lineno(),
617
+ info, extra, self.conditionals)
618
+
619
+ def warning(self, msg):
620
+ if self.doc_disable:
621
+ return
622
+ print(msg)
623
+
624
+ def error(self, msg, token=-1):
625
+ if self.doc_disable:
626
+ return
627
+
628
+ print("Parse Error: " + msg)
629
+ if token != -1:
630
+ print("Got token ", token)
631
+ self.lexer.debug()
632
+ sys.exit(1)
633
+
634
+ def debug(self, msg, token=-1):
635
+ print("Debug: " + msg)
636
+ if token != -1:
637
+ print("Got token ", token)
638
+ self.lexer.debug()
639
+
640
+ def parseTopComment(self, comment):
641
+ res = {}
642
+ lines = comment.split("\n")
643
+ item = None
644
+ for line in lines:
645
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
646
+ line = line[1:]
647
+ while line != "" and line[0] == '*':
648
+ line = line[1:]
649
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
650
+ line = line[1:]
651
+ try:
652
+ (it, line) = line.split(":", 1)
653
+ item = it
654
+ while line != "" and (line[0] == ' ' or line[0] == '\t'):
655
+ line = line[1:]
656
+ if item in res:
657
+ res[item] = res[item] + " " + line
658
+ else:
659
+ res[item] = line
660
+ except:
661
+ if item != None:
662
+ if item in res:
663
+ res[item] = res[item] + " " + line
664
+ else:
665
+ res[item] = line
666
+ self.index.info = res
667
+
668
+ def parseComment(self, token):
669
+ if self.top_comment == "":
670
+ self.top_comment = token[1]
671
+ if self.comment == None or token[1][0] == '*':
672
+ self.comment = token[1];
673
+ else:
674
+ self.comment = self.comment + token[1]
675
+ token = self.lexer.token()
676
+
677
+ if self.comment.find("DOC_DISABLE") != -1:
678
+ self.disable()
679
+
680
+ if self.comment.find("DOC_ENABLE") != -1:
681
+ self.enable()
682
+
683
+ return token
684
+
685
+ #
686
+ # Parse a simple comment block for typedefs or global variables
687
+ #
688
+ def parseSimpleComment(self, name, quiet = False):
689
+ if name[0:2] == '__':
690
+ quiet = 1
691
+
692
+ args = []
693
+ desc = ""
694
+
695
+ if self.comment == None:
696
+ if not quiet:
697
+ self.warning("Missing comment for %s" % (name))
698
+ return(None)
699
+ if self.comment[0] != '*':
700
+ if not quiet:
701
+ self.warning("Missing * in comment for %s" % (name))
702
+ return(None)
703
+ lines = self.comment.split('\n')
704
+ if lines[0] == '*':
705
+ del lines[0]
706
+ if lines[0] != "* %s:" % (name):
707
+ if not quiet:
708
+ self.warning("Misformatted comment for %s" % (name))
709
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
710
+ return(None)
711
+ del lines[0]
712
+ while len(lines) > 0 and lines[0] == '*':
713
+ del lines[0]
714
+ desc = ""
715
+ while len(lines) > 0:
716
+ l = lines[0]
717
+ while len(l) > 0 and l[0] == '*':
718
+ l = l[1:]
719
+ l = l.strip()
720
+ desc = desc + " " + l
721
+ del lines[0]
722
+
723
+ desc = desc.strip()
724
+
725
+ if quiet == 0:
726
+ if desc == "":
727
+ self.warning("Comment for %s lacks description" % (name))
728
+
729
+ return(desc)
730
+ #
731
+ # Parse a comment block associate to a macro
732
+ #
733
+ def parseMacroComment(self, name, quiet = 0):
734
+ if name[0:2] == '__':
735
+ quiet = 1
736
+
737
+ args = []
738
+ desc = ""
739
+
740
+ if self.comment == None:
741
+ if not quiet:
742
+ self.warning("Missing comment for macro %s" % (name))
743
+ return((args, desc))
744
+ if self.comment[0] != '*':
745
+ if not quiet:
746
+ self.warning("Missing * in macro comment for %s" % (name))
747
+ return((args, desc))
748
+ lines = self.comment.split('\n')
749
+ if lines[0] == '*':
750
+ del lines[0]
751
+ if lines[0] != "* %s:" % (name):
752
+ if not quiet:
753
+ self.warning("Misformatted macro comment for %s" % (name))
754
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
755
+ return((args, desc))
756
+ del lines[0]
757
+ while lines[0] == '*':
758
+ del lines[0]
759
+ while len(lines) > 0 and lines[0][0:3] == '* @':
760
+ l = lines[0][3:]
761
+ try:
762
+ (arg, desc) = l.split(':', 1)
763
+ desc=desc.strip()
764
+ arg=arg.strip()
765
+ except:
766
+ if not quiet:
767
+ self.warning("Misformatted macro comment for %s" % (name))
768
+ self.warning(" problem with '%s'" % (lines[0]))
769
+ del lines[0]
770
+ continue
771
+ del lines[0]
772
+ l = lines[0].strip()
773
+ while len(l) > 2 and l[0:3] != '* @':
774
+ while l[0] == '*':
775
+ l = l[1:]
776
+ desc = desc + ' ' + l.strip()
777
+ del lines[0]
778
+ if len(lines) == 0:
779
+ break
780
+ l = lines[0]
781
+ args.append((arg, desc))
782
+ while len(lines) > 0 and lines[0] == '*':
783
+ del lines[0]
784
+ desc = ""
785
+ while len(lines) > 0:
786
+ l = lines[0]
787
+ while len(l) > 0 and l[0] == '*':
788
+ l = l[1:]
789
+ l = l.strip()
790
+ desc = desc + " " + l
791
+ del lines[0]
792
+
793
+ desc = desc.strip()
794
+
795
+ if quiet == 0:
796
+ if desc == "":
797
+ self.warning("Macro comment for %s lack description of the macro" % (name))
798
+
799
+ return((args, desc))
800
+
801
+ #
802
+ # Parse a comment block and merge the information found in the
803
+ # parameters descriptions, finally returns a block as complete
804
+ # as possible
805
+ #
806
+ def mergeFunctionComment(self, name, description, quiet = 0):
807
+ if name == 'main':
808
+ quiet = 1
809
+ if name[0:2] == '__':
810
+ quiet = 1
811
+
812
+ (ret, args) = description
813
+ desc = ""
814
+ retdesc = ""
815
+
816
+ if self.comment == None:
817
+ if not quiet:
818
+ self.warning("Missing comment for function %s" % (name))
819
+ return(((ret[0], retdesc), args, desc))
820
+ if self.comment[0] != '*':
821
+ if not quiet:
822
+ self.warning("Missing * in function comment for %s" % (name))
823
+ return(((ret[0], retdesc), args, desc))
824
+ lines = self.comment.split('\n')
825
+ if lines[0] == '*':
826
+ del lines[0]
827
+ if lines[0] != "* %s:" % (name):
828
+ if not quiet:
829
+ self.warning("Misformatted function comment for %s" % (name))
830
+ self.warning(" Expecting '* %s:' got '%s'" % (name, lines[0]))
831
+ return(((ret[0], retdesc), args, desc))
832
+ del lines[0]
833
+ while lines[0] == '*':
834
+ del lines[0]
835
+ nbargs = len(args)
836
+ while len(lines) > 0 and lines[0][0:3] == '* @':
837
+ l = lines[0][3:]
838
+ try:
839
+ (arg, desc) = l.split(':', 1)
840
+ desc=desc.strip()
841
+ arg=arg.strip()
842
+ except:
843
+ if not quiet:
844
+ self.warning("Misformatted function comment for %s" % (name))
845
+ self.warning(" problem with '%s'" % (lines[0]))
846
+ del lines[0]
847
+ continue
848
+ del lines[0]
849
+ l = lines[0].strip()
850
+ while len(l) > 2 and l[0:3] != '* @':
851
+ while l[0] == '*':
852
+ l = l[1:]
853
+ desc = desc + ' ' + l.strip()
854
+ del lines[0]
855
+ if len(lines) == 0:
856
+ break
857
+ l = lines[0]
858
+ i = 0
859
+ while i < nbargs:
860
+ if args[i][1] == arg:
861
+ args[i] = (args[i][0], arg, desc)
862
+ break;
863
+ i = i + 1
864
+ if i >= nbargs:
865
+ if not quiet:
866
+ self.warning("Unable to find arg %s from function comment for %s" % (
867
+ arg, name))
868
+ while len(lines) > 0 and lines[0] == '*':
869
+ del lines[0]
870
+ desc = ""
871
+ while len(lines) > 0:
872
+ l = lines[0]
873
+ while len(l) > 0 and l[0] == '*':
874
+ l = l[1:]
875
+ l = l.strip()
876
+ if len(l) >= 6 and l[0:6] == "return" or l[0:6] == "Return":
877
+ try:
878
+ l = l.split(' ', 1)[1]
879
+ except:
880
+ l = ""
881
+ retdesc = l.strip()
882
+ del lines[0]
883
+ while len(lines) > 0:
884
+ l = lines[0]
885
+ while len(l) > 0 and l[0] == '*':
886
+ l = l[1:]
887
+ l = l.strip()
888
+ retdesc = retdesc + " " + l
889
+ del lines[0]
890
+ else:
891
+ desc = desc + " " + l
892
+ del lines[0]
893
+
894
+ retdesc = retdesc.strip()
895
+ desc = desc.strip()
896
+
897
+ if quiet == 0:
898
+ #
899
+ # report missing comments
900
+ #
901
+ i = 0
902
+ while i < nbargs:
903
+ if args[i][2] == None and args[i][0] != "void" and \
904
+ ((args[i][1] != None) or (args[i][1] == '')):
905
+ self.warning("Function comment for %s lacks description of arg %s" % (name, args[i][1]))
906
+ i = i + 1
907
+ if retdesc == "" and ret[0] != "void":
908
+ self.warning("Function comment for %s lacks description of return value" % (name))
909
+ if desc == "" and retdesc == "":
910
+ self.warning("Function comment for %s lacks description of the function" % (name))
911
+
912
+ return(((ret[0], retdesc), args, desc))
913
+
914
+ def parsePreproc(self, token):
915
+ if debug:
916
+ print("=> preproc ", token, self.lexer.tokens)
917
+ name = token[1]
918
+ if name == "#include":
919
+ token = self.lexer.token()
920
+ if token == None:
921
+ return None
922
+ if token[0] == 'preproc':
923
+ self.index_add(token[1], self.filename, not self.is_header,
924
+ "include")
925
+ return self.lexer.token()
926
+ return token
927
+ if name == "#define":
928
+ token = self.lexer.token()
929
+ if token == None:
930
+ return None
931
+ if token[0] == 'preproc':
932
+ # TODO macros with arguments
933
+ name = token[1]
934
+ lst = []
935
+ token = self.lexer.token()
936
+ while token != None and token[0] == 'preproc' and \
937
+ token[1][0] != '#':
938
+ lst.append(token[1])
939
+ token = self.lexer.token()
940
+ try:
941
+ name = name.split('(') [0]
942
+ except:
943
+ pass
944
+ info = self.parseMacroComment(name, True)
945
+ self.index_add(name, self.filename, not self.is_header,
946
+ "macro", info)
947
+ return token
948
+
949
+ #
950
+ # Processing of conditionals modified by Bill 1/1/05
951
+ #
952
+ # We process conditionals (i.e. tokens from #ifdef, #ifndef,
953
+ # #if, #else and #endif) for headers and mainline code,
954
+ # store the ones from the header in libxml2-api.xml, and later
955
+ # (in the routine merge_public) verify that the two (header and
956
+ # mainline code) agree.
957
+ #
958
+ # There is a small problem with processing the headers. Some of
959
+ # the variables are not concerned with enabling / disabling of
960
+ # library functions (e.g. '__XML_PARSER_H__'), and we don't want
961
+ # them to be included in libxml2-api.xml, or involved in
962
+ # the check between the header and the mainline code. To
963
+ # accomplish this, we ignore any conditional which doesn't include
964
+ # the string 'ENABLED'
965
+ #
966
+ if name == "#ifdef":
967
+ apstr = self.lexer.tokens[0][1]
968
+ try:
969
+ self.defines.append(apstr)
970
+ if apstr.find('ENABLED') != -1:
971
+ self.conditionals.append("defined(%s)" % apstr)
972
+ except:
973
+ pass
974
+ elif name == "#ifndef":
975
+ apstr = self.lexer.tokens[0][1]
976
+ try:
977
+ self.defines.append(apstr)
978
+ if apstr.find('ENABLED') != -1:
979
+ self.conditionals.append("!defined(%s)" % apstr)
980
+ except:
981
+ pass
982
+ elif name == "#if":
983
+ apstr = ""
984
+ for tok in self.lexer.tokens:
985
+ if apstr != "":
986
+ apstr = apstr + " "
987
+ apstr = apstr + tok[1]
988
+ try:
989
+ self.defines.append(apstr)
990
+ if apstr.find('ENABLED') != -1:
991
+ self.conditionals.append(apstr)
992
+ except:
993
+ pass
994
+ elif name == "#else":
995
+ if self.conditionals != [] and \
996
+ self.defines[-1].find('ENABLED') != -1:
997
+ self.conditionals[-1] = "!(%s)" % self.conditionals[-1]
998
+ elif name == "#endif":
999
+ if self.conditionals != [] and \
1000
+ self.defines[-1].find('ENABLED') != -1:
1001
+ self.conditionals = self.conditionals[:-1]
1002
+ self.defines = self.defines[:-1]
1003
+ token = self.lexer.token()
1004
+ while token != None and token[0] == 'preproc' and \
1005
+ token[1][0] != '#':
1006
+ token = self.lexer.token()
1007
+ return token
1008
+
1009
+ #
1010
+ # token acquisition on top of the lexer, it handle internally
1011
+ # preprocessor and comments since they are logically not part of
1012
+ # the program structure.
1013
+ #
1014
+ def token(self):
1015
+ global ignored_words
1016
+
1017
+ token = self.lexer.token()
1018
+ while token != None:
1019
+ if token[0] == 'comment':
1020
+ token = self.parseComment(token)
1021
+ continue
1022
+ elif token[0] == 'preproc':
1023
+ token = self.parsePreproc(token)
1024
+ continue
1025
+ elif token[0] == "name" and token[1] == "__const":
1026
+ token = ("name", "const")
1027
+ return token
1028
+ elif token[0] == "name" and token[1] == "__attribute":
1029
+ token = self.lexer.token()
1030
+ while token != None and token[1] != ";":
1031
+ token = self.lexer.token()
1032
+ return token
1033
+ elif token[0] == "name" and token[1] in ignored_words:
1034
+ (n, info) = ignored_words[token[1]]
1035
+ i = 0
1036
+ while i < n:
1037
+ token = self.lexer.token()
1038
+ i = i + 1
1039
+ token = self.lexer.token()
1040
+ continue
1041
+ else:
1042
+ if debug:
1043
+ print("=> ", token)
1044
+ return token
1045
+ return None
1046
+
1047
+ #
1048
+ # Parse a typedef, it records the type and its name.
1049
+ #
1050
+ def parseTypedef(self, token):
1051
+ if token == None:
1052
+ return None
1053
+ token = self.parseType(token)
1054
+ if token == None:
1055
+ self.error("parsing typedef")
1056
+ return None
1057
+ base_type = self.type
1058
+ type = base_type
1059
+ #self.debug("end typedef type", token)
1060
+ while token != None:
1061
+ if token[0] == "name":
1062
+ name = token[1]
1063
+ signature = self.signature
1064
+ if signature != None:
1065
+ type = type.split('(')[0]
1066
+ d = self.mergeFunctionComment(name,
1067
+ ((type, None), signature), 1)
1068
+ self.index_add(name, self.filename, not self.is_header,
1069
+ "functype", d)
1070
+ else:
1071
+ if base_type == "struct":
1072
+ self.index_add(name, self.filename, not self.is_header,
1073
+ "struct", type)
1074
+ base_type = "struct " + name
1075
+ else:
1076
+ # TODO report missing or misformatted comments
1077
+ info = self.parseSimpleComment(name, True)
1078
+ self.index_add(name, self.filename, not self.is_header,
1079
+ "typedef", type, info)
1080
+ token = self.token()
1081
+ else:
1082
+ self.error("parsing typedef: expecting a name")
1083
+ return token
1084
+ #self.debug("end typedef", token)
1085
+ if token != None and token[0] == 'sep' and token[1] == ',':
1086
+ type = base_type
1087
+ token = self.token()
1088
+ while token != None and token[0] == "op":
1089
+ type = type + token[1]
1090
+ token = self.token()
1091
+ elif token != None and token[0] == 'sep' and token[1] == ';':
1092
+ break;
1093
+ elif token != None and token[0] == 'name':
1094
+ type = base_type
1095
+ continue;
1096
+ else:
1097
+ self.error("parsing typedef: expecting ';'", token)
1098
+ return token
1099
+ token = self.token()
1100
+ return token
1101
+
1102
+ #
1103
+ # Parse a C code block, used for functions it parse till
1104
+ # the balancing } included
1105
+ #
1106
+ def parseBlock(self, token):
1107
+ while token != None:
1108
+ if token[0] == "sep" and token[1] == "{":
1109
+ token = self.token()
1110
+ token = self.parseBlock(token)
1111
+ elif token[0] == "sep" and token[1] == "}":
1112
+ token = self.token()
1113
+ return token
1114
+ else:
1115
+ if self.collect_ref == 1:
1116
+ oldtok = token
1117
+ token = self.token()
1118
+ if oldtok[0] == "name" and oldtok[1][0:3] == "xml":
1119
+ if token[0] == "sep" and token[1] == "(":
1120
+ self.index_add_ref(oldtok[1], self.filename,
1121
+ 0, "function")
1122
+ token = self.token()
1123
+ elif token[0] == "name":
1124
+ token = self.token()
1125
+ if token[0] == "sep" and (token[1] == ";" or
1126
+ token[1] == "," or token[1] == "="):
1127
+ self.index_add_ref(oldtok[1], self.filename,
1128
+ 0, "type")
1129
+ elif oldtok[0] == "name" and oldtok[1][0:4] == "XML_":
1130
+ self.index_add_ref(oldtok[1], self.filename,
1131
+ 0, "typedef")
1132
+ elif oldtok[0] == "name" and oldtok[1][0:7] == "LIBXML_":
1133
+ self.index_add_ref(oldtok[1], self.filename,
1134
+ 0, "typedef")
1135
+
1136
+ else:
1137
+ token = self.token()
1138
+ return token
1139
+
1140
+ #
1141
+ # Parse a C struct definition till the balancing }
1142
+ #
1143
+ def parseStruct(self, token):
1144
+ fields = []
1145
+ #self.debug("start parseStruct", token)
1146
+ while token != None:
1147
+ if token[0] == "sep" and token[1] == "{":
1148
+ token = self.token()
1149
+ token = self.parseTypeBlock(token)
1150
+ elif token[0] == "sep" and token[1] == "}":
1151
+ self.struct_fields = fields
1152
+ #self.debug("end parseStruct", token)
1153
+ #print fields
1154
+ token = self.token()
1155
+ return token
1156
+ else:
1157
+ base_type = self.type
1158
+ #self.debug("before parseType", token)
1159
+ token = self.parseType(token)
1160
+ #self.debug("after parseType", token)
1161
+ if token != None and token[0] == "name":
1162
+ fname = token[1]
1163
+ token = self.token()
1164
+ if token[0] == "sep" and token[1] == ";":
1165
+ token = self.token()
1166
+ fields.append((self.type, fname))
1167
+ else:
1168
+ self.error("parseStruct: expecting ;", token)
1169
+ elif token != None and token[0] == "sep" and token[1] == "{":
1170
+ token = self.token()
1171
+ token = self.parseTypeBlock(token)
1172
+ if token != None and token[0] == "name":
1173
+ token = self.token()
1174
+ if token != None and token[0] == "sep" and token[1] == ";":
1175
+ token = self.token()
1176
+ else:
1177
+ self.error("parseStruct: expecting ;", token)
1178
+ else:
1179
+ self.error("parseStruct: name", token)
1180
+ token = self.token()
1181
+ self.type = base_type;
1182
+ self.struct_fields = fields
1183
+ #self.debug("end parseStruct", token)
1184
+ #print fields
1185
+ return token
1186
+
1187
+ #
1188
+ # Parse a C enum block, parse till the balancing }
1189
+ #
1190
+ def parseEnumBlock(self, token):
1191
+ self.enums = []
1192
+ name = None
1193
+ self.comment = None
1194
+ comment = ""
1195
+ value = "0"
1196
+ while token != None:
1197
+ if token[0] == "sep" and token[1] == "{":
1198
+ token = self.token()
1199
+ token = self.parseTypeBlock(token)
1200
+ elif token[0] == "sep" and token[1] == "}":
1201
+ if name != None:
1202
+ if self.comment != None:
1203
+ comment = self.comment
1204
+ self.comment = None
1205
+ self.enums.append((name, value, comment))
1206
+ token = self.token()
1207
+ return token
1208
+ elif token[0] == "name":
1209
+ if name != None:
1210
+ if self.comment != None:
1211
+ comment = self.comment.strip()
1212
+ self.comment = None
1213
+ self.enums.append((name, value, comment))
1214
+ name = token[1]
1215
+ comment = ""
1216
+ token = self.token()
1217
+ if token[0] == "op" and token[1][0] == "=":
1218
+ value = ""
1219
+ if len(token[1]) > 1:
1220
+ value = token[1][1:]
1221
+ token = self.token()
1222
+ while token[0] != "sep" or (token[1] != ',' and
1223
+ token[1] != '}'):
1224
+ value = value + token[1]
1225
+ token = self.token()
1226
+ else:
1227
+ try:
1228
+ value = "%d" % (int(value) + 1)
1229
+ except:
1230
+ self.warning("Failed to compute value of enum %s" % (name))
1231
+ value=""
1232
+ if token[0] == "sep" and token[1] == ",":
1233
+ token = self.token()
1234
+ else:
1235
+ token = self.token()
1236
+ return token
1237
+
1238
+ #
1239
+ # Parse a C definition block, used for structs it parse till
1240
+ # the balancing }
1241
+ #
1242
+ def parseTypeBlock(self, token):
1243
+ while token != None:
1244
+ if token[0] == "sep" and token[1] == "{":
1245
+ token = self.token()
1246
+ token = self.parseTypeBlock(token)
1247
+ elif token[0] == "sep" and token[1] == "}":
1248
+ token = self.token()
1249
+ return token
1250
+ else:
1251
+ token = self.token()
1252
+ return token
1253
+
1254
+ #
1255
+ # Parse a type: the fact that the type name can either occur after
1256
+ # the definition or within the definition makes it a little harder
1257
+ # if inside, the name token is pushed back before returning
1258
+ #
1259
+ def parseType(self, token):
1260
+ self.type = ""
1261
+ self.struct_fields = []
1262
+ self.signature = None
1263
+ if token == None:
1264
+ return token
1265
+
1266
+ have_sign = 0
1267
+ done = 0
1268
+
1269
+ while token[0] == "name" and (
1270
+ token[1] == "const" or \
1271
+ token[1] == "unsigned" or \
1272
+ token[1] == "signed"):
1273
+ if token[1] == "unsigned" or token[1] == "signed":
1274
+ have_sign = 1
1275
+ if self.type == "":
1276
+ self.type = token[1]
1277
+ else:
1278
+ self.type = self.type + " " + token[1]
1279
+ token = self.token()
1280
+
1281
+ if token[0] == "name" and token[1] in ("char", "short", "int", "long"):
1282
+ if self.type == "":
1283
+ self.type = token[1]
1284
+ else:
1285
+ self.type = self.type + " " + token[1]
1286
+
1287
+ elif have_sign:
1288
+ done = 1
1289
+
1290
+ elif token[0] == "name" and token[1] == "struct":
1291
+ if self.type == "":
1292
+ self.type = token[1]
1293
+ else:
1294
+ self.type = self.type + " " + token[1]
1295
+ token = self.token()
1296
+ nametok = None
1297
+ if token[0] == "name":
1298
+ nametok = token
1299
+ token = self.token()
1300
+ if token != None and token[0] == "sep" and token[1] == "{":
1301
+ token = self.token()
1302
+ token = self.parseStruct(token)
1303
+ elif token != None and token[0] == "op" and token[1] == "*":
1304
+ self.type = self.type + " " + nametok[1] + " *"
1305
+ token = self.token()
1306
+ while token != None and token[0] == "op" and token[1] == "*":
1307
+ self.type = self.type + " *"
1308
+ token = self.token()
1309
+ if token[0] == "name":
1310
+ nametok = token
1311
+ token = self.token()
1312
+ else:
1313
+ self.error("struct : expecting name", token)
1314
+ return token
1315
+ elif token != None and token[0] == "name" and nametok != None:
1316
+ self.type = self.type + " " + nametok[1]
1317
+ return token
1318
+
1319
+ if nametok != None:
1320
+ self.lexer.push(token)
1321
+ token = nametok
1322
+ return token
1323
+
1324
+ elif token[0] == "name" and token[1] == "enum":
1325
+ if self.type == "":
1326
+ self.type = token[1]
1327
+ else:
1328
+ self.type = self.type + " " + token[1]
1329
+ self.enums = []
1330
+ token = self.token()
1331
+ if token != None and token[0] == "sep" and token[1] == "{":
1332
+ token = self.token()
1333
+ token = self.parseEnumBlock(token)
1334
+ else:
1335
+ self.error("parsing enum: expecting '{'", token)
1336
+ enum_type = None
1337
+ if token != None and token[0] != "name":
1338
+ self.lexer.push(token)
1339
+ token = ("name", "enum")
1340
+ else:
1341
+ enum_type = token[1]
1342
+ for enum in self.enums:
1343
+ self.index_add(enum[0], self.filename,
1344
+ not self.is_header, "enum",
1345
+ (enum[1], enum[2], enum_type))
1346
+ return token
1347
+
1348
+ elif token[0] == "name":
1349
+ if self.type == "":
1350
+ self.type = token[1]
1351
+ else:
1352
+ self.type = self.type + " " + token[1]
1353
+ else:
1354
+ self.error("parsing type %s: expecting a name" % (self.type),
1355
+ token)
1356
+ return token
1357
+ if not done:
1358
+ token = self.token()
1359
+ while token != None and (token[0] == "op" or
1360
+ token[0] == "name" and token[1] == "const"):
1361
+ self.type = self.type + " " + token[1]
1362
+ token = self.token()
1363
+
1364
+ #
1365
+ # if there is a parenthesis here, this means a function type
1366
+ #
1367
+ if token != None and token[0] == "sep" and token[1] == '(':
1368
+ self.type = self.type + token[1]
1369
+ token = self.token()
1370
+ while token != None and token[0] == "op" and token[1] == '*':
1371
+ self.type = self.type + token[1]
1372
+ token = self.token()
1373
+ if token == None or token[0] != "name" :
1374
+ self.error("parsing function type, name expected", token);
1375
+ return token
1376
+ self.type = self.type + token[1]
1377
+ nametok = token
1378
+ token = self.token()
1379
+ if token != None and token[0] == "sep" and token[1] == ')':
1380
+ self.type = self.type + token[1]
1381
+ token = self.token()
1382
+ if token != None and token[0] == "sep" and token[1] == '(':
1383
+ token = self.token()
1384
+ type = self.type;
1385
+ token = self.parseSignature(token);
1386
+ self.type = type;
1387
+ else:
1388
+ self.error("parsing function type, '(' expected", token);
1389
+ return token
1390
+ else:
1391
+ self.error("parsing function type, ')' expected", token);
1392
+ return token
1393
+ self.lexer.push(token)
1394
+ token = nametok
1395
+ return token
1396
+
1397
+ #
1398
+ # do some lookahead for arrays
1399
+ #
1400
+ if token != None and token[0] == "name":
1401
+ nametok = token
1402
+ token = self.token()
1403
+ if token != None and token[0] == "sep" and token[1] == '[':
1404
+ self.type = self.type + nametok[1]
1405
+ while token != None and token[0] == "sep" and token[1] == '[':
1406
+ self.type = self.type + token[1]
1407
+ token = self.token()
1408
+ while token != None and token[0] != 'sep' and \
1409
+ token[1] != ']' and token[1] != ';':
1410
+ self.type = self.type + token[1]
1411
+ token = self.token()
1412
+ if token != None and token[0] == 'sep' and token[1] == ']':
1413
+ self.type = self.type + token[1]
1414
+ token = self.token()
1415
+ else:
1416
+ self.error("parsing array type, ']' expected", token);
1417
+ return token
1418
+ elif token != None and token[0] == "sep" and token[1] == ':':
1419
+ # remove :12 in case it's a limited int size
1420
+ token = self.token()
1421
+ token = self.token()
1422
+ self.lexer.push(token)
1423
+ token = nametok
1424
+
1425
+ return token
1426
+
1427
+ #
1428
+ # Parse a signature: '(' has been parsed and we scan the type definition
1429
+ # up to the ')' included
1430
+ def parseSignature(self, token):
1431
+ signature = []
1432
+ if token != None and token[0] == "sep" and token[1] == ')':
1433
+ self.signature = []
1434
+ token = self.token()
1435
+ return token
1436
+ while token != None:
1437
+ token = self.parseType(token)
1438
+ if token != None and token[0] == "name":
1439
+ signature.append((self.type, token[1], None))
1440
+ token = self.token()
1441
+ elif token != None and token[0] == "sep" and token[1] == ',':
1442
+ token = self.token()
1443
+ continue
1444
+ elif token != None and token[0] == "sep" and token[1] == ')':
1445
+ # only the type was provided
1446
+ if self.type == "...":
1447
+ signature.append((self.type, "...", None))
1448
+ else:
1449
+ signature.append((self.type, None, None))
1450
+ if token != None and token[0] == "sep":
1451
+ if token[1] == ',':
1452
+ token = self.token()
1453
+ continue
1454
+ elif token[1] == ')':
1455
+ token = self.token()
1456
+ break
1457
+ self.signature = signature
1458
+ return token
1459
+
1460
+ #
1461
+ # Parse a global definition, be it a type, variable or function
1462
+ # the extern "C" blocks are a bit nasty and require it to recurse.
1463
+ #
1464
+ def parseGlobal(self, token):
1465
+ static = 0
1466
+ if token[1] == 'extern':
1467
+ token = self.token()
1468
+ if token == None:
1469
+ return token
1470
+ if token[0] == 'string':
1471
+ if token[1] == 'C':
1472
+ token = self.token()
1473
+ if token == None:
1474
+ return token
1475
+ if token[0] == 'sep' and token[1] == "{":
1476
+ token = self.token()
1477
+ # print 'Entering extern "C line ', self.lineno()
1478
+ while token != None and (token[0] != 'sep' or
1479
+ token[1] != "}"):
1480
+ if token[0] == 'name':
1481
+ token = self.parseGlobal(token)
1482
+ else:
1483
+ self.error(
1484
+ "token %s %s unexpected at the top level" % (
1485
+ token[0], token[1]))
1486
+ token = self.parseGlobal(token)
1487
+ # print 'Exiting extern "C" line', self.lineno()
1488
+ token = self.token()
1489
+ return token
1490
+ else:
1491
+ return token
1492
+ elif token[1] == 'static':
1493
+ static = 1
1494
+ token = self.token()
1495
+ if token == None or token[0] != 'name':
1496
+ return token
1497
+
1498
+ if token[1] == 'typedef':
1499
+ token = self.token()
1500
+ return self.parseTypedef(token)
1501
+ else:
1502
+ token = self.parseType(token)
1503
+ type_orig = self.type
1504
+ if token == None or token[0] != "name":
1505
+ return token
1506
+ type = type_orig
1507
+ self.name = token[1]
1508
+ token = self.token()
1509
+ while token != None and (token[0] == "sep" or token[0] == "op"):
1510
+ if token[0] == "sep":
1511
+ if token[1] == "[":
1512
+ type = type + token[1]
1513
+ token = self.token()
1514
+ while token != None and (token[0] != "sep" or \
1515
+ token[1] != ";"):
1516
+ type = type + token[1]
1517
+ token = self.token()
1518
+
1519
+ if token != None and token[0] == "op" and token[1] == "=":
1520
+ #
1521
+ # Skip the initialization of the variable
1522
+ #
1523
+ token = self.token()
1524
+ if token[0] == 'sep' and token[1] == '{':
1525
+ token = self.token()
1526
+ token = self.parseBlock(token)
1527
+ else:
1528
+ while token != None and (token[0] != "sep" or \
1529
+ (token[1] != ';' and token[1] != ',')):
1530
+ token = self.token()
1531
+ if token == None or token[0] != "sep" or (token[1] != ';' and
1532
+ token[1] != ','):
1533
+ self.error("missing ';' or ',' after value")
1534
+
1535
+ if token != None and token[0] == "sep":
1536
+ if token[1] == ";":
1537
+ if type == "struct":
1538
+ self.index_add(self.name, self.filename,
1539
+ not self.is_header, "struct", self.struct_fields)
1540
+ else:
1541
+ info = self.parseSimpleComment(self.name, True)
1542
+ self.index_add(self.name, self.filename,
1543
+ not self.is_header, "variable", type, info)
1544
+ self.comment = None
1545
+ token = self.token()
1546
+ break
1547
+ elif token[1] == "(":
1548
+ token = self.token()
1549
+ token = self.parseSignature(token)
1550
+ if token == None:
1551
+ return None
1552
+ if token[0] == "sep" and token[1] == ";":
1553
+ d = self.mergeFunctionComment(self.name,
1554
+ ((type, None), self.signature), 1)
1555
+ self.index_add(self.name, self.filename, static,
1556
+ "function", d)
1557
+ self.comment = None
1558
+ token = self.token()
1559
+ elif token[0] == "sep" and token[1] == "{":
1560
+ d = self.mergeFunctionComment(self.name,
1561
+ ((type, None), self.signature), static)
1562
+ self.index_add(self.name, self.filename, static,
1563
+ "function", d)
1564
+ self.comment = None
1565
+ token = self.token()
1566
+ token = self.parseBlock(token);
1567
+ elif token[1] == ',':
1568
+ self.index_add(self.name, self.filename, static,
1569
+ "variable", type)
1570
+ self.comment = None
1571
+ type = type_orig
1572
+ token = self.token()
1573
+ while token != None and token[0] == "sep":
1574
+ type = type + token[1]
1575
+ token = self.token()
1576
+ if token != None and token[0] == "name":
1577
+ self.name = token[1]
1578
+ token = self.token()
1579
+ else:
1580
+ break
1581
+
1582
+ return token
1583
+
1584
+ def parse(self):
1585
+ self.warning("Parsing %s" % (self.filename))
1586
+ token = self.token()
1587
+ while token != None:
1588
+ if token[0] == 'name':
1589
+ token = self.parseGlobal(token)
1590
+ else:
1591
+ self.error("token %s %s unexpected at the top level" % (
1592
+ token[0], token[1]))
1593
+ token = self.parseGlobal(token)
1594
+ return
1595
+ self.parseTopComment(self.top_comment)
1596
+ return self.index
1597
+
1598
+
1599
+ class docBuilder:
1600
+ """A documentation builder"""
1601
+ def __init__(self, name, directories=['.'], excludes=[]):
1602
+ self.name = name
1603
+ self.directories = directories
1604
+ self.excludes = excludes + list(ignored_files.keys())
1605
+ self.modules = {}
1606
+ self.headers = {}
1607
+ self.idx = index()
1608
+ self.index = {}
1609
+ if name == 'libxml2':
1610
+ self.basename = 'libxml'
1611
+ else:
1612
+ self.basename = name
1613
+
1614
+ def analyze(self):
1615
+ print("Project %s : %d headers, %d modules" % (self.name, len(list(self.headers.keys())), len(list(self.modules.keys()))))
1616
+ self.idx.analyze()
1617
+
1618
+ def scanHeaders(self):
1619
+ for header in list(self.headers.keys()):
1620
+ parser = CParser(header)
1621
+ idx = parser.parse()
1622
+ self.headers[header] = idx;
1623
+ self.idx.merge(idx)
1624
+
1625
+ def scanModules(self):
1626
+ for module in list(self.modules.keys()):
1627
+ parser = CParser(module)
1628
+ idx = parser.parse()
1629
+ # idx.analyze()
1630
+ self.modules[module] = idx
1631
+ self.idx.merge_public(idx)
1632
+
1633
+ def scan(self):
1634
+ for directory in self.directories:
1635
+ files = glob.glob(directory + "/*.c")
1636
+ for file in files:
1637
+ skip = 0
1638
+ for excl in self.excludes:
1639
+ if file.find(excl) != -1:
1640
+ print("Skipping %s" % file)
1641
+ skip = 1
1642
+ break
1643
+ if skip == 0:
1644
+ self.modules[file] = None;
1645
+ files = glob.glob(directory + "/*.h")
1646
+ for file in files:
1647
+ skip = 0
1648
+ for excl in self.excludes:
1649
+ if file.find(excl) != -1:
1650
+ print("Skipping %s" % file)
1651
+ skip = 1
1652
+ break
1653
+ if skip == 0:
1654
+ self.headers[file] = None;
1655
+ self.scanHeaders()
1656
+ self.scanModules()
1657
+
1658
+ def modulename_file(self, file):
1659
+ module = os.path.basename(file)
1660
+ if module[-2:] == '.h':
1661
+ module = module[:-2]
1662
+ elif module[-2:] == '.c':
1663
+ module = module[:-2]
1664
+ return module
1665
+
1666
+ def serialize_enum(self, output, name):
1667
+ id = self.idx.enums[name]
1668
+ output.write(" <enum name='%s' file='%s'" % (name,
1669
+ self.modulename_file(id.header)))
1670
+ if id.info != None:
1671
+ info = id.info
1672
+ if info[0] != None and info[0] != '':
1673
+ try:
1674
+ val = eval(info[0])
1675
+ except:
1676
+ val = info[0]
1677
+ output.write(" value='%s'" % (val));
1678
+ if info[2] != None and info[2] != '':
1679
+ output.write(" type='%s'" % info[2]);
1680
+ if info[1] != None and info[1] != '':
1681
+ output.write(" info='%s'" % escape(info[1]));
1682
+ output.write("/>\n")
1683
+
1684
+ def serialize_macro(self, output, name):
1685
+ id = self.idx.macros[name]
1686
+ output.write(" <macro name='%s' file='%s'>\n" % (name,
1687
+ self.modulename_file(id.header)))
1688
+ if id.info != None:
1689
+ try:
1690
+ (args, desc) = id.info
1691
+ if desc != None and desc != "":
1692
+ output.write(" <info>%s</info>\n" % (escape(desc)))
1693
+ for arg in args:
1694
+ (name, desc) = arg
1695
+ if desc != None and desc != "":
1696
+ output.write(" <arg name='%s' info='%s'/>\n" % (
1697
+ name, escape(desc)))
1698
+ else:
1699
+ output.write(" <arg name='%s'/>\n" % (name))
1700
+ except:
1701
+ pass
1702
+ output.write(" </macro>\n")
1703
+
1704
+ def serialize_typedef(self, output, name):
1705
+ id = self.idx.typedefs[name]
1706
+ if id.info[0:7] == 'struct ':
1707
+ output.write(" <struct name='%s' file='%s' type='%s'" % (
1708
+ name, self.modulename_file(id.header), id.info))
1709
+ name = id.info[7:]
1710
+ if name in self.idx.structs and ( \
1711
+ type(self.idx.structs[name].info) == type(()) or
1712
+ type(self.idx.structs[name].info) == type([])):
1713
+ output.write(">\n");
1714
+ try:
1715
+ for field in self.idx.structs[name].info:
1716
+ output.write(" <field name='%s' type='%s'/>\n" % (field[1] , field[0]))
1717
+ except:
1718
+ print("Failed to serialize struct %s" % (name))
1719
+ output.write(" </struct>\n")
1720
+ else:
1721
+ output.write("/>\n");
1722
+ else :
1723
+ output.write(" <typedef name='%s' file='%s' type='%s'" % (
1724
+ name, self.modulename_file(id.header), id.info))
1725
+ try:
1726
+ desc = id.extra
1727
+ if desc != None and desc != "":
1728
+ output.write(">\n <info>%s</info>\n" % (escape(desc)))
1729
+ output.write(" </typedef>\n")
1730
+ else:
1731
+ output.write("/>\n")
1732
+ except:
1733
+ output.write("/>\n")
1734
+
1735
+ def serialize_variable(self, output, name):
1736
+ id = self.idx.variables[name]
1737
+ if id.info != None:
1738
+ output.write(" <variable name='%s' file='%s' type='%s'" % (
1739
+ name, self.modulename_file(id.header), id.info))
1740
+ else:
1741
+ output.write(" <variable name='%s' file='%s'" % (
1742
+ name, self.modulename_file(id.header)))
1743
+ desc = id.extra
1744
+ if desc != None and desc != "":
1745
+ output.write(">\n <info>%s</info>\n" % (escape(desc)))
1746
+ output.write(" </variable>\n")
1747
+ else:
1748
+ output.write("/>\n")
1749
+
1750
+ def serialize_function(self, output, name):
1751
+ id = self.idx.functions[name]
1752
+ if name == debugsym:
1753
+ print("=>", id)
1754
+
1755
+ output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type,
1756
+ name, self.modulename_file(id.header),
1757
+ self.modulename_file(id.module)))
1758
+ #
1759
+ # Processing of conditionals modified by Bill 1/1/05
1760
+ #
1761
+ if id.conditionals != None:
1762
+ apstr = ""
1763
+ for cond in id.conditionals:
1764
+ if apstr != "":
1765
+ apstr = apstr + " &amp;&amp; "
1766
+ apstr = apstr + cond
1767
+ output.write(" <cond>%s</cond>\n"% (apstr));
1768
+ try:
1769
+ (ret, params, desc) = id.info
1770
+ if (desc == None or desc == '') and \
1771
+ name[0:9] != "xmlThrDef" and name != "xmlDllMain" and \
1772
+ ret[1] == '':
1773
+ print("%s %s from %s has no description" % (id.type, name,
1774
+ self.modulename_file(id.module)))
1775
+
1776
+ output.write(" <info>%s</info>\n" % (escape(desc)))
1777
+ if ret[0] != None:
1778
+ if ret[0] == "void":
1779
+ output.write(" <return type='void'/>\n")
1780
+ else:
1781
+ output.write(" <return type='%s' info='%s'/>\n" % (
1782
+ ret[0], escape(ret[1])))
1783
+ for param in params:
1784
+ if param[0] == 'void':
1785
+ continue
1786
+ if param[2] == None:
1787
+ output.write(" <arg name='%s' type='%s' info=''/>\n" % (param[1], param[0]))
1788
+ else:
1789
+ output.write(" <arg name='%s' type='%s' info='%s'/>\n" % (param[1], param[0], escape(param[2])))
1790
+ except:
1791
+ print("Failed to save function %s info: " % name, repr(id.info))
1792
+ output.write(" </%s>\n" % (id.type))
1793
+
1794
+ def serialize_exports(self, output, file):
1795
+ module = self.modulename_file(file)
1796
+ output.write(" <file name='%s'>\n" % (module))
1797
+ dict = self.headers[file]
1798
+ if dict.info != None:
1799
+ for data in ('Summary', 'Description', 'Author'):
1800
+ try:
1801
+ output.write(" <%s>%s</%s>\n" % (
1802
+ data.lower(),
1803
+ escape(dict.info[data]),
1804
+ data.lower()))
1805
+ except:
1806
+ if data != 'Author':
1807
+ print("Header %s lacks a %s description" % (module, data))
1808
+ if 'Description' in dict.info:
1809
+ desc = dict.info['Description']
1810
+ if desc.find("DEPRECATED") != -1:
1811
+ output.write(" <deprecated/>\n")
1812
+
1813
+ ids = list(dict.macros.keys())
1814
+ ids.sort()
1815
+ for id in ids:
1816
+ # Macros are sometime used to masquerade other types.
1817
+ if id in dict.functions:
1818
+ continue
1819
+ if id in dict.variables:
1820
+ continue
1821
+ if id in dict.typedefs:
1822
+ continue
1823
+ if id in dict.structs:
1824
+ continue
1825
+ if id in dict.enums:
1826
+ continue
1827
+ output.write(" <exports symbol='%s' type='macro'/>\n" % (id))
1828
+ ids = list(dict.enums.keys())
1829
+ ids.sort()
1830
+ for id in ids:
1831
+ output.write(" <exports symbol='%s' type='enum'/>\n" % (id))
1832
+ ids = list(dict.typedefs.keys())
1833
+ ids.sort()
1834
+ for id in ids:
1835
+ output.write(" <exports symbol='%s' type='typedef'/>\n" % (id))
1836
+ ids = list(dict.structs.keys())
1837
+ ids.sort()
1838
+ for id in ids:
1839
+ output.write(" <exports symbol='%s' type='struct'/>\n" % (id))
1840
+ ids = list(dict.variables.keys())
1841
+ ids.sort()
1842
+ for id in ids:
1843
+ output.write(" <exports symbol='%s' type='variable'/>\n" % (id))
1844
+ ids = list(dict.functions.keys())
1845
+ ids.sort()
1846
+ for id in ids:
1847
+ output.write(" <exports symbol='%s' type='function'/>\n" % (id))
1848
+ output.write(" </file>\n")
1849
+
1850
+ def serialize(self):
1851
+ filename = "%s-api.xml" % self.name
1852
+ print("Saving XML description %s" % (filename))
1853
+ output = open(filename, "w")
1854
+ output.write('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
1855
+ output.write("<api name='%s'>\n" % self.name)
1856
+ output.write(" <files>\n")
1857
+ headers = list(self.headers.keys())
1858
+ headers.sort()
1859
+ for file in headers:
1860
+ self.serialize_exports(output, file)
1861
+ output.write(" </files>\n")
1862
+ output.write(" <symbols>\n")
1863
+ macros = list(self.idx.macros.keys())
1864
+ macros.sort()
1865
+ for macro in macros:
1866
+ self.serialize_macro(output, macro)
1867
+ enums = list(self.idx.enums.keys())
1868
+ enums.sort()
1869
+ for enum in enums:
1870
+ self.serialize_enum(output, enum)
1871
+ typedefs = list(self.idx.typedefs.keys())
1872
+ typedefs.sort()
1873
+ for typedef in typedefs:
1874
+ self.serialize_typedef(output, typedef)
1875
+ variables = list(self.idx.variables.keys())
1876
+ variables.sort()
1877
+ for variable in variables:
1878
+ self.serialize_variable(output, variable)
1879
+ functions = list(self.idx.functions.keys())
1880
+ functions.sort()
1881
+ for function in functions:
1882
+ self.serialize_function(output, function)
1883
+ output.write(" </symbols>\n")
1884
+ output.write("</api>\n")
1885
+ output.close()
1886
+
1887
+
1888
+ def rebuild():
1889
+ builder = None
1890
+ if glob.glob("parser.c") != [] :
1891
+ print("Rebuilding API description for libxml2")
1892
+ builder = docBuilder("libxml2", [".", "."],
1893
+ ["tst.c"])
1894
+ elif glob.glob("../parser.c") != [] :
1895
+ print("Rebuilding API description for libxml2")
1896
+ builder = docBuilder("libxml2", ["..", "../include/libxml"],
1897
+ ["tst.c"])
1898
+ elif glob.glob("../libxslt/transform.c") != [] :
1899
+ print("Rebuilding API description for libxslt")
1900
+ builder = docBuilder("libxslt", ["../libxslt"],
1901
+ ["win32config.h", "libxslt.h", "tst.c"])
1902
+ else:
1903
+ print("rebuild() failed, unable to guess the module")
1904
+ return None
1905
+ builder.scan()
1906
+ builder.analyze()
1907
+ builder.serialize()
1908
+ if glob.glob("../libexslt/exslt.c") != [] :
1909
+ extra = docBuilder("libexslt", ["../libexslt"], ["libexslt.h"])
1910
+ extra.scan()
1911
+ extra.analyze()
1912
+ extra.serialize()
1913
+ return builder
1914
+
1915
+ #
1916
+ # for debugging the parser
1917
+ #
1918
+ def parse(filename):
1919
+ parser = CParser(filename)
1920
+ idx = parser.parse()
1921
+ return idx
1922
+
1923
+ if __name__ == "__main__":
1924
+ if len(sys.argv) > 1:
1925
+ debug = 1
1926
+ parse(sys.argv[1])
1927
+ else:
1928
+ rebuild()
local-test-libxml2-delta-01/afc-libxml2/doc/libxml2-api.xml ADDED
The diff for this file is too large to render. See raw diff
 
local-test-libxml2-delta-01/afc-libxml2/doc/meson.build ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ install_man(files(['xml2-config.1', 'xmlcatalog.1', 'xmllint.1']))
3
+
4
+
5
+ tutorial_files = files(
6
+ 'xmlcatalog.html',
7
+ 'xmllint.html',
8
+ )
9
+
10
+ install_data(tutorial_files, install_dir: dir_doc)
11
+
12
+ subdir('devhelp')
local-test-libxml2-delta-01/afc-libxml2/doc/xml2-config.1 ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .TH xml2-config 1 "3 April 2022" Version 1.2.0
2
+ .SH NAME
3
+ xml2-config - script to get information about the installed version of libxml2
4
+ .SH SYNOPSIS
5
+ .B xml2-config
6
+ [\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help]
7
+ .SH DESCRIPTION
8
+ \fIxml2-config\fP is a tool that is used to determine the compile and
9
+ linker flags that should be used to compile and link programs that use
10
+ \fIlibxml2\fP.
11
+ .SH OPTIONS
12
+ \fIxml2-config\fP accepts the following options:
13
+ .TP 8
14
+ .B \-\-version
15
+ Print the currently installed version of \fIlibxml2\fP on the standard output.
16
+ .TP 8
17
+ .B \-\-libs
18
+ Print the linker flags that are necessary to link a \fIlibxml2\fP program.
19
+ Add \-\-dynamic after \-\-libs to print only shared library linking
20
+ information.
21
+ .TP 8
22
+ .B \-\-cflags
23
+ Print the compiler flags that are necessary to compile a \fIlibxml2\fP program.
24
+ .TP 8
25
+ .B \-\-prefix=PREFIX
26
+ If specified, use PREFIX instead of the installation prefix that
27
+ \fIlibxml2\fP was built with when computing the output for the
28
+ \-\-cflags and \-\-libs options. This option must be specified before
29
+ any \-\-libs or \-\-cflags options.
30
+ .SH AUTHOR
31
+ This manual page was written by Fredrik Hallenberg <hallon@lysator.liu.se>,
32
+ for the Debian GNU/linux system (but may be used by others).
local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.1 ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '\" t
2
+ .\" Title: xmlcatalog
3
+ .\" Author: John Fleck <jfleck@inkstain.net>
4
+ .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5
+ .\" Date: 06/12/2024
6
+ .\" Manual: xmlcatalog Manual
7
+ .\" Source: libxml2
8
+ .\" Language: English
9
+ .\"
10
+ .TH "XMLCATALOG" "1" "06/12/2024" "libxml2" "xmlcatalog Manual"
11
+ .\" -----------------------------------------------------------------
12
+ .\" * Define some portability stuff
13
+ .\" -----------------------------------------------------------------
14
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ .\" http://bugs.debian.org/507673
16
+ .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
+ .ie \n(.g .ds Aq \(aq
19
+ .el .ds Aq '
20
+ .\" -----------------------------------------------------------------
21
+ .\" * set default formatting
22
+ .\" -----------------------------------------------------------------
23
+ .\" disable hyphenation
24
+ .nh
25
+ .\" disable justification (adjust text to left margin only)
26
+ .ad l
27
+ .\" -----------------------------------------------------------------
28
+ .\" * MAIN CONTENT STARTS HERE *
29
+ .\" -----------------------------------------------------------------
30
+ .SH "NAME"
31
+ xmlcatalog \- Command line tool to parse and manipulate XML or SGML catalog files\&.
32
+ .SH "SYNOPSIS"
33
+ .HP \w'\fBxmlcatalog\fR\ 'u
34
+ \fBxmlcatalog\fR [\fB\-\-sgml\fR | \fB\-\-shell\fR | \fB\-\-convert\fR | \fB\-\-create\fR | \fB\-\-del\ \fR\fB\fIVALUE(S)\fR\fR | [\ \fB\-\-add\ \fR\fB\fITYPE\fR\fR\fB\ \fR\fB\fIORIG\fR\fR\fB\ \fR\fB\fIREPLACE\fR\fR\fB\ \fR\ |\ \fB\-\-add\ \fR\fB\fIFILENAME\fR\fR] | \fB\-\-noout\fR | \fB\-\-no\-super\-update\fR | [\fB\-v\fR\ |\ \fB\-\-verbose\fR]] {\fICATALOGFILE\fR} {\fIENTITIES\fR...}
35
+ .SH "DESCRIPTION"
36
+ .PP
37
+ \fBxmlcatalog\fR
38
+ is a command line application allowing users to monitor and manipulate
39
+ XML
40
+ and
41
+ SGML
42
+ catalogs\&. It is included in
43
+ \fBlibxml\fR(3)\&.
44
+ .PP
45
+ Its functions can be invoked from a single command from the command line, or it can perform multiple functions in interactive mode\&. It can operate on both
46
+ XML
47
+ and
48
+ SGML
49
+ files\&.
50
+ .SH "OPTIONS"
51
+ .PP
52
+ \fBxmlcatalog\fR
53
+ accepts the following options (in alphabetical order):
54
+ .PP
55
+ \fB\-\-add \fR\fB\fITYPE\fR\fR\fB \fR\fB\fIORIG\fR\fR\fB \fR\fB\fIREPLACE\fR\fR\fB \fR
56
+ .RS 4
57
+ Add an entry to
58
+ CATALOGFILE\&.
59
+ \fITYPE\fR
60
+ indicates the type of entry\&. Possible types are:
61
+ \fIpublic\fR, \fIsystem\fR, \fIuri\fR, \fIrewriteSystem\fR, \fIrewriteURI\fR, \fIdelegatePublic\fR, \fIdelegateSystem\fR, \fIdelegateURI\fR, \fInextCatalog\fR\&.
62
+ \fIORIG\fR
63
+ is the original reference to be replaced, and
64
+ \fIREPLACE\fR
65
+ is the
66
+ URI
67
+ of the replacement entity to be used\&. The
68
+ \fB\-\-add\fR
69
+ option will not overwrite
70
+ CATALOGFILE, outputting to
71
+ stdout, unless
72
+ \fB\-\-noout\fR
73
+ is used\&. The
74
+ \fB\-\-add\fR
75
+ will always take three parameters even if some of the
76
+ XML
77
+ catalog constructs will have only a single argument\&.
78
+ .RE
79
+ .PP
80
+ \fB\-\-add \fR\fB\fIFILENAME\fR\fR
81
+ .RS 4
82
+ If the
83
+ \fB\-\-add\fR
84
+ option is used following the
85
+ \fB\-\-sgml\fR
86
+ option, only a single argument, a
87
+ \fIFILENAME\fR, is used\&. This is used to add the name of a catalog file to an
88
+ SGML
89
+ supercatalog, a file that contains references to other included
90
+ SGML
91
+ catalog files\&.
92
+ .RE
93
+ .PP
94
+ \fB\-\-convert\fR
95
+ .RS 4
96
+ Convert SGML catalog to XML\&.
97
+ .RE
98
+ .PP
99
+ \fB\-\-create\fR
100
+ .RS 4
101
+ Create a new
102
+ XML
103
+ catalog\&. Outputs to
104
+ stdout, ignoring
105
+ \fIfilename\fR
106
+ unless
107
+ \fB\-\-noout\fR
108
+ is used, in which case it creates a new catalog file
109
+ \fIfilename\fR\&.
110
+ .RE
111
+ .PP
112
+ \fB\-\-del \fR\fB\fIVALUE(S)\fR\fR
113
+ .RS 4
114
+ Remove entries from
115
+ \fICATALOGFILE\fR
116
+ matching
117
+ \fIVALUE(S)\fR\&. The
118
+ \fB\-\-del\fR
119
+ option will not overwrite
120
+ \fICATALOGFILE\fR, outputting to
121
+ stdout, unless
122
+ \fB\-\-noout\fR
123
+ is used\&.
124
+ .RE
125
+ .PP
126
+ \fB\-\-noout\fR
127
+ .RS 4
128
+ Save output to the named file rather than outputting to
129
+ stdout\&.
130
+ .RE
131
+ .PP
132
+ \fB\-\-no\-super\-update\fR
133
+ .RS 4
134
+ Do not update the
135
+ SGML
136
+ super catalog\&.
137
+ .RE
138
+ .PP
139
+ \fB\-\-shell\fR
140
+ .RS 4
141
+ Run a shell allowing interactive queries on catalog file
142
+ \fICATALOGFILE\fR\&. For the set of available commands see
143
+ the section called \(lqSHELL COMMANDS\(rq\&.
144
+ .RE
145
+ .PP
146
+ \fB\-\-sgml\fR
147
+ .RS 4
148
+ Uses
149
+ SGML
150
+ super catalogs for
151
+ \fB\-\-add\fR
152
+ and
153
+ \fB\-\-del\fR
154
+ options\&.
155
+ .RE
156
+ .PP
157
+ \fB\-v\fR, \fB\-\-verbose\fR
158
+ .RS 4
159
+ Output debugging information\&.
160
+ .RE
161
+ .PP
162
+ Invoking
163
+ \fBxmlcatalog\fR
164
+ non\-interactively without a designated action (imposed with options like
165
+ \fB\-\-add\fR) will result in a lookup of the catalog entry for
166
+ \fIENTITIES\fR
167
+ in the catalog denoted with
168
+ \fICATALOGFILE\fR\&. The corresponding entries will be output to the command line\&. This mode of operation, together with
169
+ \fB\-\-shell\fR
170
+ mode and non\-modifying (i\&.e\&. without
171
+ \fB\-\-noout\fR) direct actions, allows for a special shortcut of the void
172
+ \fICATALOGFILE\fR
173
+ specification (possibly expressed as "" in the shell environment) appointing the default system catalog\&. That simplifies the handling when its exact location is irrelevant but the respective built\-in still needs to be consulted\&.
174
+ .SH "SHELL COMMANDS"
175
+ .PP
176
+ Invoking
177
+ \fBxmlcatalog\fR
178
+ with the
179
+ \fB\-\-shell \fR\fB\fICATALOGFILE\fR\fR
180
+ option opens a command line shell allowing interactive access to the catalog file identified by
181
+ \fICATALOGFILE\fR\&. Invoking the shell provides a command line prompt after which the following commands (described in alphabetical order) can be entered\&.
182
+ .PP
183
+ \fBadd \fR\fB\fITYPE\fR\fR\fB \fR\fB\fIORIG\fR\fR\fB \fR\fB\fIREPLACE\fR\fR\fB \fR
184
+ .RS 4
185
+ Add an entry to the catalog file\&.
186
+ \fITYPE\fR
187
+ indicates the type of entry\&. Possible types are:
188
+ \fIpublic\fR, \fIsystem\fR, \fIuri\fR, \fIrewriteSystem\fR, \fIrewriteURI\fR, \fIdelegatePublic\fR, \fIdelegateSystem\fR, \fIdelegateURI\fR, \fInextCatalog\fR\&.
189
+ \fIORIG\fR
190
+ is the original reference to be replaced, and
191
+ \fIREPLACE\fR
192
+ is the
193
+ URI
194
+ of the replacement entity to be used\&. The
195
+ \fB\-\-add\fR
196
+ option will not overwrite
197
+ CATALOGFILE, outputting to
198
+ stdout, unless
199
+ \fB\-\-noout\fR
200
+ is used\&. The
201
+ \fB\-\-add\fR
202
+ will always take three parameters even if some of the
203
+ XML
204
+ catalog constructs will have only a single argument\&.
205
+ .RE
206
+ .PP
207
+ \fBdebug\fR
208
+ .RS 4
209
+ Print debugging statements showing the steps
210
+ \fBxmlcatalog\fR
211
+ is executing\&.
212
+ .RE
213
+ .PP
214
+ \fBdel \fR\fB\fIVALUE(S)\fR\fR
215
+ .RS 4
216
+ Remove the catalog entry corresponding to
217
+ \fIVALUE(S)\fR\&.
218
+ .RE
219
+ .PP
220
+ \fBdump\fR
221
+ .RS 4
222
+ Print the current catalog\&.
223
+ .RE
224
+ .PP
225
+ \fBexit\fR
226
+ .RS 4
227
+ Quit the shell\&.
228
+ .RE
229
+ .PP
230
+ \fBpublic \fR\fB\fIPUBLIC\-ID\fR\fR
231
+ .RS 4
232
+ Execute a Formal Public Identifier lookup of the catalog entry for
233
+ \fIPUBLIC\-ID\fR\&. The corresponding entry will be output to the command line\&.
234
+ .RE
235
+ .PP
236
+ \fBquiet\fR
237
+ .RS 4
238
+ Stop printing debugging statements\&.
239
+ .RE
240
+ .PP
241
+ \fBsystem \fR\fB\fISYSTEM\-ID\fR\fR
242
+ .RS 4
243
+ Execute a Formal Public Identifier lookup of the catalog entry for
244
+ \fISYSTEM\-ID\fR\&. The corresponding entry will be output to the command line\&.
245
+ .RE
246
+ .SH "ENVIRONMENT"
247
+ .PP
248
+ \fBXML_CATALOG_FILES\fR
249
+ .RS 4
250
+ XML
251
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
252
+ \fBXML_CATALOG_FILES\fR
253
+ environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog from
254
+ /etc/xml/catalog
255
+ or, more specifically,
256
+ ${sysconfdir}/xml/catalog\&.
257
+ .RE
258
+ .SH "DIAGNOSTICS"
259
+ .PP
260
+ \fBxmlcatalog\fR
261
+ return codes provide information that can be used when calling it from scripts\&.
262
+ .PP
263
+ \fB0\fR
264
+ .RS 4
265
+ No error
266
+ .RE
267
+ .PP
268
+ \fB1\fR
269
+ .RS 4
270
+ Failed to remove an entry from the catalog
271
+ .RE
272
+ .PP
273
+ \fB2\fR
274
+ .RS 4
275
+ Failed to save to the catalog, check file permissions
276
+ .RE
277
+ .PP
278
+ \fB3\fR
279
+ .RS 4
280
+ Failed to add an entry to the catalog
281
+ .RE
282
+ .PP
283
+ \fB4\fR
284
+ .RS 4
285
+ Failed to look up an entry in the catalog
286
+ .RE
287
+ .SH "SEE ALSO"
288
+ .PP
289
+ \fBlibxml\fR(3)
290
+ .PP
291
+ More information can be found at
292
+ .sp
293
+ .RS 4
294
+ .ie n \{\
295
+ \h'-04'\(bu\h'+03'\c
296
+ .\}
297
+ .el \{\
298
+ .sp -1
299
+ .IP \(bu 2.3
300
+ .\}
301
+ \fBlibxml\fR(3)
302
+ web page
303
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2\fR\m[]
304
+ .RE
305
+ .sp
306
+ .RS 4
307
+ .ie n \{\
308
+ \h'-04'\(bu\h'+03'\c
309
+ .\}
310
+ .el \{\
311
+ .sp -1
312
+ .IP \(bu 2.3
313
+ .\}
314
+ \fBlibxml\fR(3)
315
+ catalog support web page at
316
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support\fR\m[]
317
+ .RE
318
+ .sp
319
+ .RS 4
320
+ .ie n \{\
321
+ \h'-04'\(bu\h'+03'\c
322
+ .\}
323
+ .el \{\
324
+ .sp -1
325
+ .IP \(bu 2.3
326
+ .\}
327
+ James Clark\*(Aqs
328
+ SGML
329
+ catalog page
330
+ \m[blue]\fB\%http://www.jclark.com/sp/catalog.htm\fR\m[]
331
+ .RE
332
+ .sp
333
+ .RS 4
334
+ .ie n \{\
335
+ \h'-04'\(bu\h'+03'\c
336
+ .\}
337
+ .el \{\
338
+ .sp -1
339
+ .IP \(bu 2.3
340
+ .\}
341
+ OASIS
342
+ XML
343
+ catalog specification
344
+ \m[blue]\fB\%http://www.oasis-open.org/committees/entity/spec.html\fR\m[]
345
+ .RE
346
+ .sp
347
+ .SH "AUTHOR"
348
+ .PP
349
+ \fBJohn Fleck\fR <\&jfleck@inkstain\&.net\&>
350
+ .RS 4
351
+ Author.
352
+ .RE
353
+ .SH "COPYRIGHT"
354
+ .br
355
+ Copyright \(co 2001, 2004
356
+ .br
local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.html ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmlcatalog</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmlcatalog &#8212;
2
+ Command line tool to parse and manipulate <acronym class="acronym">XML</acronym>
3
+ or <acronym class="acronym">SGML</acronym> catalog files.
4
+ </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmlcatalog</code> [ <code class="option">--sgml</code> | <code class="option">--shell</code> | <code class="option">--convert</code> | <code class="option">--create</code> | <code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code> |
5
+ [
6
+ <code class="option">--add
7
+ <em class="replaceable"><code>TYPE</code></em>
8
+ <em class="replaceable"><code>ORIG</code></em>
9
+ <em class="replaceable"><code>REPLACE</code></em>
10
+ </code>
11
+ | <code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code> ]
12
+ | <code class="option">--noout</code> | <code class="option">--no-super-update</code> |
13
+ [ <code class="option">-v</code> | <code class="option">--verbose</code> ]
14
+ ] {<em class="replaceable"><code>CATALOGFILE</code></em>} {<em class="replaceable"><code>ENTITIES</code></em>...}</p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
15
+ <span class="command"><strong>xmlcatalog</strong></span> is a command line application allowing users to monitor and
16
+ manipulate <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> catalogs. It
17
+ is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.
18
+ </p><p>
19
+ Its functions can be invoked from a single command from the command line,
20
+ or it can perform multiple functions in interactive mode. It can operate
21
+ on both <acronym class="acronym">XML</acronym> and <acronym class="acronym">SGML</acronym> files.
22
+ </p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
23
+ <span class="command"><strong>xmlcatalog</strong></span> accepts the following options (in alphabetical order):
24
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
25
+ <code class="option">--add
26
+ <em class="replaceable"><code>TYPE</code></em>
27
+ <em class="replaceable"><code>ORIG</code></em>
28
+ <em class="replaceable"><code>REPLACE</code></em>
29
+ </code>
30
+ </span></dt><dd><p>
31
+ Add an entry to <code class="filename">CATALOGFILE</code>. <em class="replaceable"><code>TYPE</code></em>
32
+ indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
33
+ reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
34
+ is the <acronym class="acronym">URI</acronym> of the replacement entity to be
35
+ used. The <code class="option">--add</code> option will not overwrite
36
+ <code class="filename">CATALOGFILE</code>, outputting
37
+ to <code class="filename">stdout</code>, unless
38
+ <code class="option">--noout</code> is used. The <code class="option">--add</code> will
39
+ always take three parameters even if some of the <acronym class="acronym">XML</acronym>
40
+ catalog constructs will have only a single argument.
41
+ </p></dd><dt><span class="term"><code class="option">--add <em class="replaceable"><code>FILENAME</code></em></code></span></dt><dd><p>
42
+ If the <code class="option">--add</code> option is used following
43
+ the <code class="option">--sgml</code> option, only a single argument,
44
+ a <em class="replaceable"><code>FILENAME</code></em>, is used. This is used to add
45
+ the name of a catalog file to an <acronym class="acronym">SGML</acronym> supercatalog,
46
+ a file that contains references to other included <acronym class="acronym">SGML</acronym>
47
+ catalog files.
48
+ </p></dd><dt><span class="term"><code class="option">--convert</code></span></dt><dd><p>
49
+ Convert SGML catalog to XML.
50
+ </p></dd><dt><span class="term"><code class="option">--create</code></span></dt><dd><p>
51
+ Create a new <acronym class="acronym">XML</acronym> catalog. Outputs
52
+ to <code class="filename">stdout</code>,
53
+ ignoring <em class="replaceable"><code>filename</code></em> unless <code class="option">--noout</code> is
54
+ used, in which case it creates a new catalog
55
+ file <em class="replaceable"><code>filename</code></em>.
56
+ </p></dd><dt><span class="term"><code class="option">--del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
57
+ Remove entries from <em class="replaceable"><code>CATALOGFILE</code></em>
58
+ matching <em class="replaceable"><code>VALUE(S)</code></em>. The <code class="option">--del</code>
59
+ option will not overwrite <em class="replaceable"><code>CATALOGFILE</code></em>,
60
+ outputting to <code class="filename">stdout</code>,
61
+ unless <code class="option">--noout</code> is used.
62
+ </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
63
+ Save output to the named file rather than outputting
64
+ to <code class="filename">stdout</code>.
65
+ </p></dd><dt><span class="term"><code class="option">--no-super-update</code></span></dt><dd><p>
66
+ Do not update the <acronym class="acronym">SGML</acronym> super catalog.
67
+ </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
68
+ Run a shell allowing interactive queries on catalog
69
+ file <em class="replaceable"><code>CATALOGFILE</code></em>. For the set of available
70
+ commands see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>.
71
+ </p></dd><dt><span class="term"><code class="option">--sgml</code></span></dt><dd><p>
72
+ Uses <acronym class="acronym">SGML</acronym> super catalogs for <code class="option">--add</code>
73
+ and <code class="option">--del</code> options.
74
+ </p></dd><dt><span class="term"><code class="option">-v</code>, </span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>Output debugging information.</p></dd></dl></div><p>
75
+ Invoking <span class="command"><strong>xmlcatalog</strong></span> non-interactively without a designated action
76
+ (imposed with options like <code class="option">--add</code>) will result in a lookup
77
+ of the catalog entry for <em class="replaceable"><code>ENTITIES</code></em> in the
78
+ catalog denoted with <em class="replaceable"><code>CATALOGFILE</code></em>. The
79
+ corresponding entries will be output to the command line. This mode of
80
+ operation, together with <code class="option">--shell</code> mode and non-modifying
81
+ (i.e. without <code class="option">--noout</code>) direct actions, allows for
82
+ a special shortcut of the void <em class="replaceable"><code>CATALOGFILE</code></em>
83
+ specification (possibly expressed as "" in the shell
84
+ environment) appointing the default system catalog. That simplifies the
85
+ handling when its exact location is irrelevant but the respective built-in
86
+ still needs to be consulted.
87
+ </p></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
88
+ Invoking <span class="command"><strong>xmlcatalog</strong></span> with
89
+ the <code class="option">--shell <em class="replaceable"><code>CATALOGFILE</code></em></code> option opens
90
+ a command line shell allowing interactive access to the catalog file
91
+ identified by <em class="replaceable"><code>CATALOGFILE</code></em>. Invoking the shell
92
+ provides a command line prompt after which the following commands (described in
93
+ alphabetical order) can be entered.
94
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
95
+ <code class="option">add
96
+ <em class="replaceable"><code>TYPE</code></em>
97
+ <em class="replaceable"><code>ORIG</code></em>
98
+ <em class="replaceable"><code>REPLACE</code></em>
99
+ </code>
100
+ </span></dt><dd><p>
101
+ Add an entry to the catalog file. <em class="replaceable"><code>TYPE</code></em>
102
+ indicates the type of entry. Possible types are: <span class="simplelist"><em class="parameter"><code>public</code></em>, <em class="parameter"><code>system</code></em>, <em class="parameter"><code>uri</code></em>, <em class="parameter"><code>rewriteSystem</code></em>, <em class="parameter"><code>rewriteURI</code></em>, <em class="parameter"><code>delegatePublic</code></em>, <em class="parameter"><code>delegateSystem</code></em>, <em class="parameter"><code>delegateURI</code></em>, <em class="parameter"><code>nextCatalog</code></em></span>. <em class="replaceable"><code>ORIG</code></em> is the original
103
+ reference to be replaced, and <em class="replaceable"><code>REPLACE</code></em>
104
+ is the <acronym class="acronym">URI</acronym> of the replacement entity to be
105
+ used. The <code class="option">--add</code> option will not overwrite
106
+ <code class="filename">CATALOGFILE</code>, outputting
107
+ to <code class="filename">stdout</code>, unless
108
+ <code class="option">--noout</code> is used. The <code class="option">--add</code> will
109
+ always take three parameters even if some of the <acronym class="acronym">XML</acronym>
110
+ catalog constructs will have only a single argument.
111
+ </p></dd><dt><span class="term"><code class="option">debug</code></span></dt><dd><p>
112
+ Print debugging statements showing the steps <span class="command"><strong>xmlcatalog</strong></span> is executing.
113
+ </p></dd><dt><span class="term"><code class="option">del <em class="replaceable"><code>VALUE(S)</code></em></code></span></dt><dd><p>
114
+ Remove the catalog entry corresponding to <em class="replaceable"><code>VALUE(S)</code></em>.
115
+ </p></dd><dt><span class="term"><code class="option">dump</code></span></dt><dd><p>Print the current catalog.</p></dd><dt><span class="term"><code class="option">exit</code></span></dt><dd><p>Quit the shell.</p></dd><dt><span class="term"><code class="option">public <em class="replaceable"><code>PUBLIC-ID</code></em></code></span></dt><dd><p>
116
+ Execute a Formal Public Identifier lookup of the catalog entry
117
+ for <em class="replaceable"><code>PUBLIC-ID</code></em>. The corresponding entry will be
118
+ output to the command line.
119
+ </p></dd><dt><span class="term"><code class="option">quiet</code></span></dt><dd><p>Stop printing debugging statements.</p></dd><dt><span class="term"><code class="option">system <em class="replaceable"><code>SYSTEM-ID</code></em></code></span></dt><dd><p>
120
+ Execute a Formal Public Identifier lookup of the catalog entry
121
+ for <em class="replaceable"><code>SYSTEM-ID</code></em>. The corresponding entry will be
122
+ output to the command line.
123
+ </p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
124
+ queries to the user's own set of catalogs. This can be done by setting
125
+ the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
126
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
127
+ An empty variable should deactivate loading the default catalog from
128
+ <code class="filename">/etc/xml/catalog</code> or, more specifically,
129
+ <code class="filename">${sysconfdir}/xml/catalog</code>.
130
+ </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
131
+ <span class="command"><strong>xmlcatalog</strong></span> return codes provide information that can be used when
132
+ calling it from scripts.
133
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Failed to remove an entry from the catalog</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Failed to save to the catalog, check file permissions</p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Failed to add an entry to the catalog</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Failed to look up an entry in the catalog</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
134
+ </p><p>
135
+ More information can be found at
136
+ </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
137
+ </p></li><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> catalog support web page
138
+ at <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support" target="_top">https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support</a>
139
+ </p></li><li class="listitem"><p>James Clark's <acronym class="acronym">SGML</acronym> catalog
140
+ page <a class="ulink" href="http://www.jclark.com/sp/catalog.htm" target="_top">http://www.jclark.com/sp/catalog.htm</a>
141
+ </p></li><li class="listitem"><p><acronym class="acronym">OASIS</acronym> <acronym class="acronym">XML</acronym> catalog specification
142
+ <a class="ulink" href="http://www.oasis-open.org/committees/entity/spec.html" target="_top">http://www.oasis-open.org/committees/entity/spec.html</a>
143
+ </p></li></ul></div><p>
144
+ </p></div></div></body></html>
local-test-libxml2-delta-01/afc-libxml2/doc/xmlcatalog.xml ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl"
3
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
5
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
6
+
7
+ <!ENTITY xmlcatalog "<command>xmlcatalog</command>">
8
+ ]>
9
+
10
+ <refentry>
11
+
12
+ <refentryinfo>
13
+ <title>xmlcatalog Manual</title>
14
+ <productname>libxml2</productname>
15
+ <copyright>
16
+ <year>2001</year>
17
+ <year>2004</year>
18
+ </copyright>
19
+ <author>
20
+ <firstname>John</firstname>
21
+ <surname>Fleck</surname>
22
+ <affiliation>
23
+ <address>
24
+ <email>jfleck@inkstain.net</email>
25
+ </address>
26
+ </affiliation>
27
+ </author>
28
+ <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
29
+ <!-- <releaseinfo>This is release 0.3 of the xmlcatalog Manual.</releaseinfo> -->
30
+ <!-- <edition>0.3</edition> -->
31
+ </refentryinfo>
32
+
33
+ <refmeta>
34
+ <refentrytitle>xmlcatalog</refentrytitle>
35
+ <manvolnum>1</manvolnum>
36
+ </refmeta>
37
+
38
+ <refnamediv>
39
+ <refname>xmlcatalog</refname>
40
+ <refpurpose>
41
+ Command line tool to parse and manipulate <acronym>XML</acronym>
42
+ or <acronym>SGML</acronym> catalog files.
43
+ </refpurpose>
44
+ </refnamediv>
45
+
46
+ <refsynopsisdiv>
47
+ <cmdsynopsis>
48
+ <command>xmlcatalog</command>
49
+ <group choice="opt">
50
+ <arg choice="plain"><option>--sgml</option></arg>
51
+ <arg choice="plain"><option>--shell</option></arg>
52
+ <arg choice="plain"><option>--convert</option></arg>
53
+ <arg choice="plain"><option>--create</option></arg>
54
+ <arg choice="plain"><option>--del <replaceable>VALUE(S)</replaceable></option></arg>
55
+ <arg choice="plain">
56
+ <group choice="opt">
57
+ <arg choice="plain">
58
+ <option>--add
59
+ <replaceable>TYPE</replaceable>
60
+ <replaceable>ORIG</replaceable>
61
+ <replaceable>REPLACE</replaceable>
62
+ </option>
63
+ </arg>
64
+ <arg choice="plain"><option>--add <replaceable>FILENAME</replaceable></option></arg>
65
+ </group>
66
+ </arg>
67
+ <arg choice="plain"><option>--noout</option></arg>
68
+ <arg choice="plain"><option>--no-super-update</option></arg>
69
+ <arg choice="plain">
70
+ <group choice="opt">
71
+ <arg choice="plain"><option>-v</option></arg>
72
+ <arg choice="plain"><option>--verbose</option></arg>
73
+ </group>
74
+ </arg>
75
+ </group>
76
+ <arg choice="req" rep="norepeat"><replaceable>CATALOGFILE</replaceable></arg>
77
+ <arg choice="req" rep="repeat"><replaceable>ENTITIES</replaceable></arg>
78
+ </cmdsynopsis>
79
+ </refsynopsisdiv>
80
+
81
+ <refsect1 id="description">
82
+ <title>DESCRIPTION</title>
83
+ <para>
84
+ &xmlcatalog; is a command line application allowing users to monitor and
85
+ manipulate <acronym>XML</acronym> and <acronym>SGML</acronym> catalogs. It
86
+ is included in <citerefentry>
87
+ <refentrytitle>libxml</refentrytitle>
88
+ <manvolnum>3</manvolnum>
89
+ </citerefentry>.
90
+ </para>
91
+ <para>
92
+ Its functions can be invoked from a single command from the command line,
93
+ or it can perform multiple functions in interactive mode. It can operate
94
+ on both <acronym>XML</acronym> and <acronym>SGML</acronym> files.
95
+ </para>
96
+ </refsect1>
97
+
98
+ <refsect1 id="options">
99
+ <title>OPTIONS</title>
100
+ <para>
101
+ &xmlcatalog; accepts the following options (in alphabetical order):
102
+ </para>
103
+
104
+ <variablelist>
105
+
106
+ <varlistentry>
107
+ <term>
108
+ <option>--add
109
+ <replaceable>TYPE</replaceable>
110
+ <replaceable>ORIG</replaceable>
111
+ <replaceable>REPLACE</replaceable>
112
+ </option>
113
+ </term>
114
+ <listitem>
115
+ <para>
116
+ Add an entry to <filename>CATALOGFILE</filename>. <replaceable>TYPE</replaceable>
117
+ indicates the type of entry. Possible types are: <simplelist type="inline">
118
+ <member><parameter>public</parameter></member>
119
+ <member><parameter>system</parameter></member>
120
+ <member><parameter>uri</parameter></member>
121
+ <member><parameter>rewriteSystem</parameter></member>
122
+ <member><parameter>rewriteURI</parameter></member>
123
+ <member><parameter>delegatePublic</parameter></member>
124
+ <member><parameter>delegateSystem</parameter></member>
125
+ <member><parameter>delegateURI</parameter></member>
126
+ <member><parameter>nextCatalog</parameter></member>
127
+ </simplelist>. <replaceable>ORIG</replaceable> is the original
128
+ reference to be replaced, and <replaceable>REPLACE</replaceable>
129
+ is the <acronym>URI</acronym> of the replacement entity to be
130
+ used. The <option>--add</option> option will not overwrite
131
+ <filename>CATALOGFILE</filename>, outputting
132
+ to <filename class="devicefile">stdout</filename>, unless
133
+ <option>--noout</option> is used. The <option>--add</option> will
134
+ always take three parameters even if some of the <acronym>XML</acronym>
135
+ catalog constructs will have only a single argument.
136
+ </para>
137
+ <!--
138
+ FIXME - Is my list of possible types correct? Are SGML types the same?
139
+ -->
140
+ </listitem>
141
+ </varlistentry>
142
+
143
+ <varlistentry>
144
+ <term><option>--add <replaceable>FILENAME</replaceable></option></term>
145
+ <listitem>
146
+ <para>
147
+ If the <option>--add</option> option is used following
148
+ the <option>--sgml</option> option, only a single argument,
149
+ a <replaceable>FILENAME</replaceable>, is used. This is used to add
150
+ the name of a catalog file to an <acronym>SGML</acronym> supercatalog,
151
+ a file that contains references to other included <acronym>SGML</acronym>
152
+ catalog files.
153
+ </para>
154
+ </listitem>
155
+ </varlistentry>
156
+
157
+ <varlistentry>
158
+ <term><option>--convert</option></term>
159
+ <listitem>
160
+ <para>
161
+ Convert SGML catalog to XML.
162
+ </para>
163
+ </listitem>
164
+ </varlistentry>
165
+
166
+ <varlistentry>
167
+ <term><option>--create</option></term>
168
+ <listitem>
169
+ <para>
170
+ Create a new <acronym>XML</acronym> catalog. Outputs
171
+ to <filename class="devicefile">stdout</filename>,
172
+ ignoring <replaceable>filename</replaceable> unless <option>--noout</option> is
173
+ used, in which case it creates a new catalog
174
+ file <replaceable>filename</replaceable>.
175
+ </para>
176
+ </listitem>
177
+ </varlistentry>
178
+
179
+ <varlistentry>
180
+ <term><option>--del <replaceable>VALUE(S)</replaceable></option></term>
181
+ <listitem>
182
+ <para>
183
+ Remove entries from <replaceable>CATALOGFILE</replaceable>
184
+ matching <replaceable>VALUE(S)</replaceable>. The <option>--del</option>
185
+ option will not overwrite <replaceable>CATALOGFILE</replaceable>,
186
+ outputting to <filename class="devicefile">stdout</filename>,
187
+ unless <option>--noout</option> is used.
188
+ </para>
189
+ </listitem>
190
+ </varlistentry>
191
+
192
+ <varlistentry>
193
+ <term><option>--noout</option></term>
194
+ <listitem>
195
+ <para>
196
+ Save output to the named file rather than outputting
197
+ to <filename class="devicefile">stdout</filename>.
198
+ </para>
199
+ </listitem>
200
+ </varlistentry>
201
+
202
+ <varlistentry>
203
+ <term><option>--no-super-update</option></term>
204
+ <listitem>
205
+ <para>
206
+ Do not update the <acronym>SGML</acronym> super catalog.
207
+ </para>
208
+ </listitem>
209
+ </varlistentry>
210
+
211
+ <varlistentry>
212
+ <term><option>--shell</option></term>
213
+ <listitem>
214
+ <para>
215
+ Run a shell allowing interactive queries on catalog
216
+ file <replaceable>CATALOGFILE</replaceable>. For the set of available
217
+ commands see <xref linkend="shell"/>.
218
+ </para>
219
+ </listitem>
220
+ </varlistentry>
221
+
222
+ <varlistentry>
223
+ <term><option>--sgml</option></term>
224
+ <listitem>
225
+ <para>
226
+ Uses <acronym>SGML</acronym> super catalogs for <option>--add</option>
227
+ and <option>--del</option> options.
228
+ </para>
229
+ </listitem>
230
+ </varlistentry>
231
+
232
+ <varlistentry>
233
+ <term><option>-v</option></term>
234
+ <term><option>--verbose</option></term>
235
+ <listitem>
236
+ <para>Output debugging information.</para>
237
+ </listitem>
238
+ </varlistentry>
239
+
240
+ </variablelist>
241
+
242
+ <para>
243
+ Invoking &xmlcatalog; non-interactively without a designated action
244
+ (imposed with options like <option>--add</option>) will result in a lookup
245
+ of the catalog entry for <replaceable>ENTITIES</replaceable> in the
246
+ catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
247
+ corresponding entries will be output to the command line. This mode of
248
+ operation, together with <option>--shell</option> mode and non-modifying
249
+ (i.e. without <option>--noout</option>) direct actions, allows for
250
+ a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
251
+ specification (possibly expressed as &quot;&quot; in the shell
252
+ environment) appointing the default system catalog. That simplifies the
253
+ handling when its exact location is irrelevant but the respective built-in
254
+ still needs to be consulted.
255
+ </para>
256
+ </refsect1>
257
+
258
+ <refsect1 id="shell">
259
+ <title>SHELL COMMANDS</title>
260
+ <para>
261
+ Invoking &xmlcatalog; with
262
+ the <option>--shell <replaceable>CATALOGFILE</replaceable></option> option opens
263
+ a command line shell allowing interactive access to the catalog file
264
+ identified by <replaceable>CATALOGFILE</replaceable>. Invoking the shell
265
+ provides a command line prompt after which the following commands (described in
266
+ alphabetical order) can be entered.
267
+ </para>
268
+
269
+ <variablelist>
270
+
271
+ <varlistentry>
272
+ <term>
273
+ <option>add
274
+ <replaceable>TYPE</replaceable>
275
+ <replaceable>ORIG</replaceable>
276
+ <replaceable>REPLACE</replaceable>
277
+ </option>
278
+ </term>
279
+ <listitem>
280
+ <para>
281
+ Add an entry to the catalog file. <replaceable>TYPE</replaceable>
282
+ indicates the type of entry. Possible types are: <simplelist type="inline">
283
+ <member><parameter>public</parameter></member>
284
+ <member><parameter>system</parameter></member>
285
+ <member><parameter>uri</parameter></member>
286
+ <member><parameter>rewriteSystem</parameter></member>
287
+ <member><parameter>rewriteURI</parameter></member>
288
+ <member><parameter>delegatePublic</parameter></member>
289
+ <member><parameter>delegateSystem</parameter></member>
290
+ <member><parameter>delegateURI</parameter></member>
291
+ <member><parameter>nextCatalog</parameter></member>
292
+ </simplelist>. <replaceable>ORIG</replaceable> is the original
293
+ reference to be replaced, and <replaceable>REPLACE</replaceable>
294
+ is the <acronym>URI</acronym> of the replacement entity to be
295
+ used. The <option>--add</option> option will not overwrite
296
+ <filename>CATALOGFILE</filename>, outputting
297
+ to <filename class="devicefile">stdout</filename>, unless
298
+ <option>--noout</option> is used. The <option>--add</option> will
299
+ always take three parameters even if some of the <acronym>XML</acronym>
300
+ catalog constructs will have only a single argument.
301
+ </para>
302
+ </listitem>
303
+ </varlistentry>
304
+
305
+ <varlistentry>
306
+ <term><option>debug</option></term>
307
+ <listitem>
308
+ <para>
309
+ Print debugging statements showing the steps &xmlcatalog; is executing.
310
+ </para>
311
+ </listitem>
312
+ </varlistentry>
313
+
314
+ <varlistentry>
315
+ <term><option>del <replaceable>VALUE(S)</replaceable></option></term>
316
+ <listitem>
317
+ <para>
318
+ Remove the catalog entry corresponding to <replaceable>VALUE(S)</replaceable>.
319
+ </para>
320
+ </listitem>
321
+ </varlistentry>
322
+
323
+ <varlistentry>
324
+ <term><option>dump</option></term>
325
+ <listitem>
326
+ <para>Print the current catalog.</para>
327
+ </listitem>
328
+ </varlistentry>
329
+
330
+ <varlistentry>
331
+ <term><option>exit</option></term>
332
+ <listitem>
333
+ <para>Quit the shell.</para>
334
+ </listitem>
335
+ </varlistentry>
336
+
337
+ <varlistentry>
338
+ <term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
339
+ <listitem>
340
+ <para>
341
+ Execute a Formal Public Identifier lookup of the catalog entry
342
+ for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
343
+ output to the command line.
344
+ </para>
345
+ </listitem>
346
+ </varlistentry>
347
+
348
+ <varlistentry>
349
+ <term><option>quiet</option></term>
350
+ <listitem>
351
+ <para>Stop printing debugging statements.</para>
352
+ </listitem>
353
+ </varlistentry>
354
+
355
+ <varlistentry>
356
+ <term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
357
+ <listitem>
358
+ <para>
359
+ Execute a Formal Public Identifier lookup of the catalog entry
360
+ for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
361
+ output to the command line.
362
+ </para>
363
+ </listitem>
364
+ </varlistentry>
365
+
366
+ </variablelist>
367
+ </refsect1>
368
+
369
+ <refsect1 id="environment">
370
+ <title>ENVIRONMENT</title>
371
+ <variablelist>
372
+
373
+ <varlistentry>
374
+ <term><envar>XML_CATALOG_FILES</envar></term>
375
+ <listitem>
376
+ <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
377
+ queries to the user's own set of catalogs. This can be done by setting
378
+ the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
379
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
380
+ An empty variable should deactivate loading the default catalog from
381
+ <filename>/etc/xml/catalog</filename> or, more specifically,
382
+ <filename>${sysconfdir}/xml/catalog</filename>.
383
+ </para>
384
+ </listitem>
385
+ </varlistentry>
386
+
387
+ </variablelist>
388
+ </refsect1>
389
+
390
+ <refsect1 id="diagnostics">
391
+ <title>DIAGNOSTICS</title>
392
+ <para>
393
+ &xmlcatalog; return codes provide information that can be used when
394
+ calling it from scripts.
395
+ </para>
396
+ <variablelist>
397
+
398
+ <varlistentry>
399
+ <term><errorcode>0</errorcode></term>
400
+ <listitem>
401
+ <para>No error</para>
402
+ </listitem>
403
+ </varlistentry>
404
+
405
+ <varlistentry>
406
+ <term><errorcode>1</errorcode></term>
407
+ <listitem>
408
+ <para>Failed to remove an entry from the catalog</para>
409
+ </listitem>
410
+ </varlistentry>
411
+
412
+ <varlistentry>
413
+ <term><errorcode>2</errorcode></term>
414
+ <listitem>
415
+ <para>Failed to save to the catalog, check file permissions</para>
416
+ </listitem>
417
+ </varlistentry>
418
+
419
+ <varlistentry>
420
+ <term><errorcode>3</errorcode></term>
421
+ <listitem>
422
+ <para>Failed to add an entry to the catalog</para>
423
+ </listitem>
424
+ </varlistentry>
425
+
426
+ <varlistentry>
427
+ <term><errorcode>4</errorcode></term>
428
+ <listitem>
429
+ <para>Failed to look up an entry in the catalog</para>
430
+ </listitem>
431
+ </varlistentry>
432
+
433
+ </variablelist>
434
+ </refsect1>
435
+
436
+ <refsect1 id="seealso">
437
+ <title>SEE ALSO</title>
438
+ <para><citerefentry>
439
+ <refentrytitle>libxml</refentrytitle>
440
+ <manvolnum>3</manvolnum>
441
+ </citerefentry>
442
+ </para>
443
+ <para>
444
+ More information can be found at
445
+ <itemizedlist>
446
+ <listitem>
447
+ <para><citerefentry>
448
+ <refentrytitle>libxml</refentrytitle>
449
+ <manvolnum>3</manvolnum>
450
+ </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
451
+ </para>
452
+ </listitem>
453
+ <listitem>
454
+ <para><citerefentry>
455
+ <refentrytitle>libxml</refentrytitle>
456
+ <manvolnum>3</manvolnum>
457
+ </citerefentry> catalog support web page
458
+ at <ulink url="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support"/>
459
+ </para>
460
+ </listitem>
461
+ <listitem>
462
+ <para>James Clark's <acronym>SGML</acronym> catalog
463
+ page <ulink url="http://www.jclark.com/sp/catalog.htm"/>
464
+ </para>
465
+ </listitem>
466
+ <listitem>
467
+ <para><acronym>OASIS</acronym> <acronym>XML</acronym> catalog specification
468
+ <ulink url="http://www.oasis-open.org/committees/entity/spec.html"/>
469
+ </para>
470
+ </listitem>
471
+ </itemizedlist>
472
+ </para>
473
+ </refsect1>
474
+
475
+ </refentry>
local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.1 ADDED
@@ -0,0 +1,642 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '\" t
2
+ .\" Title: xmllint
3
+ .\" Author: John Fleck <jfleck@inkstain.net>
4
+ .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5
+ .\" Date: 06/12/2024
6
+ .\" Manual: xmllint Manual
7
+ .\" Source: libxml2
8
+ .\" Language: English
9
+ .\"
10
+ .TH "XMLLINT" "1" "06/12/2024" "libxml2" "xmllint Manual"
11
+ .\" -----------------------------------------------------------------
12
+ .\" * Define some portability stuff
13
+ .\" -----------------------------------------------------------------
14
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ .\" http://bugs.debian.org/507673
16
+ .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
+ .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
+ .ie \n(.g .ds Aq \(aq
19
+ .el .ds Aq '
20
+ .\" -----------------------------------------------------------------
21
+ .\" * set default formatting
22
+ .\" -----------------------------------------------------------------
23
+ .\" disable hyphenation
24
+ .nh
25
+ .\" disable justification (adjust text to left margin only)
26
+ .ad l
27
+ .\" -----------------------------------------------------------------
28
+ .\" * MAIN CONTENT STARTS HERE *
29
+ .\" -----------------------------------------------------------------
30
+ .SH "NAME"
31
+ xmllint \- command line XML tool
32
+ .SH "SYNOPSIS"
33
+ .HP \w'\fBxmllint\fR\ 'u
34
+ \fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-quiet\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-nodict\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-max\-ampl\ \fR\fB\fIINTEGER\fR\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR | \fB\-\-pedantic\fR] {\fIXML\-FILE(S)\fR... | \-}
35
+ .HP \w'\fBxmllint\fR\ 'u
36
+ \fBxmllint\fR \fB\-\-help\fR
37
+ .SH "DESCRIPTION"
38
+ .PP
39
+ The
40
+ \fBxmllint\fR
41
+ program parses one or more
42
+ XML
43
+ files, specified on the command line as
44
+ \fIXML\-FILE\fR
45
+ (or the standard input if the filename provided is
46
+ \fB\-\fR
47
+ )\&. It prints various types of output, depending upon the options selected\&. It is useful for detecting errors both in
48
+ XML
49
+ code and in the
50
+ XML
51
+ parser itself\&.
52
+ .PP
53
+ \fBxmllint\fR
54
+ is included in
55
+ \fBlibxml\fR(3)\&.
56
+ .SH "OPTIONS"
57
+ .PP
58
+ \fBxmllint\fR
59
+ accepts the following options (in alphabetical order):
60
+ .PP
61
+ \fB\-\-auto\fR
62
+ .RS 4
63
+ Generate a small document for testing purposes\&.
64
+ .RE
65
+ .PP
66
+ \fB\-\-catalogs\fR
67
+ .RS 4
68
+ Use the
69
+ SGML
70
+ catalog(s) from
71
+ \fBSGML_CATALOG_FILES\fR\&. Otherwise
72
+ XML
73
+ catalogs starting from
74
+ /etc/xml/catalog
75
+ or, more specifically,
76
+ ${sysconfdir}/xml/catalog
77
+ are used by default\&.
78
+ .RE
79
+ .PP
80
+ \fB\-\-compress\fR
81
+ .RS 4
82
+ Turn on
83
+ \fBgzip\fR(1)
84
+ compression of output\&.
85
+ .RE
86
+ .PP
87
+ \fB\-\-copy\fR
88
+ .RS 4
89
+ Test the internal copy implementation\&.
90
+ .RE
91
+ .PP
92
+ \fB\-\-c14n\fR
93
+ .RS 4
94
+ Use the W3C
95
+ XML
96
+ Canonicalisation (C14N) to serialize the result of parsing to
97
+ stdout\&. It keeps comments in the result\&.
98
+ .RE
99
+ .PP
100
+ \fB\-\-dtdvalid \fR\fB\fIURL\fR\fR
101
+ .RS 4
102
+ Use the
103
+ DTD
104
+ specified by an
105
+ \fIURL\fR
106
+ for validation\&.
107
+ .RE
108
+ .PP
109
+ \fB\-\-dtdvalidfpi \fR\fB\fIFPI\fR\fR
110
+ .RS 4
111
+ Use the
112
+ DTD
113
+ specified by a Formal Public Identifier
114
+ \fIFPI\fR
115
+ for validation, note that this will require a catalog exporting that Formal Public Identifier to work\&.
116
+ .RE
117
+ .PP
118
+ \fB\-\-debug\fR
119
+ .RS 4
120
+ Parse a file and output an annotated tree of the in\-memory version of the document\&.
121
+ .RE
122
+ .PP
123
+ \fB\-\-debugent\fR
124
+ .RS 4
125
+ Debug the entities defined in the document\&.
126
+ .RE
127
+ .PP
128
+ \fB\-\-dropdtd\fR
129
+ .RS 4
130
+ Remove
131
+ DTD
132
+ from output\&.
133
+ .RE
134
+ .PP
135
+ \fB\-\-dtdattr\fR
136
+ .RS 4
137
+ Fetch external
138
+ DTD
139
+ and populate the tree with inherited attributes\&.
140
+ .RE
141
+ .PP
142
+ \fB\-\-encode \fR\fB\fIENCODING\fR\fR
143
+ .RS 4
144
+ Output in the given encoding\&. Note that this works for full document not fragments or result from XPath queries\&.
145
+ .RE
146
+ .PP
147
+ \fB\-\-format\fR
148
+ .RS 4
149
+ Reformat and reindent the output\&. The
150
+ \fBXMLLINT_INDENT\fR
151
+ environment variable controls the indentation\&. The default value is two spaces " ")\&.
152
+ .RE
153
+ .PP
154
+ \fB\-\-help\fR
155
+ .RS 4
156
+ Print out a short usage summary for
157
+ \fBxmllint\fR\&.
158
+ .RE
159
+ .PP
160
+ \fB\-\-html\fR
161
+ .RS 4
162
+ Use the
163
+ HTML
164
+ parser\&.
165
+ .RE
166
+ .PP
167
+ \fB\-\-htmlout\fR
168
+ .RS 4
169
+ Output results as an
170
+ HTML
171
+ file\&. This causes
172
+ \fBxmllint\fR
173
+ to output the necessary
174
+ HTML
175
+ tags surrounding the result tree output so the results can be displayed/viewed in a browser\&.
176
+ .RE
177
+ .PP
178
+ \fB\-\-insert\fR
179
+ .RS 4
180
+ Test for valid insertions\&.
181
+ .RE
182
+ .PP
183
+ \fB\-\-loaddtd\fR
184
+ .RS 4
185
+ Fetch an external
186
+ DTD\&.
187
+ .RE
188
+ .PP
189
+ \fB\-\-load\-trace\fR
190
+ .RS 4
191
+ Display all the documents loaded during the processing to
192
+ stderr\&.
193
+ .RE
194
+ .PP
195
+ \fB\-\-max\-ampl \fR\fB\fIINTEGER\fR\fR
196
+ .RS 4
197
+ Set the maximum amplification factor which protects against exponential entity expansion ("billion laughs")\&. The default value is 5\&. Documents making heavy use of entity expansion may require a higher value\&.
198
+ .RE
199
+ .PP
200
+ \fB\-\-maxmem \fR\fB\fINNBYTES\fR\fR
201
+ .RS 4
202
+ Test the parser memory support\&.
203
+ \fINNBYTES\fR
204
+ is the maximum number of bytes the library is allowed to allocate\&. This can also be used to make sure batch processing of
205
+ XML
206
+ files will not exhaust the virtual memory of the server running them\&.
207
+ .RE
208
+ .PP
209
+ \fB\-\-memory\fR
210
+ .RS 4
211
+ Parse from memory\&.
212
+ .RE
213
+ .PP
214
+ \fB\-\-noblanks\fR
215
+ .RS 4
216
+ Drop ignorable blank spaces\&.
217
+ .RE
218
+ .PP
219
+ \fB\-\-nocatalogs\fR
220
+ .RS 4
221
+ Do not use any catalogs\&.
222
+ .RE
223
+ .PP
224
+ \fB\-\-nocdata\fR
225
+ .RS 4
226
+ Substitute CDATA section by equivalent text nodes\&.
227
+ .RE
228
+ .PP
229
+ \fB\-\-nodict\fR
230
+ .RS 4
231
+ Don\*(Aqt use dictionaries (parser option XML_PARSE_NODICT)\&. Only for debugging\&.
232
+ .RE
233
+ .PP
234
+ \fB\-\-noent\fR
235
+ .RS 4
236
+ Substitute entity values for entity references\&. By default,
237
+ \fBxmllint\fR
238
+ leaves entity references in place\&.
239
+ .RE
240
+ .PP
241
+ \fB\-\-nonet\fR
242
+ .RS 4
243
+ Do not use the Internet to fetch
244
+ DTDs or entities\&.
245
+ .RE
246
+ .PP
247
+ \fB\-\-noout\fR
248
+ .RS 4
249
+ Suppress output\&. By default,
250
+ \fBxmllint\fR
251
+ outputs the result tree\&.
252
+ .RE
253
+ .PP
254
+ \fB\-\-nowarning\fR
255
+ .RS 4
256
+ Do not emit warnings from the parser and/or validator\&.
257
+ .RE
258
+ .PP
259
+ \fB\-\-nowrap\fR
260
+ .RS 4
261
+ Do not output
262
+ HTML
263
+ doc wrapper\&.
264
+ .RE
265
+ .PP
266
+ \fB\-\-noxincludenode\fR
267
+ .RS 4
268
+ Do XInclude processing but do not generate XInclude start and end nodes\&.
269
+ .RE
270
+ .PP
271
+ \fB\-\-nsclean\fR
272
+ .RS 4
273
+ Remove redundant namespace declarations\&.
274
+ .RE
275
+ .PP
276
+ \fB\-\-output \fR\fB\fIFILE\fR\fR
277
+ .RS 4
278
+ Define a file path where
279
+ \fBxmllint\fR
280
+ will save the result of parsing\&. Usually the programs build a tree and save it on
281
+ stdout, with this option the result
282
+ XML
283
+ instance will be saved onto a file\&.
284
+ .RE
285
+ .PP
286
+ \fB\-\-path "\fR\fB\fIPATH(S)\fR\fR\fB"\fR
287
+ .RS 4
288
+ Use the (space\- or colon\-separated) list of filesystem paths specified by
289
+ \fIPATHS\fR
290
+ to load
291
+ DTDs or entities\&. Enclose space\-separated lists by quotation marks\&.
292
+ .RE
293
+ .PP
294
+ \fB\-\-pattern \fR\fB\fIPATTERNVALUE\fR\fR
295
+ .RS 4
296
+ Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser\&. It allows to select some nodes in the document based on an XPath (subset) expression\&. Used for debugging\&.
297
+ .RE
298
+ .PP
299
+ \fB\-\-pedantic\fR
300
+ .RS 4
301
+ Enable additional warnings\&.
302
+ .RE
303
+ .PP
304
+ \fB\-\-postvalid\fR
305
+ .RS 4
306
+ Validate after parsing has completed\&.
307
+ .RE
308
+ .PP
309
+ \fB\-\-push\fR
310
+ .RS 4
311
+ Use the push mode of the parser\&.
312
+ .RE
313
+ .PP
314
+ \fB\-\-quiet\fR
315
+ .RS 4
316
+ Don\*(Aqt print informational messages to stderr\&.
317
+ .RE
318
+ .PP
319
+ \fB\-\-recover\fR
320
+ .RS 4
321
+ Output any parsable portions of an invalid document\&.
322
+ .RE
323
+ .PP
324
+ \fB\-\-relaxng \fR\fB\fISCHEMA\fR\fR
325
+ .RS 4
326
+ Use RelaxNG file named
327
+ \fISCHEMA\fR
328
+ for validation\&.
329
+ .RE
330
+ .PP
331
+ \fB\-\-repeat\fR
332
+ .RS 4
333
+ Repeat 100 times, for timing or profiling\&.
334
+ .RE
335
+ .PP
336
+ \fB\-\-schema \fR\fB\fISCHEMA\fR\fR
337
+ .RS 4
338
+ Use a W3C
339
+ XML
340
+ Schema file named
341
+ \fISCHEMA\fR
342
+ for validation\&.
343
+ .RE
344
+ .PP
345
+ \fB\-\-shell\fR
346
+ .RS 4
347
+ Run a navigating shell\&. Details on available commands in shell mode are below (see
348
+ the section called \(lqSHELL COMMANDS\(rq)\&.
349
+ .RE
350
+ .PP
351
+ \fB\-\-xpath "\fR\fB\fIXPath_expression\fR\fR\fB"\fR
352
+ .RS 4
353
+ Run an XPath expression given as argument and print the result\&. In case of a nodeset result, each node in the node set is serialized in full in the output\&. In case of an empty node set the "XPath set is empty" result will be shown and exit code 11 will be returned\&.\&. This feature is EXPERIMENTAL\&. Implementation details can change without futher notice\&.
354
+ .RE
355
+ .PP
356
+ \fB\-\-stream\fR
357
+ .RS 4
358
+ Use streaming
359
+ API
360
+ \- useful when used in combination with
361
+ \fB\-\-relaxng\fR
362
+ or
363
+ \fB\-\-valid\fR
364
+ options for validation of files that are too large to be held in memory\&.
365
+ .RE
366
+ .PP
367
+ \fB\-\-testIO\fR
368
+ .RS 4
369
+ Test user input/output support\&.
370
+ .RE
371
+ .PP
372
+ \fB\-\-timing\fR
373
+ .RS 4
374
+ Output information about the time it takes
375
+ \fBxmllint\fR
376
+ to perform the various steps\&.
377
+ .RE
378
+ .PP
379
+ \fB\-\-valid\fR
380
+ .RS 4
381
+ Determine if the document is a valid instance of the included Document Type Definition (DTD)\&. A
382
+ DTD
383
+ to be validated against also can be specified at the command line using the
384
+ \fB\-\-dtdvalid\fR
385
+ option\&. By default,
386
+ \fBxmllint\fR
387
+ also checks to determine if the document is well\-formed\&.
388
+ .RE
389
+ .PP
390
+ \fB\-\-version\fR
391
+ .RS 4
392
+ Display the version of
393
+ \fBlibxml\fR(3)
394
+ used\&.
395
+ .RE
396
+ .PP
397
+ \fB\-\-walker\fR
398
+ .RS 4
399
+ Test the walker module, which is a reader interface but for a document tree, instead of using the reader
400
+ API
401
+ on an unparsed document it works on an existing in\-memory tree\&. Used for debugging\&.
402
+ .RE
403
+ .PP
404
+ \fB\-\-xinclude\fR
405
+ .RS 4
406
+ Do XInclude processing\&.
407
+ .RE
408
+ .PP
409
+ \fB\-\-xmlout\fR
410
+ .RS 4
411
+ Used in conjunction with
412
+ \fB\-\-html\fR\&. Usually when
413
+ HTML
414
+ is parsed the document is saved with the
415
+ HTML
416
+ serializer\&. But with this option the resulting document is saved with the
417
+ XML
418
+ serializer\&. This is primarily used to generate
419
+ XHTML
420
+ from
421
+ HTML
422
+ input\&.
423
+ .RE
424
+ .SH "SHELL COMMANDS"
425
+ .PP
426
+ \fBxmllint\fR
427
+ offers an interactive shell mode invoked with the
428
+ \fB\-\-shell\fR
429
+ command\&. Available commands in shell mode include (in alphabetical order):
430
+ .PP
431
+ \fBbase\fR
432
+ .RS 4
433
+ Display
434
+ XML
435
+ base of the node\&.
436
+ .RE
437
+ .PP
438
+ \fBbye\fR
439
+ .RS 4
440
+ Leave the shell\&.
441
+ .RE
442
+ .PP
443
+ \fBcat \fR\fB\fINODE\fR\fR
444
+ .RS 4
445
+ Display the given node or the current one\&.
446
+ .RE
447
+ .PP
448
+ \fBcd \fR\fB\fIPATH\fR\fR
449
+ .RS 4
450
+ Change the current node to the given path (if unique) or root if no argument is given\&.
451
+ .RE
452
+ .PP
453
+ \fBdir \fR\fB\fIPATH\fR\fR
454
+ .RS 4
455
+ Dumps information about the node (namespace, attributes, content)\&.
456
+ .RE
457
+ .PP
458
+ \fBdu \fR\fB\fIPATH\fR\fR
459
+ .RS 4
460
+ Show the structure of the subtree under the given path or the current node\&.
461
+ .RE
462
+ .PP
463
+ \fBexit\fR
464
+ .RS 4
465
+ Leave the shell\&.
466
+ .RE
467
+ .PP
468
+ \fBhelp\fR
469
+ .RS 4
470
+ Show this help\&.
471
+ .RE
472
+ .PP
473
+ \fBload \fR\fB\fIFILENAME\fR\fR
474
+ .RS 4
475
+ Load a new document with the given filename\&.
476
+ .RE
477
+ .PP
478
+ \fBls \fR\fB\fIPATH\fR\fR
479
+ .RS 4
480
+ List contents of the given path or the current directory\&.
481
+ .RE
482
+ .PP
483
+ \fBpwd\fR
484
+ .RS 4
485
+ Display the path to the current node\&.
486
+ .RE
487
+ .PP
488
+ \fBquit\fR
489
+ .RS 4
490
+ Leave the shell\&.
491
+ .RE
492
+ .PP
493
+ \fBsave \fR\fB\fIFILENAME\fR\fR
494
+ .RS 4
495
+ Save the current document to the given filename or to the original name\&.
496
+ .RE
497
+ .PP
498
+ \fBvalidate\fR
499
+ .RS 4
500
+ Check the document for errors\&.
501
+ .RE
502
+ .PP
503
+ \fBwrite \fR\fB\fIFILENAME\fR\fR
504
+ .RS 4
505
+ Write the current node to the given filename\&.
506
+ .RE
507
+ .SH "ENVIRONMENT"
508
+ .PP
509
+ \fBSGML_CATALOG_FILES\fR
510
+ .RS 4
511
+ SGML
512
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
513
+ \fBSGML_CATALOG_FILES\fR
514
+ environment variable to a list of catalogs\&. An empty one should deactivate loading the default catalog\&.
515
+ .RE
516
+ .PP
517
+ \fBXML_CATALOG_FILES\fR
518
+ .RS 4
519
+ XML
520
+ catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
521
+ \fBXML_CATALOG_FILES\fR
522
+ environment variable to a space\-separated list of catalogs\&. Use percent\-encoding to escape spaces or other characters\&. An empty variable should deactivate loading the default catalog\&.
523
+ .RE
524
+ .PP
525
+ \fBXML_DEBUG_CATALOG\fR
526
+ .RS 4
527
+ Setting the environment variable
528
+ \fBXML_DEBUG_CATALOG\fR
529
+ to
530
+ \fInon\-zero\fR
531
+ using the
532
+ \fBexport\fR
533
+ command outputs debugging information related to catalog operations\&.
534
+ .RE
535
+ .PP
536
+ \fBXMLLINT_INDENT\fR
537
+ .RS 4
538
+ Setting the environment variable
539
+ \fBXMLLINT_INDENT\fR
540
+ controls the indentation\&. The default value is two spaces " "\&.
541
+ .RE
542
+ .SH "DIAGNOSTICS"
543
+ .PP
544
+ \fBxmllint\fR
545
+ return codes provide information that can be used when calling it from scripts\&.
546
+ .PP
547
+ \fB0\fR
548
+ .RS 4
549
+ No error
550
+ .RE
551
+ .PP
552
+ \fB1\fR
553
+ .RS 4
554
+ Unclassified
555
+ .RE
556
+ .PP
557
+ \fB2\fR
558
+ .RS 4
559
+ Error in
560
+ DTD
561
+ .RE
562
+ .PP
563
+ \fB3\fR
564
+ .RS 4
565
+ Validation error
566
+ .RE
567
+ .PP
568
+ \fB4\fR
569
+ .RS 4
570
+ Validation error
571
+ .RE
572
+ .PP
573
+ \fB5\fR
574
+ .RS 4
575
+ Error in schema compilation
576
+ .RE
577
+ .PP
578
+ \fB6\fR
579
+ .RS 4
580
+ Error writing output
581
+ .RE
582
+ .PP
583
+ \fB7\fR
584
+ .RS 4
585
+ Error in pattern (generated when
586
+ \fB\-\-pattern\fR
587
+ option is used)
588
+ .RE
589
+ .PP
590
+ \fB9\fR
591
+ .RS 4
592
+ Out of memory error
593
+ .RE
594
+ .PP
595
+ \fB10\fR
596
+ .RS 4
597
+ XPath evaluation error
598
+ .RE
599
+ .PP
600
+ \fB11\fR
601
+ .RS 4
602
+ XPath result is empty
603
+ .RE
604
+ .SH "SEE ALSO"
605
+ .PP
606
+ \fBlibxml\fR(3)
607
+ .PP
608
+ More information can be found at
609
+ .sp
610
+ .RS 4
611
+ .ie n \{\
612
+ \h'-04'\(bu\h'+03'\c
613
+ .\}
614
+ .el \{\
615
+ .sp -1
616
+ .IP \(bu 2.3
617
+ .\}
618
+ \fBlibxml\fR(3)
619
+ web page
620
+ \m[blue]\fB\%https://gitlab.gnome.org/GNOME/libxml2\fR\m[]
621
+ .RE
622
+ .sp
623
+ .SH "AUTHORS"
624
+ .PP
625
+ \fBJohn Fleck\fR <\&jfleck@inkstain\&.net\&>
626
+ .RS 4
627
+ Author.
628
+ .RE
629
+ .PP
630
+ \fBZiying Sherwin\fR <\&sherwin@nlm\&.nih\&.gov\&>
631
+ .RS 4
632
+ Author.
633
+ .RE
634
+ .PP
635
+ \fBHeiko Rupp\fR <\&hwr@pilhuhn\&.de\&>
636
+ .RS 4
637
+ Author.
638
+ .RE
639
+ .SH "COPYRIGHT"
640
+ .br
641
+ Copyright \(co 2001, 2004
642
+ .br
local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.html ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint &#8212; command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code> [ <code class="option">--version</code> | <code class="option">--debug</code> | <code class="option">--quiet</code> | <code class="option">--shell</code> | <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code> | <code class="option">--debugent</code> | <code class="option">--copy</code> | <code class="option">--recover</code> | <code class="option">--nodict</code> | <code class="option">--noent</code> | <code class="option">--noout</code> | <code class="option">--nonet</code> | <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code> | <code class="option">--load-trace</code> | <code class="option">--htmlout</code> | <code class="option">--nowrap</code> | <code class="option">--valid</code> | <code class="option">--postvalid</code> | <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code> | <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code> | <code class="option">--timing</code> | <code class="option">--output <em class="replaceable"><code>FILE</code></em></code> | <code class="option">--repeat</code> | <code class="option">--insert</code> | <code class="option">--compress</code> | <code class="option">--html</code> | <code class="option">--xmlout</code> | <code class="option">--push</code> | <code class="option">--memory</code> | <code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code> | <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code> | <code class="option">--nowarning</code> | <code class="option">--noblanks</code> | <code class="option">--nocdata</code> | <code class="option">--format</code> | <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code> | <code class="option">--dropdtd</code> | <code class="option">--nsclean</code> | <code class="option">--testIO</code> | <code class="option">--catalogs</code> | <code class="option">--nocatalogs</code> | <code class="option">--auto</code> | <code class="option">--xinclude</code> | <code class="option">--noxincludenode</code> | <code class="option">--loaddtd</code> | <code class="option">--dtdattr</code> | <code class="option">--stream</code> | <code class="option">--walker</code> | <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code> | <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--c14n</code> | <code class="option">--pedantic</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>... | - }</p></div><div class="cmdsynopsis"><p><code class="command">xmllint</code> <code class="option">--help</code> </p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
2
+ The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
3
+ specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
4
+ (or the standard input if the filename provided
5
+ is <span class="bold"><strong>-</strong></span> ). It prints various types of
6
+ output, depending upon the options selected. It is useful for detecting
7
+ errors both in <acronym class="acronym">XML</acronym> code and in
8
+ the <acronym class="acronym">XML</acronym> parser itself.
9
+ </p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
10
+ <span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
11
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
12
+ Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
13
+ Otherwise <acronym class="acronym">XML</acronym> catalogs starting
14
+ from <code class="filename">/etc/xml/catalog</code> or, more specifically,
15
+ <code class="filename">${sysconfdir}/xml/catalog</code> are used by default.
16
+ </p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
17
+ Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
18
+ </p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code></span></dt><dd><p>
19
+ Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
20
+ serialize the result of parsing to <code class="filename">stdout</code>.
21
+ It keeps comments in the result.
22
+ </p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
23
+ Use the <acronym class="acronym">DTD</acronym> specified by
24
+ an <em class="replaceable"><code>URL</code></em> for validation.
25
+ </p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
26
+ Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
27
+ Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
28
+ will require a catalog exporting that Formal Public Identifier to work.
29
+ </p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
30
+ Parse a file and output an annotated tree of the
31
+ in-memory version of the document.
32
+ </p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
33
+ Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
34
+ inherited attributes.
35
+ </p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
36
+ Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
37
+ environment variable controls the indentation. The default value is two
38
+ spaces " ").
39
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd><p>Print out a short usage summary for <span class="command"><strong>xmllint</strong></span>.</p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
40
+ Output results as an <acronym class="acronym">HTML</acronym> file. This
41
+ causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
42
+ tags surrounding the result tree output so the results can be
43
+ displayed/viewed in a browser.
44
+ </p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
45
+ Display all the documents loaded during the processing
46
+ to <code class="filename">stderr</code>.
47
+ </p></dd><dt><span class="term"><code class="option">--max-ampl <em class="replaceable"><code>INTEGER</code></em></code></span></dt><dd><p>
48
+ Set the maximum amplification factor which protects against
49
+ exponential entity expansion ("billion laughs"). The default value
50
+ is 5. Documents making heavy use of entity expansion may require a
51
+ higher value.
52
+ </p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
53
+ Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
54
+ is the maximum number of bytes the library is allowed to allocate.
55
+ This can also be used to make sure batch processing
56
+ of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
57
+ of the server running them.
58
+ </p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--nodict</code></span></dt><dd><p>
59
+ Don't use dictionaries (parser option XML_PARSE_NODICT).
60
+ Only for debugging.
61
+ </p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
62
+ Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
63
+ leaves entity references in place.
64
+ </p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
65
+ Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
66
+ </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
67
+ Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
68
+ </p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
69
+ Do XInclude processing but do not generate XInclude start and end nodes.
70
+ </p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
71
+ Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
72
+ Usually the programs build a tree and save it
73
+ on <code class="filename">stdout</code>, with this option
74
+ the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
75
+ </p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
76
+ Use the (space- or colon-separated) list of filesystem paths specified
77
+ by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
78
+ entities. Enclose space-separated lists by quotation marks.
79
+ </p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
80
+ Used to exercise the pattern recognition engine, which can be used
81
+ with the reader interface to the parser. It allows to select some
82
+ nodes in the document based on an XPath (subset) expression. Used
83
+ for debugging.
84
+ </p></dd><dt><span class="term"><code class="option">--pedantic</code></span></dt><dd><p>Enable additional warnings.</p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--quiet</code></span></dt><dd><p>Don't print informational messages to stderr.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
85
+ Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
86
+ for validation.
87
+ </p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
88
+ Use a W3C <acronym class="acronym">XML</acronym> Schema file
89
+ named <em class="replaceable"><code>SCHEMA</code></em> for validation.
90
+ </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
91
+ Run a navigating shell. Details on available commands in shell mode
92
+ are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called &#8220;SHELL COMMANDS&#8221;</a>).
93
+ </p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
94
+ Run an XPath expression given as argument and print the
95
+ result. In case of a nodeset result, each node in the
96
+ node set is serialized in full in the output. In case
97
+ of an empty node set the "XPath set is empty" result
98
+ will be shown and exit code 11 will be returned..
99
+ This feature is EXPERIMENTAL. Implementation details can
100
+ change without futher notice.
101
+ </p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
102
+ Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
103
+ with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
104
+ for validation of files that are too large to be held in memory.
105
+ </p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
106
+ Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
107
+ various steps.
108
+ </p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
109
+ Determine if the document is a valid instance of the included
110
+ Document Type Definition (<acronym class="acronym">DTD</acronym>).
111
+ A <acronym class="acronym">DTD</acronym> to be validated against also can be
112
+ specified at the command line using the <code class="option">--dtdvalid</code>
113
+ option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
114
+ document is well-formed.
115
+ </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
116
+ Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
117
+ </p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
118
+ Test the walker module, which is a reader interface but for a
119
+ document tree, instead of using the reader <acronym class="acronym">API</acronym> on
120
+ an unparsed document it works on an existing in-memory tree. Used for
121
+ debugging.
122
+ </p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
123
+ Used in conjunction with <code class="option">--html</code>. Usually
124
+ when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
125
+ the <acronym class="acronym">HTML</acronym> serializer. But with this option the
126
+ resulting document is saved with the <acronym class="acronym">XML</acronym>
127
+ serializer. This is primarily used to
128
+ generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
129
+ </p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
130
+ <span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
131
+ the <code class="option">--shell</code> command. Available commands in shell mode
132
+ include (in alphabetical order):
133
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
134
+ Change the current node to the given path (if unique) or root if no
135
+ argument is given.
136
+ </p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
137
+ Dumps information about the node (namespace, attributes, content).
138
+ </p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
139
+ Show the structure of the subtree under the given path or the current node.
140
+ </p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
141
+ Save the current document to the given filename or to the original name.
142
+ </p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
143
+ queries to the user's own set of catalogs. This can be done by setting
144
+ the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
145
+ of catalogs. An empty one should deactivate loading the
146
+ default catalog.
147
+ </p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
148
+ queries to the user's own set of catalogs. This can be done by setting
149
+ the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
150
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
151
+ An empty variable should deactivate loading the default catalog.
152
+ </p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
153
+ to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
154
+ command outputs debugging information related to catalog operations.
155
+ </p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
156
+ controls the indentation. The default value is two spaces " ".
157
+ </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
158
+ <span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
159
+ calling it from scripts.
160
+ </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
161
+ Error in pattern (generated when <code class="option">--pattern</code> option is used)
162
+ </p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd><dt><span class="term"><span class="errorcode">10</span></span></dt><dd><p>XPath evaluation error</p></dd><dt><span class="term"><span class="errorcode">11</span></span></dt><dd><p>XPath result is empty</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
163
+ </p><p>
164
+ More information can be found at
165
+ </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
166
+ </p></li></ul></div><p>
167
+ </p></div></div></body></html>
local-test-libxml2-delta-01/afc-libxml2/doc/xmllint.xml ADDED
@@ -0,0 +1,1045 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl"
3
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
5
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
6
+
7
+ <!ENTITY xmllint "<command>xmllint</command>">
8
+ ]>
9
+
10
+ <refentry>
11
+
12
+ <refentryinfo>
13
+ <title>xmllint Manual</title>
14
+ <productname>libxml2</productname>
15
+ <copyright>
16
+ <year>2001</year>
17
+ <year>2004</year>
18
+ </copyright>
19
+ <authorgroup>
20
+ <author>
21
+ <firstname>John</firstname>
22
+ <surname>Fleck</surname>
23
+ <affiliation>
24
+ <address>
25
+ <email>jfleck@inkstain.net</email>
26
+ </address>
27
+ </affiliation>
28
+ </author>
29
+ <author>
30
+ <firstname>Ziying</firstname>
31
+ <surname>Sherwin</surname>
32
+ <affiliation>
33
+ <address>
34
+ <email>sherwin@nlm.nih.gov</email>
35
+ </address>
36
+ </affiliation>
37
+ </author>
38
+ <author>
39
+ <firstname>Heiko</firstname>
40
+ <surname>Rupp</surname>
41
+ <affiliation>
42
+ <address>
43
+ <email>hwr@pilhuhn.de</email>
44
+ </address>
45
+ </affiliation>
46
+ </author>
47
+ </authorgroup>
48
+ <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
49
+ <!-- <releaseinfo>This is release 0.5 of the xmllint Manual.</releaseinfo> -->
50
+ <!-- <edition>0.5</edition> -->
51
+ </refentryinfo>
52
+
53
+ <refmeta>
54
+ <refentrytitle>xmllint</refentrytitle>
55
+ <manvolnum>1</manvolnum>
56
+ </refmeta>
57
+
58
+ <refnamediv>
59
+ <refname>xmllint</refname>
60
+ <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
61
+ </refnamediv>
62
+
63
+ <refsynopsisdiv>
64
+ <cmdsynopsis>
65
+ <command>xmllint</command>
66
+ <group choice="opt">
67
+ <arg choice="plain"><option>--version</option></arg>
68
+ <arg choice="plain"><option>--debug</option></arg>
69
+ <arg choice="plain"><option>--quiet</option></arg>
70
+ <arg choice="plain"><option>--shell</option></arg>
71
+ <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
72
+ <arg choice="plain"><option>--debugent</option></arg>
73
+ <arg choice="plain"><option>--copy</option></arg>
74
+ <arg choice="plain"><option>--recover</option></arg>
75
+ <arg choice="plain"><option>--huge</option></arg>
76
+ <arg choice="plain"><option>--nocompact</option></arg>
77
+ <arg choice="plain"><option>--nodefdtd</option></arg>
78
+ <arg choice="plain"><option>--nodict</option></arg>
79
+ <arg choice="plain"><option>--noenc</option></arg>
80
+ <arg choice="plain"><option>--noent</option></arg>
81
+ <arg choice="plain"><option>--nofixup-base-uris</option></arg>
82
+ <arg choice="plain"><option>--noout</option></arg>
83
+ <arg choice="plain"><option>--nonet</option></arg>
84
+ <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
85
+ <arg choice="plain"><option>--load-trace</option></arg>
86
+ <arg choice="plain"><option>--htmlout</option></arg>
87
+ <arg choice="plain"><option>--nowrap</option></arg>
88
+ <arg choice="plain"><option>--valid</option></arg>
89
+ <arg choice="plain"><option>--postvalid</option></arg>
90
+ <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
91
+ <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
92
+ <arg choice="plain"><option>--timing</option></arg>
93
+ <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
94
+ <arg choice="plain"><option>--repeat</option></arg>
95
+ <arg choice="plain"><option>--insert</option></arg>
96
+ <arg choice="plain"><option>--compress</option></arg>
97
+ <arg choice="plain"><option>--html</option></arg>
98
+ <arg choice="plain"><option>--xmlout</option></arg>
99
+ <arg choice="plain"><option>--push</option></arg>
100
+ <arg choice="plain"><option>--memory</option></arg>
101
+ <arg choice="plain"><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></arg>
102
+ <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
103
+ <arg choice="plain"><option>--nowarning</option></arg>
104
+ <arg choice="plain"><option>--noblanks</option></arg>
105
+ <arg choice="plain"><option>--nocdata</option></arg>
106
+ <arg choice="plain"><option>--format</option></arg>
107
+ <arg choice="plain"><option>--pretty <replaceable class="option">INTEGER</replaceable></option></arg>
108
+ <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
109
+ <arg choice="plain"><option>--dropdtd</option></arg>
110
+ <arg choice="plain"><option>--nsclean</option></arg>
111
+ <arg choice="plain"><option>--testIO</option></arg>
112
+ <arg choice="plain"><option>--catalogs</option></arg>
113
+ <arg choice="plain"><option>--nocatalogs</option></arg>
114
+ <arg choice="plain"><option>--auto</option></arg>
115
+ <arg choice="plain"><option>--xinclude</option></arg>
116
+ <arg choice="plain"><option>--noxincludenode</option></arg>
117
+ <arg choice="plain"><option>--loaddtd</option></arg>
118
+ <arg choice="plain"><option>--dtdattr</option></arg>
119
+ <arg choice="plain"><option>--stream</option></arg>
120
+ <arg choice="plain"><option>--walker</option></arg>
121
+ <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
122
+ <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
123
+ <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
124
+ <arg choice="plain"><option>--schematron <replaceable class="option">SCHEMA</replaceable></option></arg>
125
+ <arg choice="plain"><option>--c14n</option></arg>
126
+ <arg choice="plain"><option>--c14n11</option></arg>
127
+ <arg choice="plain"><option>--exc-c14n</option></arg>
128
+ <arg choice="plain"><option>--pedantic</option></arg>
129
+ <arg choice="plain"><option>--sax</option></arg>
130
+ <arg choice="plain"><option>--sax1</option></arg>
131
+ <arg choice="plain"><option>--oldxml10</option></arg>
132
+ </group>
133
+ <group choice="req">
134
+ <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
135
+ <arg choice="plain" rep="norepeat">-</arg>
136
+ </group>
137
+ </cmdsynopsis>
138
+ </refsynopsisdiv>
139
+
140
+ <refsect1 id="description">
141
+ <title>DESCRIPTION</title>
142
+ <para>
143
+ The &xmllint; program parses one or more <acronym>XML</acronym> files,
144
+ specified on the command line as <replaceable>XML-FILE</replaceable>
145
+ (or the standard input if the filename provided
146
+ is <emphasis role="bold">-</emphasis> ). It prints various types of
147
+ output, depending upon the options selected. It is useful for detecting
148
+ errors both in <acronym>XML</acronym> code and in
149
+ the <acronym>XML</acronym> parser itself.
150
+ </para>
151
+ <para>&xmllint; is included in <citerefentry>
152
+ <refentrytitle>libxml</refentrytitle>
153
+ <manvolnum>3</manvolnum>
154
+ </citerefentry>.</para>
155
+ </refsect1>
156
+
157
+ <refsect1 id="options">
158
+ <title>OPTIONS</title>
159
+ <para>
160
+ &xmllint; accepts the following options (in alphabetical order):
161
+ </para>
162
+
163
+ <variablelist>
164
+
165
+ <varlistentry>
166
+ <term><option>--auto</option></term>
167
+ <listitem>
168
+ <para>Generate a small document for testing purposes.</para>
169
+ </listitem>
170
+ </varlistentry>
171
+
172
+ <varlistentry>
173
+ <term><option>--catalogs</option></term>
174
+ <listitem>
175
+ <para>
176
+ Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
177
+ Otherwise <acronym>XML</acronym> catalogs starting
178
+ from <filename>/etc/xml/catalog</filename> or, more specifically,
179
+ <filename>${sysconfdir}/xml/catalog</filename> are used by default.
180
+ </para>
181
+ </listitem>
182
+ </varlistentry>
183
+
184
+ <varlistentry>
185
+ <term><option>--compress</option></term>
186
+ <listitem>
187
+ <para>
188
+ Turn on <citerefentry>
189
+ <refentrytitle>gzip</refentrytitle>
190
+ <manvolnum>1</manvolnum>
191
+ </citerefentry> compression of output.
192
+ </para>
193
+ </listitem>
194
+ </varlistentry>
195
+
196
+ <varlistentry>
197
+ <term><option>--copy</option></term>
198
+ <listitem>
199
+ <para>Test the internal copy implementation.</para>
200
+ </listitem>
201
+ </varlistentry>
202
+
203
+ <varlistentry>
204
+ <term><option>--c14n</option></term>
205
+ <term><option>--c14n11</option></term>
206
+ <term><option>--exc-c14n</option></term>
207
+ <listitem>
208
+ <para>
209
+ Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
210
+ serialize the result of parsing to <filename class="devicefile">stdout</filename>.
211
+ It keeps comments in the result.
212
+ </para>
213
+ </listitem>
214
+ </varlistentry>
215
+
216
+ <varlistentry>
217
+ <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
218
+ <listitem>
219
+ <para>
220
+ Use the <acronym>DTD</acronym> specified by
221
+ an <replaceable>URL</replaceable> for validation.
222
+ </para>
223
+ </listitem>
224
+ </varlistentry>
225
+
226
+ <varlistentry>
227
+ <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
228
+ <listitem>
229
+ <para>
230
+ Use the <acronym>DTD</acronym> specified by a Formal Public
231
+ Identifier <replaceable>FPI</replaceable> for validation, note that this
232
+ will require a catalog exporting that Formal Public Identifier to work.
233
+ </para>
234
+ </listitem>
235
+ </varlistentry>
236
+
237
+ <varlistentry>
238
+ <term><option>--debug</option></term>
239
+ <listitem>
240
+ <para>
241
+ Parse a file and output an annotated tree of the
242
+ in-memory version of the document.
243
+ </para>
244
+ </listitem>
245
+ </varlistentry>
246
+
247
+ <varlistentry>
248
+ <term><option>--debugent</option></term>
249
+ <listitem>
250
+ <para>Debug the entities defined in the document.</para>
251
+ </listitem>
252
+ </varlistentry>
253
+
254
+ <varlistentry>
255
+ <term><option>--dropdtd</option></term>
256
+ <listitem>
257
+ <para>Remove <acronym>DTD</acronym> from output.</para>
258
+ </listitem>
259
+ </varlistentry>
260
+
261
+ <varlistentry>
262
+ <term><option>--dtdattr</option></term>
263
+ <listitem>
264
+ <para>
265
+ Fetch external <acronym>DTD</acronym> and populate the tree with
266
+ inherited attributes.
267
+ </para>
268
+ </listitem>
269
+ </varlistentry>
270
+
271
+ <varlistentry>
272
+ <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
273
+ <listitem>
274
+ <para>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</para>
275
+ </listitem>
276
+ </varlistentry>
277
+
278
+ <varlistentry>
279
+ <term><option>--format</option></term>
280
+ <listitem>
281
+ <para>
282
+ Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
283
+ environment variable controls the indentation. The default value is two
284
+ spaces &quot; &quot;).
285
+ </para>
286
+ </listitem>
287
+ </varlistentry>
288
+
289
+ <varlistentry>
290
+ <term><option>--html</option></term>
291
+ <listitem>
292
+ <para>Use the <acronym>HTML</acronym> parser.</para>
293
+ </listitem>
294
+ </varlistentry>
295
+
296
+ <varlistentry>
297
+ <term><option>--htmlout</option></term>
298
+ <listitem>
299
+ <para>
300
+ Output results as an <acronym>HTML</acronym> file. This
301
+ causes &xmllint; to output the necessary <acronym>HTML</acronym>
302
+ tags surrounding the result tree output so the results can be
303
+ displayed/viewed in a browser.
304
+ </para>
305
+ </listitem>
306
+ </varlistentry>
307
+
308
+ <varlistentry>
309
+ <term><option>--huge</option></term>
310
+ <listitem>
311
+ <para>Ignore some hardcoded parser limits.</para>
312
+ </listitem>
313
+ </varlistentry>
314
+
315
+ <varlistentry>
316
+ <term><option>--insert</option></term>
317
+ <listitem>
318
+ <para>Test for valid insertions.</para>
319
+ </listitem>
320
+ </varlistentry>
321
+
322
+ <varlistentry>
323
+ <term><option>--loaddtd</option></term>
324
+ <listitem>
325
+ <para>Fetch an external <acronym>DTD</acronym>.</para>
326
+ </listitem>
327
+ </varlistentry>
328
+
329
+ <varlistentry>
330
+ <term><option>--load-trace</option></term>
331
+ <listitem>
332
+ <para>
333
+ Display all the documents loaded during the processing
334
+ to <filename class="devicefile">stderr</filename>.
335
+ </para>
336
+ </listitem>
337
+ </varlistentry>
338
+
339
+ <varlistentry>
340
+ <term><option>--max-ampl <replaceable class="option">INTEGER</replaceable></option></term>
341
+ <listitem>
342
+ <para>
343
+ Set the maximum amplification factor which protects against
344
+ exponential entity expansion ("billion laughs"). The default value
345
+ is 5. Documents making heavy use of entity expansion may require a
346
+ higher value.
347
+ </para>
348
+ </listitem>
349
+ </varlistentry>
350
+
351
+ <varlistentry>
352
+ <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
353
+ <listitem>
354
+ <para>
355
+ Test the parser memory support. <replaceable>NNBYTES</replaceable>
356
+ is the maximum number of bytes the library is allowed to allocate.
357
+ This can also be used to make sure batch processing
358
+ of <acronym>XML</acronym> files will not exhaust the virtual memory
359
+ of the server running them.
360
+ </para>
361
+ </listitem>
362
+ </varlistentry>
363
+
364
+ <varlistentry>
365
+ <term><option>--memory</option></term>
366
+ <listitem>
367
+ <para>Parse from memory.</para>
368
+ </listitem>
369
+ </varlistentry>
370
+
371
+ <varlistentry>
372
+ <term><option>--noblanks</option></term>
373
+ <listitem>
374
+ <para>Drop ignorable blank spaces.</para>
375
+ </listitem>
376
+ </varlistentry>
377
+
378
+ <varlistentry>
379
+ <term><option>--nocatalogs</option></term>
380
+ <listitem>
381
+ <para>Do not use any catalogs.</para>
382
+ </listitem>
383
+ </varlistentry>
384
+
385
+ <varlistentry>
386
+ <term><option>--nocdata</option></term>
387
+ <listitem>
388
+ <para>Substitute CDATA section by equivalent text nodes.</para>
389
+ </listitem>
390
+ </varlistentry>
391
+
392
+ <varlistentry>
393
+ <term><option>--nocompact</option></term>
394
+ <listitem>
395
+ <para>
396
+ Do not generate compact text nodes (parser option
397
+ XML_PARSE_COMPACT). Only for debugging.
398
+ </para>
399
+ </listitem>
400
+ </varlistentry>
401
+
402
+ <varlistentry>
403
+ <term><option>--nodefdtd</option></term>
404
+ <listitem>
405
+ <para>
406
+ Do not set default HTML doctype (parser option
407
+ HTML_PARSE_NODEFDTD).
408
+ </para>
409
+ </listitem>
410
+ </varlistentry>
411
+
412
+ <varlistentry>
413
+ <term><option>--nodict</option></term>
414
+ <listitem>
415
+ <para>
416
+ Don't use dictionaries (parser option XML_PARSE_NODICT).
417
+ Only for debugging.
418
+ </para>
419
+ </listitem>
420
+ </varlistentry>
421
+
422
+ <varlistentry>
423
+ <term><option>--noenc</option></term>
424
+ <listitem>
425
+ <para>
426
+ Ignore encoding declaration (parser option
427
+ XML_PARSE_IGNORE_ENC).
428
+ </para>
429
+ </listitem>
430
+ </varlistentry>
431
+
432
+ <varlistentry>
433
+ <term><option>--noent</option></term>
434
+ <listitem>
435
+ <para>
436
+ Substitute entity values for entity references. By default, &xmllint;
437
+ leaves entity references in place.
438
+ </para>
439
+ </listitem>
440
+ </varlistentry>
441
+
442
+ <varlistentry>
443
+ <term><option>--nofixup-base-uris</option></term>
444
+ <listitem>
445
+ <para>
446
+ Don't fix xml:base URIs when processing XIncludes
447
+ (parser option XML_PARSE_NOBASEFIX).
448
+ </para>
449
+ </listitem>
450
+ </varlistentry>
451
+
452
+ <varlistentry>
453
+ <term><option>--nonet</option></term>
454
+ <listitem>
455
+ <para>
456
+ Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
457
+ </para>
458
+ </listitem>
459
+ </varlistentry>
460
+
461
+ <varlistentry>
462
+ <term><option>--noout</option></term>
463
+ <listitem>
464
+ <para>
465
+ Suppress output. By default, &xmllint; outputs the result tree.
466
+ </para>
467
+ </listitem>
468
+ </varlistentry>
469
+
470
+ <varlistentry>
471
+ <term><option>--nowarning</option></term>
472
+ <listitem>
473
+ <para>Do not emit warnings from the parser and/or validator.</para>
474
+ </listitem>
475
+ </varlistentry>
476
+
477
+ <varlistentry>
478
+ <term><option>--nowrap</option></term>
479
+ <listitem>
480
+ <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
481
+ </listitem>
482
+ </varlistentry>
483
+
484
+ <varlistentry>
485
+ <term><option>--noxincludenode</option></term>
486
+ <listitem>
487
+ <para>
488
+ Do XInclude processing but do not generate XInclude start and end nodes.
489
+ </para>
490
+ </listitem>
491
+ </varlistentry>
492
+
493
+ <varlistentry>
494
+ <term><option>--nsclean</option></term>
495
+ <listitem>
496
+ <para>Remove redundant namespace declarations.</para>
497
+ </listitem>
498
+ </varlistentry>
499
+
500
+ <varlistentry>
501
+ <term><option>--oldxml10</option></term>
502
+ <listitem>
503
+ <para>
504
+ Use deprecated parsing rules before XML 1.0,
505
+ 5th edition.
506
+ </para>
507
+ </listitem>
508
+ </varlistentry>
509
+
510
+ <varlistentry>
511
+ <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
512
+ <listitem>
513
+ <para>
514
+ Define a file path where &xmllint; will save the result of parsing.
515
+ Usually the programs build a tree and save it
516
+ on <filename class="devicefile">stdout</filename>, with this option
517
+ the result <acronym>XML</acronym> instance will be saved onto a file.
518
+ </para>
519
+ </listitem>
520
+ </varlistentry>
521
+
522
+ <varlistentry>
523
+ <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
524
+ <listitem>
525
+ <para>
526
+ Use the (space- or colon-separated) list of filesystem paths specified
527
+ by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
528
+ entities. Enclose space-separated lists by quotation marks.
529
+ </para>
530
+ </listitem>
531
+ </varlistentry>
532
+
533
+ <varlistentry>
534
+ <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
535
+ <listitem>
536
+ <para>
537
+ Used to exercise the pattern recognition engine, which can be used
538
+ with the reader interface to the parser. It allows to select some
539
+ nodes in the document based on an XPath (subset) expression. Used
540
+ for debugging.
541
+ </para>
542
+ </listitem>
543
+ </varlistentry>
544
+
545
+ <varlistentry>
546
+ <term><option>--pedantic</option></term>
547
+ <listitem>
548
+ <para>Enable additional warnings.</para>
549
+ </listitem>
550
+ </varlistentry>
551
+
552
+ <varlistentry>
553
+ <term><option>--postvalid</option></term>
554
+ <listitem>
555
+ <para>Validate after parsing has completed.</para>
556
+ </listitem>
557
+ </varlistentry>
558
+
559
+ <varlistentry>
560
+ <term><option>--pretty <replaceable class="option">INTEGER</replaceable></option></term>
561
+ <listitem>
562
+ <para>
563
+ Value 0 means no formatting, 1 means XML_SAVE_FORMAT
564
+ (same as --format), 2 means XML_SAVE_WSNONSIG.
565
+ </para>
566
+ </listitem>
567
+ </varlistentry>
568
+
569
+ <varlistentry>
570
+ <term><option>--push</option></term>
571
+ <listitem>
572
+ <para>Use the push mode of the parser.</para>
573
+ </listitem>
574
+ </varlistentry>
575
+
576
+ <varlistentry>
577
+ <term><option>--quiet</option></term>
578
+ <listitem>
579
+ <para>Don't print informational messages to stderr.</para>
580
+ </listitem>
581
+ </varlistentry>
582
+
583
+ <varlistentry>
584
+ <term><option>--recover</option></term>
585
+ <listitem>
586
+ <para>Output any parsable portions of an invalid document.</para>
587
+ </listitem>
588
+ </varlistentry>
589
+
590
+ <varlistentry>
591
+ <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
592
+ <listitem>
593
+ <para>
594
+ Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
595
+ for validation.
596
+ </para>
597
+ </listitem>
598
+ </varlistentry>
599
+
600
+ <varlistentry>
601
+ <term><option>--repeat</option></term>
602
+ <listitem>
603
+ <para>Repeat 100 times, for timing or profiling.</para>
604
+ </listitem>
605
+ </varlistentry>
606
+
607
+ <varlistentry>
608
+ <term><option>--sax</option></term>
609
+ <listitem>
610
+ <para>Print SAX callbacks (only for debugging).</para>
611
+ </listitem>
612
+ </varlistentry>
613
+
614
+ <varlistentry>
615
+ <term><option>--sax1</option></term>
616
+ <listitem>
617
+ <para>Use deprecated SAX1 interface (only for debugging).</para>
618
+ </listitem>
619
+ </varlistentry>
620
+
621
+ <varlistentry>
622
+ <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
623
+ <listitem>
624
+ <para>
625
+ Use a W3C <acronym>XML</acronym> Schema file
626
+ named <replaceable>SCHEMA</replaceable> for validation.
627
+ </para>
628
+ </listitem>
629
+ </varlistentry>
630
+
631
+ <varlistentry>
632
+ <term><option>--schematron <replaceable>SCHEMA</replaceable></option></term>
633
+ <listitem>
634
+ <para>
635
+ Use a Schematron file
636
+ named <replaceable>SCHEMA</replaceable> for validation.
637
+ </para>
638
+ </listitem>
639
+ </varlistentry>
640
+
641
+ <varlistentry>
642
+ <term><option>--shell</option></term>
643
+ <listitem>
644
+ <para>
645
+ Run a navigating shell. Details on available commands in shell mode
646
+ are below (see <xref linkend="shell"/>).
647
+ </para>
648
+ </listitem>
649
+ </varlistentry>
650
+
651
+ <varlistentry>
652
+ <term><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></term>
653
+ <listitem>
654
+ <para>
655
+ Run an XPath expression given as argument and print the
656
+ result. In case of a nodeset result, each node in the
657
+ node set is serialized in full in the output. In case
658
+ of an empty node set the "XPath set is empty" result
659
+ will be shown and exit code 11 will be returned..
660
+ This feature is EXPERIMENTAL. Implementation details can
661
+ change without futher notice.
662
+ </para>
663
+ </listitem>
664
+ </varlistentry>
665
+
666
+ <varlistentry>
667
+ <term><option>--stream</option></term>
668
+ <listitem>
669
+ <para>
670
+ Use streaming <acronym>API</acronym> - useful when used in combination
671
+ with <option>--relaxng</option> or <option>--valid</option> options
672
+ for validation of files that are too large to be held in memory.
673
+ </para>
674
+ </listitem>
675
+ </varlistentry>
676
+
677
+ <varlistentry>
678
+ <term><option>--testIO</option></term>
679
+ <listitem>
680
+ <para>Test user input/output support.</para>
681
+ </listitem>
682
+ </varlistentry>
683
+
684
+ <varlistentry>
685
+ <term><option>--timing</option></term>
686
+ <listitem>
687
+ <para>
688
+ Output information about the time it takes &xmllint; to perform the
689
+ various steps.
690
+ </para>
691
+ </listitem>
692
+ </varlistentry>
693
+
694
+ <varlistentry>
695
+ <term><option>--valid</option></term>
696
+ <listitem>
697
+ <para>
698
+ Determine if the document is a valid instance of the included
699
+ Document Type Definition (<acronym>DTD</acronym>).
700
+ A <acronym>DTD</acronym> to be validated against also can be
701
+ specified at the command line using the <option>--dtdvalid</option>
702
+ option. By default, &xmllint; also checks to determine if the
703
+ document is well-formed.
704
+ </para>
705
+ </listitem>
706
+ </varlistentry>
707
+
708
+ <varlistentry>
709
+ <term><option>--version</option></term>
710
+ <listitem>
711
+ <para>
712
+ Display the version of <citerefentry>
713
+ <refentrytitle>libxml</refentrytitle>
714
+ <manvolnum>3</manvolnum>
715
+ </citerefentry> used.
716
+ </para>
717
+ </listitem>
718
+ </varlistentry>
719
+
720
+ <varlistentry>
721
+ <term><option>--walker</option></term>
722
+ <listitem>
723
+ <para>
724
+ Test the walker module, which is a reader interface but for a
725
+ document tree, instead of using the reader <acronym>API</acronym> on
726
+ an unparsed document it works on an existing in-memory tree. Used for
727
+ debugging.
728
+ </para>
729
+ </listitem>
730
+ </varlistentry>
731
+
732
+ <varlistentry>
733
+ <term><option>--xinclude</option></term>
734
+ <listitem>
735
+ <para>Do XInclude processing.</para>
736
+ </listitem>
737
+ </varlistentry>
738
+
739
+ <varlistentry>
740
+ <term><option>--xmlout</option></term>
741
+ <listitem>
742
+ <para>
743
+ Used in conjunction with <option>--html</option>. Usually
744
+ when <acronym>HTML</acronym> is parsed the document is saved with
745
+ the <acronym>HTML</acronym> serializer. But with this option the
746
+ resulting document is saved with the <acronym>XML</acronym>
747
+ serializer. This is primarily used to
748
+ generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
749
+ </para>
750
+ </listitem>
751
+ </varlistentry>
752
+
753
+ </variablelist>
754
+ </refsect1>
755
+
756
+ <refsect1 id="shell">
757
+ <title>SHELL COMMANDS</title>
758
+ <para>
759
+ &xmllint; offers an interactive shell mode invoked with
760
+ the <option>--shell</option> command. Available commands in shell mode
761
+ include (in alphabetical order):
762
+ </para>
763
+ <variablelist>
764
+
765
+ <varlistentry>
766
+ <term><command>base</command></term>
767
+ <listitem>
768
+ <para>Display <acronym>XML</acronym> base of the node.</para>
769
+ </listitem>
770
+ </varlistentry>
771
+
772
+ <varlistentry>
773
+ <term><command>bye</command></term>
774
+ <listitem>
775
+ <para>Leave the shell.</para>
776
+ </listitem>
777
+ </varlistentry>
778
+
779
+ <varlistentry>
780
+ <term><command>cat <replaceable>NODE</replaceable></command></term>
781
+ <listitem>
782
+ <para>Display the given node or the current one.</para>
783
+ </listitem>
784
+ </varlistentry>
785
+
786
+ <varlistentry>
787
+ <term><command>cd <replaceable>PATH</replaceable></command></term>
788
+ <listitem>
789
+ <para>
790
+ Change the current node to the given path (if unique) or root if no
791
+ argument is given.
792
+ </para>
793
+ </listitem>
794
+ </varlistentry>
795
+
796
+ <varlistentry>
797
+ <term><command>dir <replaceable>PATH</replaceable></command></term>
798
+ <listitem>
799
+ <para>
800
+ Dumps information about the node (namespace, attributes, content).
801
+ </para>
802
+ </listitem>
803
+ </varlistentry>
804
+
805
+ <varlistentry>
806
+ <term><command>du <replaceable>PATH</replaceable></command></term>
807
+ <listitem>
808
+ <para>
809
+ Show the structure of the subtree under the given path or the current node.
810
+ </para>
811
+ </listitem>
812
+ </varlistentry>
813
+
814
+ <varlistentry>
815
+ <term><command>exit</command></term>
816
+ <listitem>
817
+ <para>Leave the shell.</para>
818
+ </listitem>
819
+ </varlistentry>
820
+
821
+ <varlistentry>
822
+ <term><command>help</command></term>
823
+ <listitem>
824
+ <para>Show this help.</para>
825
+ </listitem>
826
+ </varlistentry>
827
+
828
+ <varlistentry>
829
+ <term><command>load <replaceable>FILENAME</replaceable></command></term>
830
+ <listitem>
831
+ <para>Load a new document with the given filename.</para>
832
+ </listitem>
833
+ </varlistentry>
834
+
835
+ <varlistentry>
836
+ <term><command>ls <replaceable>PATH</replaceable></command></term>
837
+ <listitem>
838
+ <para>List contents of the given path or the current directory.</para>
839
+ </listitem>
840
+ </varlistentry>
841
+
842
+ <varlistentry>
843
+ <term><command>pwd</command></term>
844
+ <listitem>
845
+ <para>Display the path to the current node.</para>
846
+ </listitem>
847
+ </varlistentry>
848
+
849
+ <varlistentry>
850
+ <term><command>quit</command></term>
851
+ <listitem>
852
+ <para>Leave the shell.</para>
853
+ </listitem>
854
+ </varlistentry>
855
+
856
+ <varlistentry>
857
+ <term><command>save <replaceable>FILENAME</replaceable></command></term>
858
+ <listitem>
859
+ <para>
860
+ Save the current document to the given filename or to the original name.
861
+ </para>
862
+ </listitem>
863
+ </varlistentry>
864
+
865
+ <varlistentry>
866
+ <term><option>validate</option></term>
867
+ <listitem>
868
+ <para>Check the document for errors.</para>
869
+ </listitem>
870
+ </varlistentry>
871
+
872
+ <varlistentry>
873
+ <term><command>write <replaceable>FILENAME</replaceable></command></term>
874
+ <listitem>
875
+ <para>Write the current node to the given filename.</para>
876
+ </listitem>
877
+ </varlistentry>
878
+
879
+ </variablelist>
880
+ </refsect1>
881
+
882
+ <refsect1 id="environment">
883
+ <title>ENVIRONMENT</title>
884
+ <variablelist>
885
+
886
+ <varlistentry>
887
+ <term><envar>SGML_CATALOG_FILES</envar></term>
888
+ <listitem>
889
+ <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
890
+ queries to the user's own set of catalogs. This can be done by setting
891
+ the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
892
+ of catalogs. An empty one should deactivate loading the
893
+ default catalog.
894
+ </para>
895
+ </listitem>
896
+ </varlistentry>
897
+
898
+ <varlistentry>
899
+ <term><envar>XML_CATALOG_FILES</envar></term>
900
+ <listitem>
901
+ <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
902
+ queries to the user's own set of catalogs. This can be done by setting
903
+ the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
904
+ list of catalogs. Use percent-encoding to escape spaces or other characters.
905
+ An empty variable should deactivate loading the default catalog.
906
+ </para>
907
+ </listitem>
908
+ </varlistentry>
909
+
910
+ <varlistentry>
911
+ <term><envar>XML_DEBUG_CATALOG</envar></term>
912
+ <listitem>
913
+ <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
914
+ to <parameter>non-zero</parameter> using the <command>export</command>
915
+ command outputs debugging information related to catalog operations.
916
+ </para>
917
+ </listitem>
918
+ </varlistentry>
919
+
920
+ <varlistentry>
921
+ <term><envar>XMLLINT_INDENT</envar></term>
922
+ <listitem>
923
+ <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
924
+ controls the indentation. The default value is two spaces &quot; &quot;.
925
+ </para>
926
+ </listitem>
927
+ </varlistentry>
928
+
929
+ </variablelist>
930
+ </refsect1>
931
+
932
+ <refsect1 id="diagnostics">
933
+ <title>DIAGNOSTICS</title>
934
+ <para>
935
+ &xmllint; return codes provide information that can be used when
936
+ calling it from scripts.
937
+ </para>
938
+ <!-- better use segmentedlist element later,
939
+ which is currently only supported in snapshots -->
940
+ <variablelist>
941
+
942
+ <varlistentry>
943
+ <term><errorcode>0</errorcode></term>
944
+ <listitem>
945
+ <para>No error</para>
946
+ </listitem>
947
+ </varlistentry>
948
+
949
+ <varlistentry>
950
+ <term><errorcode>1</errorcode></term>
951
+ <listitem>
952
+ <para>Unclassified</para>
953
+ </listitem>
954
+ </varlistentry>
955
+
956
+ <varlistentry>
957
+ <term><errorcode>2</errorcode></term>
958
+ <listitem>
959
+ <para>Error in <acronym>DTD</acronym></para>
960
+ </listitem>
961
+ </varlistentry>
962
+
963
+ <varlistentry>
964
+ <term><errorcode>3</errorcode></term>
965
+ <listitem>
966
+ <para>Validation error</para>
967
+ </listitem>
968
+ </varlistentry>
969
+
970
+ <varlistentry>
971
+ <term><errorcode>4</errorcode></term>
972
+ <listitem>
973
+ <para>Validation error</para>
974
+ </listitem>
975
+ </varlistentry>
976
+
977
+ <varlistentry>
978
+ <term><errorcode>5</errorcode></term>
979
+ <listitem>
980
+ <para>Error in schema compilation</para>
981
+ </listitem>
982
+ </varlistentry>
983
+
984
+ <varlistentry>
985
+ <term><errorcode>6</errorcode></term>
986
+ <listitem>
987
+ <para>Error writing output</para>
988
+ </listitem>
989
+ </varlistentry>
990
+
991
+ <varlistentry>
992
+ <term><errorcode>7</errorcode></term>
993
+ <listitem>
994
+ <para>
995
+ Error in pattern (generated when <option>--pattern</option> option is used)
996
+ </para>
997
+ </listitem>
998
+ </varlistentry>
999
+
1000
+ <varlistentry>
1001
+ <term><errorcode>9</errorcode></term>
1002
+ <listitem>
1003
+ <para>Out of memory error</para>
1004
+ </listitem>
1005
+ </varlistentry>
1006
+
1007
+ <varlistentry>
1008
+ <term><errorcode>10</errorcode></term>
1009
+ <listitem>
1010
+ <para>XPath evaluation error</para>
1011
+ </listitem>
1012
+ </varlistentry>
1013
+
1014
+ <varlistentry>
1015
+ <term><errorcode>11</errorcode></term>
1016
+ <listitem>
1017
+ <para>XPath result is empty</para>
1018
+ </listitem>
1019
+ </varlistentry>
1020
+
1021
+ </variablelist>
1022
+ </refsect1>
1023
+
1024
+ <refsect1 id="seealso">
1025
+ <title>SEE ALSO</title>
1026
+ <para><citerefentry>
1027
+ <refentrytitle>libxml</refentrytitle>
1028
+ <manvolnum>3</manvolnum>
1029
+ </citerefentry>
1030
+ </para>
1031
+ <para>
1032
+ More information can be found at
1033
+ <itemizedlist>
1034
+ <listitem>
1035
+ <para><citerefentry>
1036
+ <refentrytitle>libxml</refentrytitle>
1037
+ <manvolnum>3</manvolnum>
1038
+ </citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
1039
+ </para>
1040
+ </listitem>
1041
+ </itemizedlist>
1042
+ </para>
1043
+ </refsect1>
1044
+
1045
+ </refentry>
local-test-libxml2-delta-01/afc-libxml2/example/.gitignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /gjobread
2
+ /io1
3
+ /io2
4
+ /parse1
5
+ /parse2
6
+ /parse3
7
+ /parse4
8
+ /reader1
9
+ /reader2
10
+ /reader3
11
+ /reader4
12
+ /testWriter
13
+ /tree1
14
+ /tree2
15
+ /xpath1
16
+ /xpath2
local-test-libxml2-delta-01/afc-libxml2/example/Makefile.am ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ EXTRA_DIST = \
2
+ gjobs.xml \
3
+ meson.build \
4
+ test1.xml \
5
+ test2.xml \
6
+ test3.xml
7
+
8
+ check_PROGRAMS = \
9
+ gjobread \
10
+ io1 \
11
+ io2 \
12
+ parse1 \
13
+ parse2 \
14
+ parse3 \
15
+ parse4 \
16
+ reader1 \
17
+ reader2 \
18
+ reader3 \
19
+ reader4 \
20
+ testWriter \
21
+ tree1 \
22
+ tree2 \
23
+ xpath1 \
24
+ xpath2
25
+
26
+ AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
27
+ LDADD = $(top_builddir)/libxml2.la
28
+
29
+ gjobread_SOURCES=gjobread.c
30
+ io1_SOURCES = io1.c
31
+ io2_SOURCES = io2.c
32
+ parse1_SOURCES = parse1.c
33
+ parse2_SOURCES = parse2.c
34
+ parse3_SOURCES = parse3.c
35
+ parse4_SOURCES = parse4.c
36
+ reader1_SOURCES = reader1.c
37
+ reader2_SOURCES = reader2.c
38
+ reader3_SOURCES = reader3.c
39
+ reader4_SOURCES = reader4.c
40
+ testWriter_SOURCES = testWriter.c
41
+ tree1_SOURCES = tree1.c
42
+ tree2_SOURCES = tree2.c
43
+ xpath1_SOURCES = xpath1.c
44
+ xpath2_SOURCES = xpath2.c
local-test-libxml2-delta-01/afc-libxml2/example/gjobread.c ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * gjobread.c : a small test program for gnome jobs XML format
3
+ *
4
+ * See Copyright for the status of this software.
5
+ *
6
+ * Daniel.Veillard@w3.org
7
+ */
8
+
9
+ #include <stdio.h>
10
+ #include <string.h>
11
+ #include <stdlib.h>
12
+
13
+ /*
14
+ * This example should compile and run indifferently with libxml-1.8.8 +
15
+ * and libxml2-2.1.0 +
16
+ * Check the COMPAT comments below
17
+ */
18
+
19
+ /*
20
+ * COMPAT using xml-config --cflags to get the include path this will
21
+ * work with both
22
+ */
23
+ #include <libxml/xmlmemory.h>
24
+ #include <libxml/parser.h>
25
+
26
+ #define DEBUG(x) printf(x)
27
+
28
+ /*
29
+ * A person record
30
+ * an xmlChar * is really an UTF8 encoded char string (0 terminated)
31
+ */
32
+ typedef struct person {
33
+ xmlChar *name;
34
+ xmlChar *email;
35
+ xmlChar *company;
36
+ xmlChar *organisation;
37
+ xmlChar *smail;
38
+ xmlChar *webPage;
39
+ xmlChar *phone;
40
+ } person, *personPtr;
41
+
42
+ /*
43
+ * And the code needed to parse it
44
+ */
45
+ static personPtr
46
+ parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
47
+ personPtr ret = NULL;
48
+
49
+ DEBUG("parsePerson\n");
50
+ /*
51
+ * allocate the struct
52
+ */
53
+ ret = (personPtr) malloc(sizeof(person));
54
+ if (ret == NULL) {
55
+ fprintf(stderr,"out of memory\n");
56
+ return(NULL);
57
+ }
58
+ memset(ret, 0, sizeof(person));
59
+
60
+ /* We don't care what the top level element name is */
61
+ /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
62
+ cur = cur->xmlChildrenNode;
63
+ while (cur != NULL) {
64
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Person")) &&
65
+ (cur->ns == ns))
66
+ ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
67
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Email")) &&
68
+ (cur->ns == ns))
69
+ ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
70
+ cur = cur->next;
71
+ }
72
+
73
+ return(ret);
74
+ }
75
+
76
+ /*
77
+ * and to print it
78
+ */
79
+ static void
80
+ printPerson(personPtr cur) {
81
+ if (cur == NULL) return;
82
+ printf("------ Person\n");
83
+ if (cur->name) printf(" name: %s\n", cur->name);
84
+ if (cur->email) printf(" email: %s\n", cur->email);
85
+ if (cur->company) printf(" company: %s\n", cur->company);
86
+ if (cur->organisation) printf(" organisation: %s\n", cur->organisation);
87
+ if (cur->smail) printf(" smail: %s\n", cur->smail);
88
+ if (cur->webPage) printf(" Web: %s\n", cur->webPage);
89
+ if (cur->phone) printf(" phone: %s\n", cur->phone);
90
+ printf("------\n");
91
+ }
92
+
93
+ /*
94
+ * a Description for a Job
95
+ */
96
+ typedef struct job {
97
+ xmlChar *projectID;
98
+ xmlChar *application;
99
+ xmlChar *category;
100
+ personPtr contact;
101
+ int nbDevelopers;
102
+ personPtr developers[100]; /* using dynamic alloc is left as an exercise */
103
+ } job, *jobPtr;
104
+
105
+ /*
106
+ * And the code needed to parse it
107
+ */
108
+ static jobPtr
109
+ parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
110
+ jobPtr ret = NULL;
111
+
112
+ DEBUG("parseJob\n");
113
+ /*
114
+ * allocate the struct
115
+ */
116
+ ret = (jobPtr) malloc(sizeof(job));
117
+ if (ret == NULL) {
118
+ fprintf(stderr,"out of memory\n");
119
+ return(NULL);
120
+ }
121
+ memset(ret, 0, sizeof(job));
122
+
123
+ /* We don't care what the top level element name is */
124
+ cur = cur->xmlChildrenNode;
125
+ while (cur != NULL) {
126
+
127
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Project")) &&
128
+ (cur->ns == ns)) {
129
+ ret->projectID = xmlGetProp(cur, (const xmlChar *) "ID");
130
+ if (ret->projectID == NULL) {
131
+ fprintf(stderr, "Project has no ID\n");
132
+ }
133
+ }
134
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Application")) &&
135
+ (cur->ns == ns))
136
+ ret->application =
137
+ xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
138
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Category")) &&
139
+ (cur->ns == ns))
140
+ ret->category =
141
+ xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
142
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Contact")) &&
143
+ (cur->ns == ns))
144
+ ret->contact = parsePerson(doc, ns, cur);
145
+ cur = cur->next;
146
+ }
147
+
148
+ return(ret);
149
+ }
150
+
151
+ /*
152
+ * and to print it
153
+ */
154
+ static void
155
+ printJob(jobPtr cur) {
156
+ int i;
157
+
158
+ if (cur == NULL) return;
159
+ printf("======= Job\n");
160
+ if (cur->projectID != NULL) printf("projectID: %s\n", cur->projectID);
161
+ if (cur->application != NULL) printf("application: %s\n", cur->application);
162
+ if (cur->category != NULL) printf("category: %s\n", cur->category);
163
+ if (cur->contact != NULL) printPerson(cur->contact);
164
+ printf("%d developers\n", cur->nbDevelopers);
165
+
166
+ for (i = 0;i < cur->nbDevelopers;i++) printPerson(cur->developers[i]);
167
+ printf("======= \n");
168
+ }
169
+
170
+ /*
171
+ * A pool of Gnome Jobs
172
+ */
173
+ typedef struct gjob {
174
+ int nbJobs;
175
+ jobPtr jobs[500]; /* using dynamic alloc is left as an exercise */
176
+ } gJob, *gJobPtr;
177
+
178
+
179
+ static gJobPtr
180
+ parseGjobFile(char *filename) {
181
+ xmlDocPtr doc;
182
+ gJobPtr ret;
183
+ jobPtr curjob;
184
+ xmlNsPtr ns;
185
+ xmlNodePtr cur;
186
+
187
+ /*
188
+ * build an XML tree from a the file;
189
+ */
190
+ doc = xmlReadFile(filename, NULL, XML_PARSE_NOBLANKS);
191
+ if (doc == NULL) return(NULL);
192
+
193
+ /*
194
+ * Check the document is of the right kind
195
+ */
196
+
197
+ cur = xmlDocGetRootElement(doc);
198
+ if (cur == NULL) {
199
+ fprintf(stderr,"empty document\n");
200
+ xmlFreeDoc(doc);
201
+ return(NULL);
202
+ }
203
+ ns = xmlSearchNsByHref(doc, cur,
204
+ (const xmlChar *) "http://www.gnome.org/some-location");
205
+ if (ns == NULL) {
206
+ fprintf(stderr,
207
+ "document of the wrong type, GJob Namespace not found\n");
208
+ xmlFreeDoc(doc);
209
+ return(NULL);
210
+ }
211
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Helping")) {
212
+ fprintf(stderr,"document of the wrong type, root node != Helping");
213
+ xmlFreeDoc(doc);
214
+ return(NULL);
215
+ }
216
+
217
+ /*
218
+ * Allocate the structure to be returned.
219
+ */
220
+ ret = (gJobPtr) malloc(sizeof(gJob));
221
+ if (ret == NULL) {
222
+ fprintf(stderr,"out of memory\n");
223
+ xmlFreeDoc(doc);
224
+ return(NULL);
225
+ }
226
+ memset(ret, 0, sizeof(gJob));
227
+
228
+ /*
229
+ * Now, walk the tree.
230
+ */
231
+ /* First level we expect just Jobs */
232
+ cur = cur->xmlChildrenNode;
233
+ while ( cur && xmlIsBlankNode ( cur ) ) {
234
+ cur = cur -> next;
235
+ }
236
+ if ( cur == 0 ) {
237
+ xmlFreeDoc(doc);
238
+ free(ret);
239
+ return ( NULL );
240
+ }
241
+ if ((xmlStrcmp(cur->name, (const xmlChar *) "Jobs")) || (cur->ns != ns)) {
242
+ fprintf(stderr,"document of the wrong type, was '%s', Jobs expected",
243
+ cur->name);
244
+ fprintf(stderr,"xmlDocDump follows\n");
245
+ #ifdef LIBXML_OUTPUT_ENABLED
246
+ xmlDocDump ( stderr, doc );
247
+ fprintf(stderr,"xmlDocDump finished\n");
248
+ #endif /* LIBXML_OUTPUT_ENABLED */
249
+ xmlFreeDoc(doc);
250
+ free(ret);
251
+ return(NULL);
252
+ }
253
+
254
+ /* Second level is a list of Job, but be laxist */
255
+ cur = cur->xmlChildrenNode;
256
+ while (cur != NULL) {
257
+ if ((!xmlStrcmp(cur->name, (const xmlChar *) "Job")) &&
258
+ (cur->ns == ns)) {
259
+ curjob = parseJob(doc, ns, cur);
260
+ if (curjob != NULL)
261
+ ret->jobs[ret->nbJobs++] = curjob;
262
+ if (ret->nbJobs >= 500) break;
263
+ }
264
+ cur = cur->next;
265
+ }
266
+
267
+ return(ret);
268
+ }
269
+
270
+ static void
271
+ handleGjob(gJobPtr cur) {
272
+ int i;
273
+
274
+ /*
275
+ * Do whatever you want and free the structure.
276
+ */
277
+ printf("%d Jobs registered\n", cur->nbJobs);
278
+ for (i = 0; i < cur->nbJobs; i++) printJob(cur->jobs[i]);
279
+ }
280
+
281
+ int main(int argc, char **argv) {
282
+ int i;
283
+ gJobPtr cur;
284
+
285
+ /* COMPAT: Do not generate nodes for formatting spaces */
286
+ LIBXML_TEST_VERSION
287
+
288
+ for (i = 1; i < argc ; i++) {
289
+ cur = parseGjobFile(argv[i]);
290
+ if ( cur )
291
+ handleGjob(cur);
292
+ else
293
+ fprintf( stderr, "Error parsing file '%s'\n", argv[i]);
294
+
295
+ }
296
+
297
+ /* Clean up everything else before quitting. */
298
+ xmlCleanupParser();
299
+
300
+ return(0);
301
+ }
local-test-libxml2-delta-01/afc-libxml2/example/gjobs.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <gjob:Helping xmlns:gjob="http://www.gnome.org/some-location">
3
+ <gjob:Jobs>
4
+
5
+ <gjob:Job>
6
+ <gjob:Project ID="3"/>
7
+ <gjob:Application>GBackup</gjob:Application>
8
+ <gjob:Category>Development</gjob:Category>
9
+
10
+ <gjob:Update>
11
+ <gjob:Status>Open</gjob:Status>
12
+ <gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST</gjob:Modified>
13
+ <gjob:Salary>USD 0.00</gjob:Salary>
14
+ </gjob:Update>
15
+
16
+ <gjob:Developers>
17
+ <gjob:Developer>
18
+ </gjob:Developer>
19
+ </gjob:Developers>
20
+
21
+ <gjob:Contact>
22
+ <gjob:Person>Nathan Clemons</gjob:Person>
23
+ <gjob:Email>nathan@windsofstorm.net</gjob:Email>
24
+ <gjob:Company>
25
+ </gjob:Company>
26
+ <gjob:Organisation>
27
+ </gjob:Organisation>
28
+ <gjob:Webpage>
29
+ </gjob:Webpage>
30
+ <gjob:Snailmail>
31
+ </gjob:Snailmail>
32
+ <gjob:Phone>
33
+ </gjob:Phone>
34
+ </gjob:Contact>
35
+
36
+ <gjob:Requirements>
37
+ The program should be released as free software, under the GPL.
38
+ </gjob:Requirements>
39
+
40
+ <gjob:Skills>
41
+ </gjob:Skills>
42
+
43
+ <gjob:Details>
44
+ A GNOME based system that will allow a superuser to configure
45
+ compressed and uncompressed files and/or file systems to be backed
46
+ up with a supported media in the system. This should be able to
47
+ perform via find commands generating a list of files that are passed
48
+ to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
49
+ or via operations performed on the filesystem itself. Email
50
+ notification and GUI status display very important.
51
+ </gjob:Details>
52
+
53
+ </gjob:Job>
54
+
55
+ </gjob:Jobs>
56
+ </gjob:Helping>
57
+
local-test-libxml2-delta-01/afc-libxml2/example/icu.c ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * icu.c: Example how to use ICU for character encoding conversion
3
+ *
4
+ * This example shows how to use ICU by installing a custom character
5
+ * encoding converter with xmlCtxtSetCharEncConvImpl, available
6
+ * since libxml2 2.14.
7
+ *
8
+ * This approach makes it possible to use ICU even if libxml2 is
9
+ * compiled without ICU support. It also makes sure that *only* ICU
10
+ * is used. Many Linux distros currently ship libxml2 with support
11
+ * for both ICU and iconv which makes the library's behavior hard to
12
+ * predict.
13
+ *
14
+ * The long-term plan is to make libxml2 only support a single
15
+ * conversion library internally (iconv on POSIX).
16
+ */
17
+
18
+ #include <stdio.h>
19
+ #include <libxml/parser.h>
20
+ #include <unicode/ucnv.h>
21
+
22
+ #define ICU_PIVOT_BUF_SIZE 1024
23
+
24
+ typedef struct {
25
+ UConverter *uconv; /* for conversion between an encoding and UTF-16 */
26
+ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
27
+ UChar *pivot_source;
28
+ UChar *pivot_target;
29
+ int isInput;
30
+ UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
31
+ } myConvCtxt;
32
+
33
+ static int
34
+ icuConvert(unsigned char *out, int *outlen,
35
+ const unsigned char *in, int *inlen, void *vctxt) {
36
+ myConvCtxt *cd = vctxt;
37
+ const char *ucv_in = (const char *) in;
38
+ char *ucv_out = (char *) out;
39
+ UConverter *target, *source;
40
+ UErrorCode err = U_ZERO_ERROR;
41
+ int ret;
42
+
43
+ if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
44
+ if (outlen != NULL)
45
+ *outlen = 0;
46
+ return XML_ENC_ERR_INTERNAL;
47
+ }
48
+
49
+ /*
50
+ * Note that the ICU API is stateful. It can always consume a certain
51
+ * amount of input even if the output buffer would overflow. The
52
+ * remaining input must be processed by calling ucnv_convertEx with a
53
+ * possibly empty input buffer.
54
+ *
55
+ * ucnv_convertEx is always called with reset and flush set to 0,
56
+ * so we don't mess up the state. This should never generate
57
+ * U_TRUNCATED_CHAR_FOUND errors.
58
+ */
59
+ if (cd->isInput) {
60
+ source = cd->uconv;
61
+ target = cd->utf8;
62
+ } else {
63
+ source = cd->utf8;
64
+ target = cd->uconv;
65
+ }
66
+
67
+ ucnv_convertEx(target, source, &ucv_out, ucv_out + *outlen,
68
+ &ucv_in, ucv_in + *inlen, cd->pivot_buf,
69
+ &cd->pivot_source, &cd->pivot_target,
70
+ cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err);
71
+
72
+ *inlen = ucv_in - (const char*) in;
73
+ *outlen = ucv_out - (char *) out;
74
+
75
+ if (U_SUCCESS(err)) {
76
+ ret = XML_ENC_ERR_SUCCESS;
77
+ } else {
78
+ switch (err) {
79
+ case U_TRUNCATED_CHAR_FOUND:
80
+ /* Shouldn't happen without flush */
81
+ ret = XML_ENC_ERR_SUCCESS;
82
+ break;
83
+
84
+ case U_BUFFER_OVERFLOW_ERROR:
85
+ ret = XML_ENC_ERR_SPACE;
86
+ break;
87
+
88
+ case U_INVALID_CHAR_FOUND:
89
+ case U_ILLEGAL_CHAR_FOUND:
90
+ case U_ILLEGAL_ESCAPE_SEQUENCE:
91
+ case U_UNSUPPORTED_ESCAPE_SEQUENCE:
92
+ ret = XML_ENC_ERR_INPUT;
93
+ break;
94
+
95
+ case U_MEMORY_ALLOCATION_ERROR:
96
+ ret = XML_ENC_ERR_MEMORY;
97
+ break;
98
+
99
+ default:
100
+ ret = XML_ENC_ERR_INTERNAL;
101
+ break;
102
+ }
103
+ }
104
+
105
+ return ret;
106
+ }
107
+
108
+ static int
109
+ icuOpen(const char* name, int isInput, myConvCtxt **out)
110
+ {
111
+ UErrorCode status;
112
+ myConvCtxt *cd;
113
+
114
+ *out = NULL;
115
+
116
+ cd = xmlMalloc(sizeof(myConvCtxt));
117
+ if (cd == NULL)
118
+ return XML_ERR_NO_MEMORY;
119
+
120
+ cd->isInput = isInput;
121
+ cd->pivot_source = cd->pivot_buf;
122
+ cd->pivot_target = cd->pivot_buf;
123
+
124
+ status = U_ZERO_ERROR;
125
+ cd->uconv = ucnv_open(name, &status);
126
+ if (U_FAILURE(status))
127
+ goto error;
128
+
129
+ status = U_ZERO_ERROR;
130
+ if (isInput) {
131
+ ucnv_setToUCallBack(cd->uconv, UCNV_TO_U_CALLBACK_STOP,
132
+ NULL, NULL, NULL, &status);
133
+ }
134
+ else {
135
+ ucnv_setFromUCallBack(cd->uconv, UCNV_FROM_U_CALLBACK_STOP,
136
+ NULL, NULL, NULL, &status);
137
+ }
138
+ if (U_FAILURE(status))
139
+ goto error;
140
+
141
+ status = U_ZERO_ERROR;
142
+ cd->utf8 = ucnv_open("UTF-8", &status);
143
+ if (U_FAILURE(status))
144
+ goto error;
145
+
146
+ *out = cd;
147
+ return 0;
148
+
149
+ error:
150
+ if (cd->uconv)
151
+ ucnv_close(cd->uconv);
152
+ xmlFree(cd);
153
+
154
+ if (status == U_FILE_ACCESS_ERROR)
155
+ return XML_ERR_UNSUPPORTED_ENCODING;
156
+ if (status == U_MEMORY_ALLOCATION_ERROR)
157
+ return XML_ERR_NO_MEMORY;
158
+ return XML_ERR_SYSTEM;
159
+ }
160
+
161
+ static void
162
+ icuClose(myConvCtxt *cd)
163
+ {
164
+ if (cd == NULL)
165
+ return;
166
+ ucnv_close(cd->uconv);
167
+ ucnv_close(cd->utf8);
168
+ xmlFree(cd);
169
+ }
170
+
171
+ static void
172
+ icuConvCtxtDtor(void *vctxt) {
173
+ icuClose(vctxt);
174
+ }
175
+
176
+ static int
177
+ icuConvImpl(void *vctxt, const char *name,
178
+ xmlCharEncConverter *conv) {
179
+ myConvCtxt *inputCtxt = NULL;
180
+ myConvCtxt *outputCtxt = NULL;
181
+ int ret;
182
+
183
+ ret = icuOpen(name, 1, &inputCtxt);
184
+ if (ret != 0)
185
+ goto error;
186
+ ret = icuOpen(name, 0, &outputCtxt);
187
+ if (ret != 0)
188
+ goto error;
189
+
190
+ conv->input = icuConvert;
191
+ conv->output = icuConvert;
192
+ conv->ctxtDtor = icuConvCtxtDtor;
193
+ conv->inputCtxt = inputCtxt;
194
+ conv->outputCtxt = outputCtxt;
195
+
196
+ return XML_ERR_OK;
197
+
198
+ error:
199
+ if (inputCtxt != NULL)
200
+ icuClose(inputCtxt);
201
+ if (outputCtxt != NULL)
202
+ icuClose(outputCtxt);
203
+ return ret;
204
+ }
205
+
206
+ int
207
+ main(void) {
208
+ xmlParserCtxtPtr ctxt;
209
+ xmlDocPtr doc;
210
+ const char *xml;
211
+ xmlChar *content;
212
+ int ret = 0;
213
+
214
+ /*
215
+ * We use IBM-1051, an alias for HP Roman, as a simple example that
216
+ * ICU supports, but iconv (typically) doesn't.
217
+ *
218
+ * Character code 0xDE is U+00DF Latin Small Letter Sharp S.
219
+ */
220
+ xml = "<doc>\xDE</doc>";
221
+
222
+ ctxt = xmlNewParserCtxt();
223
+ xmlCtxtSetCharEncConvImpl(ctxt, icuConvImpl, NULL);
224
+ doc = xmlCtxtReadDoc(ctxt, BAD_CAST xml, NULL, "IBM-1051", 0);
225
+ xmlFreeParserCtxt(ctxt);
226
+
227
+ content = xmlNodeGetContent((xmlNodePtr) doc);
228
+
229
+ printf("content: %s\n", content);
230
+
231
+ if (!xmlStrEqual(content, BAD_CAST "\xC3\x9F")) {
232
+ fprintf(stderr, "converison failed\n");
233
+ ret = 1;
234
+ }
235
+
236
+ xmlFree(content);
237
+ xmlFreeDoc(doc);
238
+
239
+ return ret;
240
+ }
241
+
local-test-libxml2-delta-01/afc-libxml2/example/io1.c ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: InputOutput
3
+ * synopsis: Example of custom Input/Output
4
+ * purpose: Demonstrate the use of xmlRegisterInputCallbacks
5
+ * to build a custom I/O layer, this is used in an
6
+ * XInclude method context to show how dynamic document can
7
+ * be built in a clean way.
8
+ * usage: io1
9
+ * test: io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res
10
+ * author: Daniel Veillard
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <stdlib.h>
16
+ #include <string.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/tree.h>
19
+ #include <libxml/xinclude.h>
20
+ #include <libxml/xmlIO.h>
21
+
22
+ #ifdef LIBXML_XINCLUDE_ENABLED
23
+ static const char *result = "<list><people>a</people><people>b</people></list>";
24
+ static const char *cur = NULL;
25
+ static int rlen;
26
+
27
+ /**
28
+ * sqlMatch:
29
+ * @URI: an URI to test
30
+ *
31
+ * Check for an sql: query
32
+ *
33
+ * Returns 1 if yes and 0 if another Input module should be used
34
+ */
35
+ static int
36
+ sqlMatch(const char * URI) {
37
+ if ((URI != NULL) && (!strncmp(URI, "sql:", 4)))
38
+ return(1);
39
+ return(0);
40
+ }
41
+
42
+ /**
43
+ * sqlOpen:
44
+ * @URI: an URI to test
45
+ *
46
+ * Return a pointer to the sql: query handler, in this example simply
47
+ * the current pointer...
48
+ *
49
+ * Returns an Input context or NULL in case or error
50
+ */
51
+ static void *
52
+ sqlOpen(const char * URI) {
53
+ if ((URI == NULL) || (strncmp(URI, "sql:", 4)))
54
+ return(NULL);
55
+ cur = result;
56
+ rlen = strlen(result);
57
+ return((void *) cur);
58
+ }
59
+
60
+ /**
61
+ * sqlClose:
62
+ * @context: the read context
63
+ *
64
+ * Close the sql: query handler
65
+ *
66
+ * Returns 0 or -1 in case of error
67
+ */
68
+ static int
69
+ sqlClose(void * context) {
70
+ if (context == NULL) return(-1);
71
+ cur = NULL;
72
+ rlen = 0;
73
+ return(0);
74
+ }
75
+
76
+ /**
77
+ * sqlRead:
78
+ * @context: the read context
79
+ * @buffer: where to store data
80
+ * @len: number of bytes to read
81
+ *
82
+ * Implement an sql: query read.
83
+ *
84
+ * Returns the number of bytes read or -1 in case of error
85
+ */
86
+ static int
87
+ sqlRead(void * context, char * buffer, int len) {
88
+ const char *ptr = (const char *) context;
89
+
90
+ if ((context == NULL) || (buffer == NULL) || (len < 0))
91
+ return(-1);
92
+
93
+ if (len > rlen) len = rlen;
94
+ memcpy(buffer, ptr, len);
95
+ rlen -= len;
96
+ return(len);
97
+ }
98
+
99
+ const char *include = "<?xml version='1.0'?>\n\
100
+ <document xmlns:xi=\"http://www.w3.org/2003/XInclude\">\n\
101
+ <p>List of people:</p>\n\
102
+ <xi:include href=\"sql:select_name_from_people\"/>\n\
103
+ </document>\n";
104
+
105
+ int main(void) {
106
+ xmlDocPtr doc;
107
+
108
+ /*
109
+ * this initialize the library and check potential ABI mismatches
110
+ * between the version it was compiled for and the actual shared
111
+ * library used.
112
+ */
113
+ LIBXML_TEST_VERSION
114
+
115
+ /*
116
+ * register the new I/O handlers
117
+ */
118
+ if (xmlRegisterInputCallbacks(sqlMatch, sqlOpen, sqlRead, sqlClose) < 0) {
119
+ fprintf(stderr, "failed to register SQL handler\n");
120
+ exit(1);
121
+ }
122
+ /*
123
+ * parse include into a document
124
+ */
125
+ doc = xmlReadMemory(include, strlen(include), "include.xml", NULL, 0);
126
+ if (doc == NULL) {
127
+ fprintf(stderr, "failed to parse the including file\n");
128
+ exit(1);
129
+ }
130
+
131
+ /*
132
+ * apply the XInclude process, this should trigger the I/O just
133
+ * registered.
134
+ */
135
+ if (xmlXIncludeProcess(doc) <= 0) {
136
+ fprintf(stderr, "XInclude processing failed\n");
137
+ exit(1);
138
+ }
139
+
140
+ #ifdef LIBXML_OUTPUT_ENABLED
141
+ /*
142
+ * save the output for checking to stdout
143
+ */
144
+ xmlDocDump(stdout, doc);
145
+ #endif
146
+
147
+ /*
148
+ * Free the document
149
+ */
150
+ xmlFreeDoc(doc);
151
+
152
+ return(0);
153
+ }
154
+ #else
155
+ int main(void) {
156
+ fprintf(stderr, "XInclude support not compiled in\n");
157
+ return(0);
158
+ }
159
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/io2.c ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: InputOutput
3
+ * synopsis: Output to char buffer
4
+ * purpose: Demonstrate the use of xmlDocDumpMemory
5
+ * to output document to a character buffer
6
+ * usage: io2
7
+ * test: io2 > io2.tmp && diff io2.tmp $(srcdir)/io2.res
8
+ * author: John Fleck
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <libxml/parser.h>
13
+
14
+ #if defined(LIBXML_OUTPUT_ENABLED)
15
+ int
16
+ main(void)
17
+ {
18
+
19
+ xmlNodePtr n;
20
+ xmlDocPtr doc;
21
+ xmlChar *xmlbuff;
22
+ int buffersize;
23
+
24
+ /*
25
+ * Create the document.
26
+ */
27
+ doc = xmlNewDoc(BAD_CAST "1.0");
28
+ n = xmlNewDocNode(doc, NULL, BAD_CAST "root", NULL);
29
+ xmlNodeSetContent(n, BAD_CAST "content");
30
+ xmlDocSetRootElement(doc, n);
31
+
32
+ /*
33
+ * Dump the document to a buffer and print it
34
+ * for demonstration purposes.
35
+ */
36
+ xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
37
+ printf("%s", (char *) xmlbuff);
38
+
39
+ /*
40
+ * Free associated memory.
41
+ */
42
+ xmlFree(xmlbuff);
43
+ xmlFreeDoc(doc);
44
+
45
+ return (0);
46
+
47
+ }
48
+ #else
49
+ #include <stdio.h>
50
+
51
+ int
52
+ main(void)
53
+ {
54
+ fprintf(stderr,
55
+ "library not configured with output support\n");
56
+ return (0);
57
+ }
58
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/meson.build ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ examples = [
2
+ 'gjobread',
3
+ 'io1',
4
+ 'io2',
5
+ 'parse1',
6
+ 'parse2',
7
+ 'parse3',
8
+ 'parse4',
9
+ 'reader1',
10
+ 'reader2',
11
+ 'reader3',
12
+ 'reader4',
13
+ 'testWriter',
14
+ 'tree1',
15
+ 'tree2',
16
+ 'xpath1',
17
+ 'xpath2',
18
+ ]
19
+
20
+ foreach example : examples
21
+ exe = executable(
22
+ example,
23
+ files(example + '.c'),
24
+ dependencies: xml_dep,
25
+ include_directories: config_dir,
26
+ )
27
+ endforeach
local-test-libxml2-delta-01/afc-libxml2/example/parse1.c ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML file to a tree and free it
4
+ * purpose: Demonstrate the use of xmlReadFile() to read an XML file
5
+ * into a tree and xmlFreeDoc() to free the resulting tree
6
+ * usage: parse1 test1.xml
7
+ * test: parse1 test1.xml
8
+ * author: Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ /**
17
+ * example1Func:
18
+ * @filename: a filename or an URL
19
+ *
20
+ * Parse the resource and free the resulting tree
21
+ */
22
+ static void
23
+ example1Func(const char *filename) {
24
+ xmlDocPtr doc; /* the resulting document tree */
25
+
26
+ doc = xmlReadFile(filename, NULL, 0);
27
+ if (doc == NULL) {
28
+ fprintf(stderr, "Failed to parse %s\n", filename);
29
+ return;
30
+ }
31
+ xmlFreeDoc(doc);
32
+ }
33
+
34
+ int main(int argc, char **argv) {
35
+ if (argc != 2)
36
+ return(1);
37
+
38
+ /*
39
+ * this initialize the library and check potential ABI mismatches
40
+ * between the version it was compiled for and the actual shared
41
+ * library used.
42
+ */
43
+ LIBXML_TEST_VERSION
44
+
45
+ example1Func(argv[1]);
46
+
47
+ return(0);
48
+ }
local-test-libxml2-delta-01/afc-libxml2/example/parse2.c ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse and validate an XML file to a tree and free the result
4
+ * purpose: Create a parser context for an XML file, then parse and validate
5
+ * the file, creating a tree, check the validation result
6
+ * and xmlFreeDoc() to free the resulting tree.
7
+ * usage: parse2 test2.xml
8
+ * test: parse2 test2.xml
9
+ * author: Daniel Veillard
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+
13
+ #include <stdio.h>
14
+ #include <libxml/parser.h>
15
+ #include <libxml/tree.h>
16
+
17
+ /**
18
+ * exampleFunc:
19
+ * @filename: a filename or an URL
20
+ *
21
+ * Parse and validate the resource and free the resulting tree
22
+ */
23
+ static void
24
+ exampleFunc(const char *filename) {
25
+ xmlParserCtxtPtr ctxt; /* the parser context */
26
+ xmlDocPtr doc; /* the resulting document tree */
27
+
28
+ /* create a parser context */
29
+ ctxt = xmlNewParserCtxt();
30
+ if (ctxt == NULL) {
31
+ fprintf(stderr, "Failed to allocate parser context\n");
32
+ return;
33
+ }
34
+ /* parse the file, activating the DTD validation option */
35
+ doc = xmlCtxtReadFile(ctxt, filename, NULL, XML_PARSE_DTDVALID);
36
+ /* check if parsing succeeded */
37
+ if (doc == NULL) {
38
+ fprintf(stderr, "Failed to parse %s\n", filename);
39
+ } else {
40
+ /* check if validation succeeded */
41
+ if (ctxt->valid == 0)
42
+ fprintf(stderr, "Failed to validate %s\n", filename);
43
+ /* free up the resulting document */
44
+ xmlFreeDoc(doc);
45
+ }
46
+ /* free up the parser context */
47
+ xmlFreeParserCtxt(ctxt);
48
+ }
49
+
50
+ int main(int argc, char **argv) {
51
+ if (argc != 2)
52
+ return(1);
53
+
54
+ /*
55
+ * this initialize the library and check potential ABI mismatches
56
+ * between the version it was compiled for and the actual shared
57
+ * library used.
58
+ */
59
+ LIBXML_TEST_VERSION
60
+
61
+ exampleFunc(argv[1]);
62
+
63
+ return(0);
64
+ }
local-test-libxml2-delta-01/afc-libxml2/example/parse3.c ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML document in memory to a tree and free it
4
+ * purpose: Demonstrate the use of xmlReadMemory() to read an XML file
5
+ * into a tree and xmlFreeDoc() to free the resulting tree
6
+ * usage: parse3
7
+ * test: parse3
8
+ * author: Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ static const char *document = "<doc/>";
17
+
18
+ /**
19
+ * example3Func:
20
+ * @content: the content of the document
21
+ * @length: the length in bytes
22
+ *
23
+ * Parse the in memory document and free the resulting tree
24
+ */
25
+ static void
26
+ example3Func(const char *content, int length) {
27
+ xmlDocPtr doc; /* the resulting document tree */
28
+
29
+ /*
30
+ * The document being in memory, it have no base per RFC 2396,
31
+ * and the "noname.xml" argument will serve as its base.
32
+ */
33
+ doc = xmlReadMemory(content, length, "noname.xml", NULL, 0);
34
+ if (doc == NULL) {
35
+ fprintf(stderr, "Failed to parse document\n");
36
+ return;
37
+ }
38
+ xmlFreeDoc(doc);
39
+ }
40
+
41
+ int main(void) {
42
+ /*
43
+ * this initialize the library and check potential ABI mismatches
44
+ * between the version it was compiled for and the actual shared
45
+ * library used.
46
+ */
47
+ LIBXML_TEST_VERSION
48
+
49
+ example3Func(document, 6);
50
+
51
+ return(0);
52
+ }
local-test-libxml2-delta-01/afc-libxml2/example/parse4.c ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Parsing
3
+ * synopsis: Parse an XML document chunk by chunk to a tree and free it
4
+ * purpose: Demonstrate the use of xmlCreatePushParserCtxt() and
5
+ * xmlParseChunk() to read an XML file progressively
6
+ * into a tree and xmlFreeDoc() to free the resulting tree
7
+ * usage: parse4 test3.xml
8
+ * test: parse4 test3.xml
9
+ * author: Daniel Veillard
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+
13
+ #include <stdio.h>
14
+ #include <libxml/parser.h>
15
+ #include <libxml/tree.h>
16
+
17
+ #ifdef LIBXML_PUSH_ENABLED
18
+ static FILE *desc;
19
+
20
+ /**
21
+ * readPacket:
22
+ * @mem: array to store the packet
23
+ * @size: the packet size
24
+ *
25
+ * read at most @size bytes from the document and store it in @mem
26
+ *
27
+ * Returns the number of bytes read
28
+ */
29
+ static int
30
+ readPacket(char *mem, int size) {
31
+ int res;
32
+
33
+ res = fread(mem, 1, size, desc);
34
+ return(res);
35
+ }
36
+
37
+ /**
38
+ * example4Func:
39
+ * @filename: a filename or an URL
40
+ *
41
+ * Parse the resource and free the resulting tree
42
+ */
43
+ static void
44
+ example4Func(const char *filename) {
45
+ xmlParserCtxtPtr ctxt;
46
+ char chars[4];
47
+ xmlDocPtr doc; /* the resulting document tree */
48
+ int res;
49
+
50
+ /*
51
+ * Read a few first byte to check the input used for the
52
+ * encoding detection at the parser level.
53
+ */
54
+ res = readPacket(chars, 4);
55
+ if (res <= 0) {
56
+ fprintf(stderr, "Failed to parse %s\n", filename);
57
+ return;
58
+ }
59
+
60
+ /*
61
+ * Create a progressive parsing context, the 2 first arguments
62
+ * are not used since we want to build a tree and not use a SAX
63
+ * parsing interface. We also pass the first bytes of the document
64
+ * to allow encoding detection when creating the parser but this
65
+ * is optional.
66
+ */
67
+ ctxt = xmlCreatePushParserCtxt(NULL, NULL,
68
+ chars, res, filename);
69
+ if (ctxt == NULL) {
70
+ fprintf(stderr, "Failed to create parser context !\n");
71
+ return;
72
+ }
73
+
74
+ /*
75
+ * loop on the input getting the document data, of course 4 bytes
76
+ * at a time is not realistic but allows to verify testing on small
77
+ * documents.
78
+ */
79
+ while ((res = readPacket(chars, 4)) > 0) {
80
+ xmlParseChunk(ctxt, chars, res, 0);
81
+ }
82
+
83
+ /*
84
+ * there is no more input, indicate the parsing is finished.
85
+ */
86
+ xmlParseChunk(ctxt, chars, 0, 1);
87
+
88
+ /*
89
+ * collect the document back and if it was wellformed
90
+ * and destroy the parser context.
91
+ */
92
+ doc = ctxt->myDoc;
93
+ res = ctxt->wellFormed;
94
+ xmlFreeParserCtxt(ctxt);
95
+
96
+ if (!res) {
97
+ fprintf(stderr, "Failed to parse %s\n", filename);
98
+ }
99
+
100
+ /*
101
+ * since we don't use the document, destroy it now.
102
+ */
103
+ xmlFreeDoc(doc);
104
+ }
105
+
106
+ int main(int argc, char **argv) {
107
+ if (argc != 2)
108
+ return(1);
109
+
110
+ /*
111
+ * this initialize the library and check potential ABI mismatches
112
+ * between the version it was compiled for and the actual shared
113
+ * library used.
114
+ */
115
+ LIBXML_TEST_VERSION
116
+
117
+ /*
118
+ * simulate a progressive parsing using the input file.
119
+ */
120
+ desc = fopen(argv[1], "rb");
121
+ if (desc != NULL) {
122
+ example4Func(argv[1]);
123
+ fclose(desc);
124
+ } else {
125
+ fprintf(stderr, "Failed to parse %s\n", argv[1]);
126
+ }
127
+
128
+ return(0);
129
+ }
130
+ #else /* ! LIBXML_PUSH_ENABLED */
131
+ int main(void) {
132
+ fprintf(stderr, "Library not compiled with push parser support\n");
133
+ return(0);
134
+ }
135
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/reader1.c ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse an XML file with an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file
5
+ * and dump the information about the nodes found in the process.
6
+ * (Note that the XMLReader functions require libxml2 version later
7
+ * than 2.6.)
8
+ * usage: reader1 <filename>
9
+ * test: reader1 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
10
+ * author: Daniel Veillard
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <libxml/xmlreader.h>
16
+
17
+ #ifdef LIBXML_READER_ENABLED
18
+
19
+ /**
20
+ * processNode:
21
+ * @reader: the xmlReader
22
+ *
23
+ * Dump information about the current node
24
+ */
25
+ static void
26
+ processNode(xmlTextReaderPtr reader) {
27
+ const xmlChar *name, *value;
28
+
29
+ name = xmlTextReaderConstName(reader);
30
+ if (name == NULL)
31
+ name = BAD_CAST "--";
32
+
33
+ value = xmlTextReaderConstValue(reader);
34
+
35
+ printf("%d %d %s %d %d",
36
+ xmlTextReaderDepth(reader),
37
+ xmlTextReaderNodeType(reader),
38
+ name,
39
+ xmlTextReaderIsEmptyElement(reader),
40
+ xmlTextReaderHasValue(reader));
41
+ if (value == NULL)
42
+ printf("\n");
43
+ else {
44
+ if (xmlStrlen(value) > 40)
45
+ printf(" %.40s...\n", value);
46
+ else
47
+ printf(" %s\n", value);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * streamFile:
53
+ * @filename: the file name to parse
54
+ *
55
+ * Parse and print information about an XML file.
56
+ */
57
+ static void
58
+ streamFile(const char *filename) {
59
+ xmlTextReaderPtr reader;
60
+ int ret;
61
+
62
+ reader = xmlReaderForFile(filename, NULL, 0);
63
+ if (reader != NULL) {
64
+ ret = xmlTextReaderRead(reader);
65
+ while (ret == 1) {
66
+ processNode(reader);
67
+ ret = xmlTextReaderRead(reader);
68
+ }
69
+ xmlFreeTextReader(reader);
70
+ if (ret != 0) {
71
+ fprintf(stderr, "%s : failed to parse\n", filename);
72
+ }
73
+ } else {
74
+ fprintf(stderr, "Unable to open %s\n", filename);
75
+ }
76
+ }
77
+
78
+ int main(int argc, char **argv) {
79
+ if (argc != 2)
80
+ return(1);
81
+
82
+ /*
83
+ * this initialize the library and check potential ABI mismatches
84
+ * between the version it was compiled for and the actual shared
85
+ * library used.
86
+ */
87
+ LIBXML_TEST_VERSION
88
+
89
+ streamFile(argv[1]);
90
+
91
+ return(0);
92
+ }
93
+
94
+ #else
95
+ int main(void) {
96
+ fprintf(stderr, "XInclude support not compiled in\n");
97
+ return(0);
98
+ }
99
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/reader2.c ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse and validate an XML file with an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() to parse an XML file
5
+ * validating the content in the process and activating options
6
+ * like entities substitution, and DTD attributes defaulting.
7
+ * (Note that the XMLReader functions require libxml2 version later
8
+ * than 2.6.)
9
+ * usage: reader2 <valid_xml_filename>
10
+ * test: reader2 test2.xml > reader1.tmp && diff reader1.tmp $(srcdir)/reader1.res
11
+ * author: Daniel Veillard
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+
15
+ #include <stdio.h>
16
+ #include <libxml/xmlreader.h>
17
+ #include <libxml/parser.h>
18
+
19
+ #ifdef LIBXML_READER_ENABLED
20
+
21
+ /**
22
+ * processNode:
23
+ * @reader: the xmlReader
24
+ *
25
+ * Dump information about the current node
26
+ */
27
+ static void
28
+ processNode(xmlTextReaderPtr reader) {
29
+ const xmlChar *name, *value;
30
+
31
+ name = xmlTextReaderConstName(reader);
32
+ if (name == NULL)
33
+ name = BAD_CAST "--";
34
+
35
+ value = xmlTextReaderConstValue(reader);
36
+
37
+ printf("%d %d %s %d %d",
38
+ xmlTextReaderDepth(reader),
39
+ xmlTextReaderNodeType(reader),
40
+ name,
41
+ xmlTextReaderIsEmptyElement(reader),
42
+ xmlTextReaderHasValue(reader));
43
+ if (value == NULL)
44
+ printf("\n");
45
+ else {
46
+ if (xmlStrlen(value) > 40)
47
+ printf(" %.40s...\n", value);
48
+ else
49
+ printf(" %s\n", value);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * streamFile:
55
+ * @filename: the file name to parse
56
+ *
57
+ * Parse, validate and print information about an XML file.
58
+ */
59
+ static void
60
+ streamFile(const char *filename) {
61
+ xmlTextReaderPtr reader;
62
+ int ret;
63
+
64
+
65
+ /*
66
+ * Pass some special parsing options to activate DTD attribute defaulting,
67
+ * entities substitution and DTD validation
68
+ */
69
+ reader = xmlReaderForFile(filename, NULL,
70
+ XML_PARSE_DTDATTR | /* default DTD attributes */
71
+ XML_PARSE_NOENT | /* substitute entities */
72
+ XML_PARSE_DTDVALID); /* validate with the DTD */
73
+ if (reader != NULL) {
74
+ ret = xmlTextReaderRead(reader);
75
+ while (ret == 1) {
76
+ processNode(reader);
77
+ ret = xmlTextReaderRead(reader);
78
+ }
79
+ /*
80
+ * Once the document has been fully parsed check the validation results
81
+ */
82
+ if (xmlTextReaderIsValid(reader) != 1) {
83
+ fprintf(stderr, "Document %s does not validate\n", filename);
84
+ }
85
+ xmlFreeTextReader(reader);
86
+ if (ret != 0) {
87
+ fprintf(stderr, "%s : failed to parse\n", filename);
88
+ }
89
+ } else {
90
+ fprintf(stderr, "Unable to open %s\n", filename);
91
+ }
92
+ }
93
+
94
+ int main(int argc, char **argv) {
95
+ if (argc != 2)
96
+ return(1);
97
+
98
+ /*
99
+ * this initialize the library and check potential ABI mismatches
100
+ * between the version it was compiled for and the actual shared
101
+ * library used.
102
+ */
103
+ LIBXML_TEST_VERSION
104
+
105
+ streamFile(argv[1]);
106
+
107
+ return(0);
108
+ }
109
+
110
+ #else
111
+ int main(void) {
112
+ fprintf(stderr, "XInclude support not compiled in\n");
113
+ return(0);
114
+ }
115
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/reader3.c ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Show how to extract subdocuments with xmlReader
4
+ * purpose: Demonstrate the use of xmlTextReaderPreservePattern()
5
+ * to parse an XML file with the xmlReader while collecting
6
+ * only some subparts of the document.
7
+ * (Note that the XMLReader functions require libxml2 version later
8
+ * than 2.6.)
9
+ * usage: reader3
10
+ * test: reader3 > reader3.tmp && diff reader3.tmp $(srcdir)/reader3.res
11
+ * author: Daniel Veillard
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+
15
+ #include <stdio.h>
16
+ #include <libxml/xmlreader.h>
17
+
18
+ #if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
19
+
20
+
21
+ /**
22
+ * streamFile:
23
+ * @filename: the file name to parse
24
+ *
25
+ * Parse and print information about an XML file.
26
+ *
27
+ * Returns the resulting doc with just the elements preserved.
28
+ */
29
+ static xmlDocPtr
30
+ extractFile(const char *filename, const xmlChar *pattern) {
31
+ xmlDocPtr doc;
32
+ xmlTextReaderPtr reader;
33
+ int ret;
34
+
35
+ /*
36
+ * build an xmlReader for that file
37
+ */
38
+ reader = xmlReaderForFile(filename, NULL, 0);
39
+ if (reader != NULL) {
40
+ /*
41
+ * add the pattern to preserve
42
+ */
43
+ if (xmlTextReaderPreservePattern(reader, pattern, NULL) < 0) {
44
+ fprintf(stderr, "%s : failed add preserve pattern %s\n",
45
+ filename, (const char *) pattern);
46
+ }
47
+ /*
48
+ * Parse and traverse the tree, collecting the nodes in the process
49
+ */
50
+ ret = xmlTextReaderRead(reader);
51
+ while (ret == 1) {
52
+ ret = xmlTextReaderRead(reader);
53
+ }
54
+ if (ret != 0) {
55
+ fprintf(stderr, "%s : failed to parse\n", filename);
56
+ xmlFreeTextReader(reader);
57
+ return(NULL);
58
+ }
59
+ /*
60
+ * get the resulting nodes
61
+ */
62
+ doc = xmlTextReaderCurrentDoc(reader);
63
+ /*
64
+ * Free up the reader
65
+ */
66
+ xmlFreeTextReader(reader);
67
+ } else {
68
+ fprintf(stderr, "Unable to open %s\n", filename);
69
+ return(NULL);
70
+ }
71
+ return(doc);
72
+ }
73
+
74
+ int main(int argc, char **argv) {
75
+ const char *filename = "test3.xml";
76
+ const char *pattern = "preserved";
77
+ xmlDocPtr doc;
78
+
79
+ if (argc == 3) {
80
+ filename = argv[1];
81
+ pattern = argv[2];
82
+ }
83
+
84
+ /*
85
+ * this initialize the library and check potential ABI mismatches
86
+ * between the version it was compiled for and the actual shared
87
+ * library used.
88
+ */
89
+ LIBXML_TEST_VERSION
90
+
91
+ doc = extractFile(filename, (const xmlChar *) pattern);
92
+ if (doc != NULL) {
93
+ /*
94
+ * output the result.
95
+ */
96
+ xmlDocDump(stdout, doc);
97
+ /*
98
+ * don't forget to free up the doc
99
+ */
100
+ xmlFreeDoc(doc);
101
+ }
102
+
103
+ return(0);
104
+ }
105
+
106
+ #else
107
+ int main(void) {
108
+ fprintf(stderr, "Reader, Pattern or output support not compiled in\n");
109
+ return(0);
110
+ }
111
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/reader4.c ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlReader
3
+ * synopsis: Parse multiple XML files reusing an xmlReader
4
+ * purpose: Demonstrate the use of xmlReaderForFile() and
5
+ * xmlReaderNewFile to parse XML files while reusing the reader object
6
+ * and parser context. (Note that the XMLReader functions require
7
+ * libxml2 version later than 2.6.)
8
+ * usage: reader4 <filename> [ filename ... ]
9
+ * test: reader4 test1.xml test2.xml test3.xml > reader4.tmp && diff reader4.tmp $(srcdir)/reader4.res
10
+ * author: Graham Bennett
11
+ * copy: see Copyright for the status of this software.
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <libxml/xmlreader.h>
16
+
17
+ #ifdef LIBXML_READER_ENABLED
18
+
19
+ static void processDoc(xmlTextReaderPtr readerPtr) {
20
+ int ret;
21
+ xmlDocPtr docPtr;
22
+ const xmlChar *URL;
23
+
24
+ ret = xmlTextReaderRead(readerPtr);
25
+ while (ret == 1) {
26
+ ret = xmlTextReaderRead(readerPtr);
27
+ }
28
+
29
+ /*
30
+ * One can obtain the document pointer to get interesting
31
+ * information about the document like the URL, but one must also
32
+ * be sure to clean it up at the end (see below).
33
+ */
34
+ docPtr = xmlTextReaderCurrentDoc(readerPtr);
35
+ if (NULL == docPtr) {
36
+ fprintf(stderr, "failed to obtain document\n");
37
+ return;
38
+ }
39
+
40
+ URL = docPtr->URL;
41
+ if (NULL == URL) {
42
+ fprintf(stderr, "Failed to obtain URL\n");
43
+ }
44
+
45
+ if (ret != 0) {
46
+ fprintf(stderr, "%s: Failed to parse\n", URL);
47
+ return;
48
+ }
49
+
50
+ printf("%s: Processed ok\n", (const char *)URL);
51
+ }
52
+
53
+ int main(int argc, char **argv) {
54
+ xmlTextReaderPtr readerPtr;
55
+ int i;
56
+ xmlDocPtr docPtr;
57
+
58
+ if (argc < 2)
59
+ return(1);
60
+
61
+ /*
62
+ * this initialises the library and check potential ABI mismatches
63
+ * between the version it was compiled for and the actual shared
64
+ * library used.
65
+ */
66
+ LIBXML_TEST_VERSION
67
+
68
+ /*
69
+ * Create a new reader for the first file and process the
70
+ * document.
71
+ */
72
+ readerPtr = xmlReaderForFile(argv[1], NULL, 0);
73
+ if (NULL == readerPtr) {
74
+ fprintf(stderr, "%s: failed to create reader\n", argv[1]);
75
+ return(1);
76
+ }
77
+ processDoc(readerPtr);
78
+
79
+ /*
80
+ * The reader can be reused for subsequent files.
81
+ */
82
+ for (i=2; i < argc; ++i) {
83
+ xmlReaderNewFile(readerPtr, argv[i], NULL, 0);
84
+ if (NULL == readerPtr) {
85
+ fprintf(stderr, "%s: failed to create reader\n", argv[i]);
86
+ return(1);
87
+ }
88
+ processDoc(readerPtr);
89
+ }
90
+
91
+ /*
92
+ * Since we've called xmlTextReaderCurrentDoc, we now have to
93
+ * clean up after ourselves. We only have to do this the last
94
+ * time, because xmlReaderNewFile calls xmlCtxtReset which takes
95
+ * care of it.
96
+ */
97
+ docPtr = xmlTextReaderCurrentDoc(readerPtr);
98
+ if (docPtr != NULL)
99
+ xmlFreeDoc(docPtr);
100
+
101
+ /*
102
+ * Clean up the reader.
103
+ */
104
+ xmlFreeTextReader(readerPtr);
105
+
106
+ return(0);
107
+ }
108
+
109
+ #else
110
+ int main(void) {
111
+ fprintf(stderr, "xmlReader support not compiled in\n");
112
+ return(0);
113
+ }
114
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/test1.xml ADDED
@@ -0,0 +1 @@
 
 
1
+ <doc/>
local-test-libxml2-delta-01/afc-libxml2/example/test2.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE doc [
2
+ <!ELEMENT doc (src | dest)*>
3
+ <!ELEMENT src EMPTY>
4
+ <!ELEMENT dest EMPTY>
5
+ <!ATTLIST src ref IDREF #IMPLIED>
6
+ <!ATTLIST dest id ID #IMPLIED>
7
+ ]>
8
+ <doc>
9
+ <src ref="foo"/>
10
+ <dest id="foo"/>
11
+ <src ref="foo"/>
12
+ </doc>
13
+
local-test-libxml2-delta-01/afc-libxml2/example/test3.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <doc>
2
+ <parent>
3
+ <discarded>
4
+ <discarded/>
5
+ </discarded>
6
+ <preserved/>
7
+ This text node must be discarded
8
+ <discarded>
9
+ <discarded/>
10
+ </discarded>
11
+ <preserved>
12
+ content1
13
+ <child1></child1>
14
+ <child2>content2</child2>
15
+ <preserved>too</preserved>
16
+ <child2>content3</child2>
17
+ <preserved></preserved>
18
+ <child2>content4</child2>
19
+ <preserved/>
20
+ <child2>content5</child2>
21
+ content6
22
+ </preserved>
23
+ This text node must be discarded
24
+ <discarded>
25
+ <discarded/>
26
+ </discarded>
27
+ This text node must be discarded
28
+ <preserved></preserved>
29
+ This text node must be discarded
30
+ <preserved/>
31
+ This text node must be discarded
32
+ <discarded>
33
+ <discarded/>
34
+ </discarded>
35
+ This text node must be discarded
36
+ </parent>
37
+ </doc>
38
+
39
+
local-test-libxml2-delta-01/afc-libxml2/example/testWriter.c ADDED
@@ -0,0 +1,1068 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: xmlWriter
3
+ * synopsis: use various APIs for the xmlWriter
4
+ * purpose: tests a number of APIs for the xmlWriter, especially
5
+ * the various methods to write to a filename, to a memory
6
+ * buffer, to a new document, or to a subtree. It shows how to
7
+ * do encoding string conversions too. The resulting
8
+ * documents are then serialized.
9
+ * usage: testWriter
10
+ * test: testWriter && for i in 1 2 3 4 ; do diff $(srcdir)/writer.xml writer$$i.tmp || break ; done
11
+ * author: Alfred Mickautsch
12
+ * copy: see Copyright for the status of this software.
13
+ */
14
+ #include <stdio.h>
15
+ #include <string.h>
16
+ #include <libxml/encoding.h>
17
+ #include <libxml/xmlwriter.h>
18
+ #include <libxml/parser.h>
19
+
20
+ #ifndef _WIN32
21
+ #include <unistd.h>
22
+ #endif
23
+
24
+ #if defined(LIBXML_WRITER_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
25
+
26
+ #define MY_ENCODING "ISO-8859-1"
27
+
28
+ void testXmlwriterFilename(const char *uri);
29
+ void testXmlwriterMemory(void);
30
+ void testXmlwriterDoc(void);
31
+ void testXmlwriterTree(void);
32
+
33
+ int
34
+ main(void)
35
+ {
36
+ /*
37
+ * this initialize the library and check potential ABI mismatches
38
+ * between the version it was compiled for and the actual shared
39
+ * library used.
40
+ */
41
+ LIBXML_TEST_VERSION
42
+
43
+ /* first, the file version */
44
+ testXmlwriterFilename("writer1.tmp");
45
+ unlink("writer1.tmp");
46
+
47
+ /* next, the memory version */
48
+ testXmlwriterMemory();
49
+
50
+ /* next, the DOM version */
51
+ testXmlwriterDoc();
52
+
53
+ /* next, the tree version */
54
+ testXmlwriterTree();
55
+
56
+ return 0;
57
+ }
58
+
59
+ /**
60
+ * testXmlwriterFilename:
61
+ * @uri: the output URI
62
+ *
63
+ * test the xmlWriter interface when writing to a new file
64
+ */
65
+ void
66
+ testXmlwriterFilename(const char *uri)
67
+ {
68
+ int rc;
69
+ xmlTextWriterPtr writer;
70
+
71
+ /* Create a new XmlWriter for uri, with no compression. */
72
+ writer = xmlNewTextWriterFilename(uri, 0);
73
+ if (writer == NULL) {
74
+ printf("testXmlwriterFilename: Error creating the xml writer\n");
75
+ return;
76
+ }
77
+
78
+ /* Start the document with the xml default for the version,
79
+ * encoding ISO 8859-1 and the default for the standalone
80
+ * declaration. */
81
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
82
+ if (rc < 0) {
83
+ printf
84
+ ("testXmlwriterFilename: Error at xmlTextWriterStartDocument\n");
85
+ return;
86
+ }
87
+
88
+ /* Start an element named "EXAMPLE". Since this is the first
89
+ * element, this will be the root element of the document. */
90
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
91
+ if (rc < 0) {
92
+ printf
93
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
94
+ return;
95
+ }
96
+
97
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
98
+ if (rc < 0) {
99
+ printf
100
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteComment\n");
101
+ return;
102
+ }
103
+
104
+ /* Start an element named "ORDER" as child of EXAMPLE. */
105
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
106
+ if (rc < 0) {
107
+ printf
108
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
109
+ return;
110
+ }
111
+
112
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
113
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
114
+ BAD_CAST "1.0");
115
+ if (rc < 0) {
116
+ printf
117
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n");
118
+ return;
119
+ }
120
+
121
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
122
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
123
+ BAD_CAST "de");
124
+ if (rc < 0) {
125
+ printf
126
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteAttribute\n");
127
+ return;
128
+ }
129
+
130
+ /* Write a comment as child of ORDER */
131
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
132
+ if (rc < 0) {
133
+ printf
134
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatComment\n");
135
+ return;
136
+ }
137
+
138
+ /* Start an element named "HEADER" as child of ORDER. */
139
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
140
+ if (rc < 0) {
141
+ printf
142
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
143
+ return;
144
+ }
145
+
146
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
147
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
148
+ "%010d", 53535);
149
+ if (rc < 0) {
150
+ printf
151
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
152
+ return;
153
+ }
154
+
155
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
156
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
157
+ "%d", 1010);
158
+ if (rc < 0) {
159
+ printf
160
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
161
+ return;
162
+ }
163
+
164
+ /* Write an element named "NAME_1" as child of HEADER. */
165
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
166
+ BAD_CAST "Mueller");
167
+ if (rc < 0) {
168
+ printf
169
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
170
+ return;
171
+ }
172
+
173
+ /* Write an element named "NAME_2" as child of HEADER. */
174
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
175
+ BAD_CAST "Joerg");
176
+ if (rc < 0) {
177
+ printf
178
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
179
+ return;
180
+ }
181
+
182
+ /* Close the element named HEADER. */
183
+ rc = xmlTextWriterEndElement(writer);
184
+ if (rc < 0) {
185
+ printf
186
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
187
+ return;
188
+ }
189
+
190
+ /* Start an element named "ENTRIES" as child of ORDER. */
191
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
192
+ if (rc < 0) {
193
+ printf
194
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
195
+ return;
196
+ }
197
+
198
+ /* Start an element named "ENTRY" as child of ENTRIES. */
199
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
200
+ if (rc < 0) {
201
+ printf
202
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
203
+ return;
204
+ }
205
+
206
+ /* Write an element named "ARTICLE" as child of ENTRY. */
207
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
208
+ BAD_CAST "<Test>");
209
+ if (rc < 0) {
210
+ printf
211
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
212
+ return;
213
+ }
214
+
215
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
216
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
217
+ 10);
218
+ if (rc < 0) {
219
+ printf
220
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
221
+ return;
222
+ }
223
+
224
+ /* Close the element named ENTRY. */
225
+ rc = xmlTextWriterEndElement(writer);
226
+ if (rc < 0) {
227
+ printf
228
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
229
+ return;
230
+ }
231
+
232
+ /* Start an element named "ENTRY" as child of ENTRIES. */
233
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
234
+ if (rc < 0) {
235
+ printf
236
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
237
+ return;
238
+ }
239
+
240
+ /* Write an element named "ARTICLE" as child of ENTRY. */
241
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
242
+ BAD_CAST "<Test 2>");
243
+ if (rc < 0) {
244
+ printf
245
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
246
+ return;
247
+ }
248
+
249
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
250
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
251
+ 20);
252
+ if (rc < 0) {
253
+ printf
254
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteFormatElement\n");
255
+ return;
256
+ }
257
+
258
+ /* Close the element named ENTRY. */
259
+ rc = xmlTextWriterEndElement(writer);
260
+ if (rc < 0) {
261
+ printf
262
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
263
+ return;
264
+ }
265
+
266
+ /* Close the element named ENTRIES. */
267
+ rc = xmlTextWriterEndElement(writer);
268
+ if (rc < 0) {
269
+ printf
270
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
271
+ return;
272
+ }
273
+
274
+ /* Start an element named "FOOTER" as child of ORDER. */
275
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
276
+ if (rc < 0) {
277
+ printf
278
+ ("testXmlwriterFilename: Error at xmlTextWriterStartElement\n");
279
+ return;
280
+ }
281
+
282
+ /* Write an element named "TEXT" as child of FOOTER. */
283
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
284
+ BAD_CAST "This is a text.");
285
+ if (rc < 0) {
286
+ printf
287
+ ("testXmlwriterFilename: Error at xmlTextWriterWriteElement\n");
288
+ return;
289
+ }
290
+
291
+ /* Close the element named FOOTER. */
292
+ rc = xmlTextWriterEndElement(writer);
293
+ if (rc < 0) {
294
+ printf
295
+ ("testXmlwriterFilename: Error at xmlTextWriterEndElement\n");
296
+ return;
297
+ }
298
+
299
+ /* Here we could close the elements ORDER and EXAMPLE using the
300
+ * function xmlTextWriterEndElement, but since we do not want to
301
+ * write any other elements, we simply call xmlTextWriterEndDocument,
302
+ * which will do all the work. */
303
+ rc = xmlTextWriterEndDocument(writer);
304
+ if (rc < 0) {
305
+ printf
306
+ ("testXmlwriterFilename: Error at xmlTextWriterEndDocument\n");
307
+ return;
308
+ }
309
+
310
+ xmlFreeTextWriter(writer);
311
+ }
312
+
313
+ /**
314
+ * testXmlwriterMemory:
315
+ * @file: the output file
316
+ *
317
+ * test the xmlWriter interface when writing to memory
318
+ */
319
+ void
320
+ testXmlwriterMemory(void)
321
+ {
322
+ int rc;
323
+ xmlTextWriterPtr writer;
324
+ xmlBufferPtr buf;
325
+
326
+ /* Create a new XML buffer, to which the XML document will be
327
+ * written */
328
+ buf = xmlBufferCreate();
329
+ if (buf == NULL) {
330
+ printf("testXmlwriterMemory: Error creating the xml buffer\n");
331
+ return;
332
+ }
333
+
334
+ /* Create a new XmlWriter for memory, with no compression.
335
+ * Remark: there is no compression for this kind of xmlTextWriter */
336
+ writer = xmlNewTextWriterMemory(buf, 0);
337
+ if (writer == NULL) {
338
+ printf("testXmlwriterMemory: Error creating the xml writer\n");
339
+ return;
340
+ }
341
+
342
+ /* Start the document with the xml default for the version,
343
+ * encoding ISO 8859-1 and the default for the standalone
344
+ * declaration. */
345
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
346
+ if (rc < 0) {
347
+ printf
348
+ ("testXmlwriterMemory: Error at xmlTextWriterStartDocument\n");
349
+ return;
350
+ }
351
+
352
+ /* Start an element named "EXAMPLE". Since this is the first
353
+ * element, this will be the root element of the document. */
354
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
355
+ if (rc < 0) {
356
+ printf
357
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
358
+ return;
359
+ }
360
+
361
+ /* Write a comment as child of EXAMPLE. */
362
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
363
+ if (rc < 0) {
364
+ printf
365
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteComment\n");
366
+ return;
367
+ }
368
+
369
+ /* Start an element named "ORDER" as child of EXAMPLE. */
370
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
371
+ if (rc < 0) {
372
+ printf
373
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
374
+ return;
375
+ }
376
+
377
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
378
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
379
+ BAD_CAST "1.0");
380
+ if (rc < 0) {
381
+ printf
382
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n");
383
+ return;
384
+ }
385
+
386
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
387
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
388
+ BAD_CAST "de");
389
+ if (rc < 0) {
390
+ printf
391
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteAttribute\n");
392
+ return;
393
+ }
394
+
395
+ /* Write a comment as child of ORDER */
396
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
397
+ if (rc < 0) {
398
+ printf
399
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatComment\n");
400
+ return;
401
+ }
402
+
403
+ /* Start an element named "HEADER" as child of ORDER. */
404
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
405
+ if (rc < 0) {
406
+ printf
407
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
408
+ return;
409
+ }
410
+
411
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
412
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
413
+ "%010d", 53535);
414
+ if (rc < 0) {
415
+ printf
416
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
417
+ return;
418
+ }
419
+
420
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
421
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
422
+ "%d", 1010);
423
+ if (rc < 0) {
424
+ printf
425
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
426
+ return;
427
+ }
428
+
429
+ /* Write an element named "NAME_1" as child of HEADER. */
430
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
431
+ BAD_CAST "Mueller");
432
+ if (rc < 0) {
433
+ printf
434
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
435
+ return;
436
+ }
437
+
438
+ /* Write an element named "NAME_2" as child of HEADER. */
439
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
440
+ BAD_CAST "Joerg");
441
+
442
+ if (rc < 0) {
443
+ printf
444
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
445
+ return;
446
+ }
447
+
448
+ /* Close the element named HEADER. */
449
+ rc = xmlTextWriterEndElement(writer);
450
+ if (rc < 0) {
451
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
452
+ return;
453
+ }
454
+
455
+ /* Start an element named "ENTRIES" as child of ORDER. */
456
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
457
+ if (rc < 0) {
458
+ printf
459
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
460
+ return;
461
+ }
462
+
463
+ /* Start an element named "ENTRY" as child of ENTRIES. */
464
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
465
+ if (rc < 0) {
466
+ printf
467
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
468
+ return;
469
+ }
470
+
471
+ /* Write an element named "ARTICLE" as child of ENTRY. */
472
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
473
+ BAD_CAST "<Test>");
474
+ if (rc < 0) {
475
+ printf
476
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
477
+ return;
478
+ }
479
+
480
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
481
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
482
+ 10);
483
+ if (rc < 0) {
484
+ printf
485
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
486
+ return;
487
+ }
488
+
489
+ /* Close the element named ENTRY. */
490
+ rc = xmlTextWriterEndElement(writer);
491
+ if (rc < 0) {
492
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
493
+ return;
494
+ }
495
+
496
+ /* Start an element named "ENTRY" as child of ENTRIES. */
497
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
498
+ if (rc < 0) {
499
+ printf
500
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
501
+ return;
502
+ }
503
+
504
+ /* Write an element named "ARTICLE" as child of ENTRY. */
505
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
506
+ BAD_CAST "<Test 2>");
507
+ if (rc < 0) {
508
+ printf
509
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
510
+ return;
511
+ }
512
+
513
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
514
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
515
+ 20);
516
+ if (rc < 0) {
517
+ printf
518
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteFormatElement\n");
519
+ return;
520
+ }
521
+
522
+ /* Close the element named ENTRY. */
523
+ rc = xmlTextWriterEndElement(writer);
524
+ if (rc < 0) {
525
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
526
+ return;
527
+ }
528
+
529
+ /* Close the element named ENTRIES. */
530
+ rc = xmlTextWriterEndElement(writer);
531
+ if (rc < 0) {
532
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
533
+ return;
534
+ }
535
+
536
+ /* Start an element named "FOOTER" as child of ORDER. */
537
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
538
+ if (rc < 0) {
539
+ printf
540
+ ("testXmlwriterMemory: Error at xmlTextWriterStartElement\n");
541
+ return;
542
+ }
543
+
544
+ /* Write an element named "TEXT" as child of FOOTER. */
545
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
546
+ BAD_CAST "This is a text.");
547
+ if (rc < 0) {
548
+ printf
549
+ ("testXmlwriterMemory: Error at xmlTextWriterWriteElement\n");
550
+ return;
551
+ }
552
+
553
+ /* Close the element named FOOTER. */
554
+ rc = xmlTextWriterEndElement(writer);
555
+ if (rc < 0) {
556
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndElement\n");
557
+ return;
558
+ }
559
+
560
+ /* Here we could close the elements ORDER and EXAMPLE using the
561
+ * function xmlTextWriterEndElement, but since we do not want to
562
+ * write any other elements, we simply call xmlTextWriterEndDocument,
563
+ * which will do all the work. */
564
+ rc = xmlTextWriterEndDocument(writer);
565
+ if (rc < 0) {
566
+ printf("testXmlwriterMemory: Error at xmlTextWriterEndDocument\n");
567
+ return;
568
+ }
569
+
570
+ xmlFreeTextWriter(writer);
571
+
572
+ xmlBufferFree(buf);
573
+ }
574
+
575
+ /**
576
+ * testXmlwriterDoc:
577
+ * @file: the output file
578
+ *
579
+ * test the xmlWriter interface when creating a new document
580
+ */
581
+ void
582
+ testXmlwriterDoc(void)
583
+ {
584
+ int rc;
585
+ xmlTextWriterPtr writer;
586
+ xmlDocPtr doc;
587
+
588
+
589
+ /* Create a new XmlWriter for DOM, with no compression. */
590
+ writer = xmlNewTextWriterDoc(&doc, 0);
591
+ if (writer == NULL) {
592
+ printf("testXmlwriterDoc: Error creating the xml writer\n");
593
+ return;
594
+ }
595
+
596
+ /* Start the document with the xml default for the version,
597
+ * encoding ISO 8859-1 and the default for the standalone
598
+ * declaration. */
599
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
600
+ if (rc < 0) {
601
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartDocument\n");
602
+ return;
603
+ }
604
+
605
+ /* Start an element named "EXAMPLE". Since this is the first
606
+ * element, this will be the root element of the document. */
607
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "EXAMPLE");
608
+ if (rc < 0) {
609
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
610
+ return;
611
+ }
612
+
613
+ /* Write a comment as child of EXAMPLE. */
614
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
615
+ if (rc < 0) {
616
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteComment\n");
617
+ return;
618
+ }
619
+
620
+ /* Start an element named "ORDER" as child of EXAMPLE. */
621
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
622
+ if (rc < 0) {
623
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
624
+ return;
625
+ }
626
+
627
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
628
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
629
+ BAD_CAST "1.0");
630
+ if (rc < 0) {
631
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n");
632
+ return;
633
+ }
634
+
635
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
636
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
637
+ BAD_CAST "de");
638
+ if (rc < 0) {
639
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteAttribute\n");
640
+ return;
641
+ }
642
+
643
+ /* Write a comment as child of ORDER */
644
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
645
+ if (rc < 0) {
646
+ printf
647
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatComment\n");
648
+ return;
649
+ }
650
+
651
+ /* Start an element named "HEADER" as child of ORDER. */
652
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
653
+ if (rc < 0) {
654
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
655
+ return;
656
+ }
657
+
658
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
659
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
660
+ "%010d", 53535);
661
+ if (rc < 0) {
662
+ printf
663
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
664
+ return;
665
+ }
666
+
667
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
668
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
669
+ "%d", 1010);
670
+ if (rc < 0) {
671
+ printf
672
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
673
+ return;
674
+ }
675
+
676
+ /* Write an element named "NAME_1" as child of HEADER. */
677
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
678
+ BAD_CAST "Mueller");
679
+ if (rc < 0) {
680
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
681
+ return;
682
+ }
683
+
684
+ /* Write an element named "NAME_2" as child of HEADER. */
685
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
686
+ BAD_CAST "Joerg");
687
+ if (rc < 0) {
688
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
689
+ return;
690
+ }
691
+
692
+ /* Close the element named HEADER. */
693
+ rc = xmlTextWriterEndElement(writer);
694
+ if (rc < 0) {
695
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
696
+ return;
697
+ }
698
+
699
+ /* Start an element named "ENTRIES" as child of ORDER. */
700
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
701
+ if (rc < 0) {
702
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
703
+ return;
704
+ }
705
+
706
+ /* Start an element named "ENTRY" as child of ENTRIES. */
707
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
708
+ if (rc < 0) {
709
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
710
+ return;
711
+ }
712
+
713
+ /* Write an element named "ARTICLE" as child of ENTRY. */
714
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
715
+ BAD_CAST "<Test>");
716
+ if (rc < 0) {
717
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
718
+ return;
719
+ }
720
+
721
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
722
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
723
+ 10);
724
+ if (rc < 0) {
725
+ printf
726
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
727
+ return;
728
+ }
729
+
730
+ /* Close the element named ENTRY. */
731
+ rc = xmlTextWriterEndElement(writer);
732
+ if (rc < 0) {
733
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
734
+ return;
735
+ }
736
+
737
+ /* Start an element named "ENTRY" as child of ENTRIES. */
738
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
739
+ if (rc < 0) {
740
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
741
+ return;
742
+ }
743
+
744
+ /* Write an element named "ARTICLE" as child of ENTRY. */
745
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
746
+ BAD_CAST "<Test 2>");
747
+ if (rc < 0) {
748
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
749
+ return;
750
+ }
751
+
752
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
753
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
754
+ 20);
755
+ if (rc < 0) {
756
+ printf
757
+ ("testXmlwriterDoc: Error at xmlTextWriterWriteFormatElement\n");
758
+ return;
759
+ }
760
+
761
+ /* Close the element named ENTRY. */
762
+ rc = xmlTextWriterEndElement(writer);
763
+ if (rc < 0) {
764
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
765
+ return;
766
+ }
767
+
768
+ /* Close the element named ENTRIES. */
769
+ rc = xmlTextWriterEndElement(writer);
770
+ if (rc < 0) {
771
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
772
+ return;
773
+ }
774
+
775
+ /* Start an element named "FOOTER" as child of ORDER. */
776
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
777
+ if (rc < 0) {
778
+ printf("testXmlwriterDoc: Error at xmlTextWriterStartElement\n");
779
+ return;
780
+ }
781
+
782
+ /* Write an element named "TEXT" as child of FOOTER. */
783
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
784
+ BAD_CAST "This is a text.");
785
+ if (rc < 0) {
786
+ printf("testXmlwriterDoc: Error at xmlTextWriterWriteElement\n");
787
+ return;
788
+ }
789
+
790
+ /* Close the element named FOOTER. */
791
+ rc = xmlTextWriterEndElement(writer);
792
+ if (rc < 0) {
793
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndElement\n");
794
+ return;
795
+ }
796
+
797
+ /* Here we could close the elements ORDER and EXAMPLE using the
798
+ * function xmlTextWriterEndElement, but since we do not want to
799
+ * write any other elements, we simply call xmlTextWriterEndDocument,
800
+ * which will do all the work. */
801
+ rc = xmlTextWriterEndDocument(writer);
802
+ if (rc < 0) {
803
+ printf("testXmlwriterDoc: Error at xmlTextWriterEndDocument\n");
804
+ return;
805
+ }
806
+
807
+ xmlFreeTextWriter(writer);
808
+
809
+ xmlFreeDoc(doc);
810
+ }
811
+
812
+ /**
813
+ * testXmlwriterTree:
814
+ * @file: the output file
815
+ *
816
+ * test the xmlWriter interface when writing to a subtree
817
+ */
818
+ void
819
+ testXmlwriterTree(void)
820
+ {
821
+ int rc;
822
+ xmlTextWriterPtr writer;
823
+ xmlDocPtr doc;
824
+ xmlNodePtr node;
825
+
826
+ /* Create a new XML DOM tree, to which the XML document will be
827
+ * written */
828
+ doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
829
+ if (doc == NULL) {
830
+ printf
831
+ ("testXmlwriterTree: Error creating the xml document tree\n");
832
+ return;
833
+ }
834
+
835
+ /* Create a new XML node, to which the XML document will be
836
+ * appended */
837
+ node = xmlNewDocNode(doc, NULL, BAD_CAST "EXAMPLE", NULL);
838
+ if (node == NULL) {
839
+ printf("testXmlwriterTree: Error creating the xml node\n");
840
+ return;
841
+ }
842
+
843
+ /* Make ELEMENT the root node of the tree */
844
+ xmlDocSetRootElement(doc, node);
845
+
846
+ /* Create a new XmlWriter for DOM tree, with no compression. */
847
+ writer = xmlNewTextWriterTree(doc, node, 0);
848
+ if (writer == NULL) {
849
+ printf("testXmlwriterTree: Error creating the xml writer\n");
850
+ return;
851
+ }
852
+
853
+ /* Start the document with the xml default for the version,
854
+ * encoding ISO 8859-1 and the default for the standalone
855
+ * declaration. */
856
+ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL);
857
+ if (rc < 0) {
858
+ printf("testXmlwriterTree: Error at xmlTextWriterStartDocument\n");
859
+ return;
860
+ }
861
+
862
+ /* Write a comment as child of EXAMPLE. */
863
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is a comment");
864
+ if (rc < 0) {
865
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteComment\n");
866
+ return;
867
+ }
868
+
869
+ /* Start an element named "ORDER" as child of EXAMPLE. */
870
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ORDER");
871
+ if (rc < 0) {
872
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
873
+ return;
874
+ }
875
+
876
+ /* Add an attribute with name "version" and value "1.0" to ORDER. */
877
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "version",
878
+ BAD_CAST "1.0");
879
+ if (rc < 0) {
880
+ printf
881
+ ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n");
882
+ return;
883
+ }
884
+
885
+ /* Add an attribute with name "xml:lang" and value "de" to ORDER. */
886
+ rc = xmlTextWriterWriteAttribute(writer, BAD_CAST "xml:lang",
887
+ BAD_CAST "de");
888
+ if (rc < 0) {
889
+ printf
890
+ ("testXmlwriterTree: Error at xmlTextWriterWriteAttribute\n");
891
+ return;
892
+ }
893
+
894
+ /* Write a comment as child of ORDER */
895
+ rc = xmlTextWriterWriteComment(writer, BAD_CAST "This is another comment");
896
+ if (rc < 0) {
897
+ printf
898
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatComment\n");
899
+ return;
900
+ }
901
+
902
+ /* Start an element named "HEADER" as child of ORDER. */
903
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "HEADER");
904
+ if (rc < 0) {
905
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
906
+ return;
907
+ }
908
+
909
+ /* Write an element named "X_ORDER_ID" as child of HEADER. */
910
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "X_ORDER_ID",
911
+ "%010d", 53535);
912
+ if (rc < 0) {
913
+ printf
914
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
915
+ return;
916
+ }
917
+
918
+ /* Write an element named "CUSTOMER_ID" as child of HEADER. */
919
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CUSTOMER_ID",
920
+ "%d", 1010);
921
+ if (rc < 0) {
922
+ printf
923
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
924
+ return;
925
+ }
926
+
927
+ /* Write an element named "NAME_1" as child of HEADER. */
928
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_1",
929
+ BAD_CAST "Mueller");
930
+ if (rc < 0) {
931
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
932
+ return;
933
+ }
934
+
935
+ /* Write an element named "NAME_2" as child of HEADER. */
936
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "NAME_2",
937
+ BAD_CAST "Joerg");
938
+ if (rc < 0) {
939
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
940
+ return;
941
+ }
942
+
943
+ /* Close the element named HEADER. */
944
+ rc = xmlTextWriterEndElement(writer);
945
+ if (rc < 0) {
946
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
947
+ return;
948
+ }
949
+
950
+ /* Start an element named "ENTRIES" as child of ORDER. */
951
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRIES");
952
+ if (rc < 0) {
953
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
954
+ return;
955
+ }
956
+
957
+ /* Start an element named "ENTRY" as child of ENTRIES. */
958
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
959
+ if (rc < 0) {
960
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
961
+ return;
962
+ }
963
+
964
+ /* Write an element named "ARTICLE" as child of ENTRY. */
965
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
966
+ BAD_CAST "<Test>");
967
+ if (rc < 0) {
968
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
969
+ return;
970
+ }
971
+
972
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
973
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
974
+ 10);
975
+ if (rc < 0) {
976
+ printf
977
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
978
+ return;
979
+ }
980
+
981
+ /* Close the element named ENTRY. */
982
+ rc = xmlTextWriterEndElement(writer);
983
+ if (rc < 0) {
984
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
985
+ return;
986
+ }
987
+
988
+ /* Start an element named "ENTRY" as child of ENTRIES. */
989
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "ENTRY");
990
+ if (rc < 0) {
991
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
992
+ return;
993
+ }
994
+
995
+ /* Write an element named "ARTICLE" as child of ENTRY. */
996
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "ARTICLE",
997
+ BAD_CAST "<Test 2>");
998
+ if (rc < 0) {
999
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
1000
+ return;
1001
+ }
1002
+
1003
+ /* Write an element named "ENTRY_NO" as child of ENTRY. */
1004
+ rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ENTRY_NO", "%d",
1005
+ 20);
1006
+ if (rc < 0) {
1007
+ printf
1008
+ ("testXmlwriterTree: Error at xmlTextWriterWriteFormatElement\n");
1009
+ return;
1010
+ }
1011
+
1012
+ /* Close the element named ENTRY. */
1013
+ rc = xmlTextWriterEndElement(writer);
1014
+ if (rc < 0) {
1015
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1016
+ return;
1017
+ }
1018
+
1019
+ /* Close the element named ENTRIES. */
1020
+ rc = xmlTextWriterEndElement(writer);
1021
+ if (rc < 0) {
1022
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1023
+ return;
1024
+ }
1025
+
1026
+ /* Start an element named "FOOTER" as child of ORDER. */
1027
+ rc = xmlTextWriterStartElement(writer, BAD_CAST "FOOTER");
1028
+ if (rc < 0) {
1029
+ printf("testXmlwriterTree: Error at xmlTextWriterStartElement\n");
1030
+ return;
1031
+ }
1032
+
1033
+ /* Write an element named "TEXT" as child of FOOTER. */
1034
+ rc = xmlTextWriterWriteElement(writer, BAD_CAST "TEXT",
1035
+ BAD_CAST "This is a text.");
1036
+ if (rc < 0) {
1037
+ printf("testXmlwriterTree: Error at xmlTextWriterWriteElement\n");
1038
+ return;
1039
+ }
1040
+
1041
+ /* Close the element named FOOTER. */
1042
+ rc = xmlTextWriterEndElement(writer);
1043
+ if (rc < 0) {
1044
+ printf("testXmlwriterTree: Error at xmlTextWriterEndElement\n");
1045
+ return;
1046
+ }
1047
+
1048
+ /* Here we could close the elements ORDER and EXAMPLE using the
1049
+ * function xmlTextWriterEndElement, but since we do not want to
1050
+ * write any other elements, we simply call xmlTextWriterEndDocument,
1051
+ * which will do all the work. */
1052
+ rc = xmlTextWriterEndDocument(writer);
1053
+ if (rc < 0) {
1054
+ printf("testXmlwriterTree: Error at xmlTextWriterEndDocument\n");
1055
+ return;
1056
+ }
1057
+
1058
+ xmlFreeTextWriter(writer);
1059
+
1060
+ xmlFreeDoc(doc);
1061
+ }
1062
+
1063
+ #else
1064
+ int main(void) {
1065
+ fprintf(stderr, "Writer or output support not compiled in\n");
1066
+ return 0;
1067
+ }
1068
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/tree1.c ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: Tree
3
+ * synopsis: Navigates a tree to print element names
4
+ * purpose: Parse a file to a tree, use xmlDocGetRootElement() to
5
+ * get the root element, then walk the document and print
6
+ * all the element name in document order.
7
+ * usage: tree1 filename_or_URL
8
+ * test: tree1 test2.xml > tree1.tmp && diff tree1.tmp $(srcdir)/tree1.res
9
+ * author: Dodji Seketeli
10
+ * copy: see Copyright for the status of this software.
11
+ */
12
+ #include <stdio.h>
13
+ #include <libxml/parser.h>
14
+ #include <libxml/tree.h>
15
+
16
+ /*
17
+ *To compile this file using gcc you can type
18
+ *gcc `xml2-config --cflags --libs` -o xmlexample libxml2-example.c
19
+ */
20
+
21
+ /**
22
+ * print_element_names:
23
+ * @a_node: the initial xml node to consider.
24
+ *
25
+ * Prints the names of the all the xml elements
26
+ * that are siblings or children of a given xml node.
27
+ */
28
+ static void
29
+ print_element_names(xmlNode * a_node)
30
+ {
31
+ xmlNode *cur_node = NULL;
32
+
33
+ for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
34
+ if (cur_node->type == XML_ELEMENT_NODE) {
35
+ printf("node type: Element, name: %s\n", cur_node->name);
36
+ }
37
+
38
+ print_element_names(cur_node->children);
39
+ }
40
+ }
41
+
42
+
43
+ /**
44
+ * Simple example to parse a file called "file.xml",
45
+ * walk down the DOM, and print the name of the
46
+ * xml elements nodes.
47
+ */
48
+ int
49
+ main(int argc, char **argv)
50
+ {
51
+ xmlDoc *doc = NULL;
52
+ xmlNode *root_element = NULL;
53
+
54
+ if (argc != 2)
55
+ return(1);
56
+
57
+ /*
58
+ * this initialize the library and check potential ABI mismatches
59
+ * between the version it was compiled for and the actual shared
60
+ * library used.
61
+ */
62
+ LIBXML_TEST_VERSION
63
+
64
+ /*parse the file and get the DOM */
65
+ doc = xmlReadFile(argv[1], NULL, 0);
66
+
67
+ if (doc == NULL) {
68
+ printf("error: could not parse file %s\n", argv[1]);
69
+ }
70
+
71
+ /*Get the root element node */
72
+ root_element = xmlDocGetRootElement(doc);
73
+
74
+ print_element_names(root_element);
75
+
76
+ /*free the document */
77
+ xmlFreeDoc(doc);
78
+
79
+ return 0;
80
+ }
local-test-libxml2-delta-01/afc-libxml2/example/tree2.c ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * section: Tree
3
+ * synopsis: Creates a tree
4
+ * purpose: Shows how to create document, nodes and dump it to stdout or file.
5
+ * usage: tree2 <filename> -Default output: stdout
6
+ * test: tree2 > tree2.tmp && diff tree2.tmp $(srcdir)/tree2.res
7
+ * author: Lucas Brasilino <brasilino@recife.pe.gov.br>
8
+ * copy: see Copyright for the status of this software
9
+ */
10
+
11
+ #include <stdio.h>
12
+ #include <libxml/parser.h>
13
+ #include <libxml/tree.h>
14
+
15
+ #if defined(LIBXML_OUTPUT_ENABLED)
16
+
17
+ /*
18
+ *To compile this file using gcc you can type
19
+ *gcc `xml2-config --cflags --libs` -o tree2 tree2.c
20
+ */
21
+
22
+ /* A simple example how to create DOM. Libxml2 automagically
23
+ * allocates the necessary amount of memory to it.
24
+ */
25
+ int
26
+ main(int argc, char **argv)
27
+ {
28
+ xmlDocPtr doc = NULL; /* document pointer */
29
+ xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;/* node pointers */
30
+ char buff[256];
31
+ int i, j;
32
+
33
+ LIBXML_TEST_VERSION;
34
+
35
+ /*
36
+ * Creates a new document, a node and set it as a root node
37
+ */
38
+ doc = xmlNewDoc(BAD_CAST "1.0");
39
+ root_node = xmlNewDocNode(doc, NULL, BAD_CAST "root", NULL);
40
+ xmlDocSetRootElement(doc, root_node);
41
+
42
+ /*
43
+ * Creates a DTD declaration. Isn't mandatory.
44
+ */
45
+ xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "tree2.dtd");
46
+
47
+ /*
48
+ * xmlNewChild() creates a new node, which is "attached" as child node
49
+ * of root_node node.
50
+ */
51
+ xmlNewChild(root_node, NULL, BAD_CAST "node1",
52
+ BAD_CAST "content of node 1");
53
+ /*
54
+ * The same as above, but the new child node doesn't have a content
55
+ */
56
+ xmlNewChild(root_node, NULL, BAD_CAST "node2", NULL);
57
+
58
+ /*
59
+ * xmlNewProp() creates attributes, which is "attached" to an node.
60
+ * It returns xmlAttrPtr, which isn't used here.
61
+ */
62
+ node =
63
+ xmlNewChild(root_node, NULL, BAD_CAST "node3",
64
+ BAD_CAST "this node has attributes");
65
+ xmlNewProp(node, BAD_CAST "attribute", BAD_CAST "yes");
66
+ xmlNewProp(node, BAD_CAST "foo", BAD_CAST "bar");
67
+
68
+ /*
69
+ * Here goes another way to create nodes. xmlNewNode() and xmlNewText
70
+ * creates a node and a text node separately. They are "attached"
71
+ * by xmlAddChild()
72
+ */
73
+ node = xmlNewDocNode(doc, NULL, BAD_CAST "node4", NULL);
74
+ node1 = xmlNewDocText(doc, BAD_CAST
75
+ "other way to create content (which is also a node)");
76
+ xmlAddChild(node, node1);
77
+ xmlAddChild(root_node, node);
78
+
79
+ /*
80
+ * A simple loop that "automates" nodes creation
81
+ */
82
+ for (i = 5; i < 7; i++) {
83
+ snprintf(buff, sizeof(buff), "node%d", i);
84
+ node = xmlNewChild(root_node, NULL, BAD_CAST buff, NULL);
85
+ for (j = 1; j < 4; j++) {
86
+ snprintf(buff, sizeof(buff), "node%d%d", i, j);
87
+ node1 = xmlNewChild(node, NULL, BAD_CAST buff, NULL);
88
+ xmlNewProp(node1, BAD_CAST "odd", BAD_CAST((j % 2) ? "no" : "yes"));
89
+ }
90
+ }
91
+
92
+ /*
93
+ * Dumping document to stdio or file
94
+ */
95
+ xmlSaveFormatFileEnc(argc > 1 ? argv[1] : "-", doc, "UTF-8", 1);
96
+
97
+ /*free the document */
98
+ xmlFreeDoc(doc);
99
+
100
+ return(0);
101
+ }
102
+ #else
103
+ int main(void) {
104
+ fprintf(stderr, "output support not compiled in\n");
105
+ return(0);
106
+ }
107
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/xpath1.c ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: XPath
3
+ * synopsis: Evaluate XPath expression and prints result node set.
4
+ * purpose: Shows how to evaluate XPath expression and register
5
+ * known namespaces in XPath context.
6
+ * usage: xpath1 <xml-file> <xpath-expr> [<known-ns-list>]
7
+ * test: xpath1 test3.xml '//child2' > xpath1.tmp && diff xpath1.tmp $(srcdir)/xpath1.res
8
+ * author: Aleksey Sanin
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+ #include <stdlib.h>
12
+ #include <stdio.h>
13
+ #include <string.h>
14
+ #include <assert.h>
15
+
16
+ #include <libxml/tree.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/xpath.h>
19
+ #include <libxml/xpathInternals.h>
20
+
21
+ #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED)
22
+
23
+
24
+ static void usage(const char *name);
25
+ int execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList);
26
+ int register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList);
27
+ void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output);
28
+
29
+ int
30
+ main(int argc, char **argv) {
31
+ /* Parse command line and process file */
32
+ if((argc < 3) || (argc > 4)) {
33
+ fprintf(stderr, "Error: wrong number of arguments.\n");
34
+ usage(argv[0]);
35
+ return(-1);
36
+ }
37
+
38
+ /* Init libxml */
39
+ xmlInitParser();
40
+ LIBXML_TEST_VERSION
41
+
42
+ /* Do the main job */
43
+ if(execute_xpath_expression(argv[1], BAD_CAST argv[2], (argc > 3) ? BAD_CAST argv[3] : NULL) < 0) {
44
+ usage(argv[0]);
45
+ return(-1);
46
+ }
47
+
48
+ return 0;
49
+ }
50
+
51
+ /**
52
+ * usage:
53
+ * @name: the program name.
54
+ *
55
+ * Prints usage information.
56
+ */
57
+ static void
58
+ usage(const char *name) {
59
+ assert(name);
60
+
61
+ fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> [<known-ns-list>]\n", name);
62
+ fprintf(stderr, "where <known-ns-list> is a list of known namespaces\n");
63
+ fprintf(stderr, "in \"<prefix1>=<href1> <prefix2>=href2> ...\" format\n");
64
+ }
65
+
66
+ /**
67
+ * execute_xpath_expression:
68
+ * @filename: the input XML filename.
69
+ * @xpathExpr: the xpath expression for evaluation.
70
+ * @nsList: the optional list of known namespaces in
71
+ * "<prefix1>=<href1> <prefix2>=href2> ..." format.
72
+ *
73
+ * Parses input XML file, evaluates XPath expression and prints results.
74
+ *
75
+ * Returns 0 on success and a negative value otherwise.
76
+ */
77
+ int
78
+ execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList) {
79
+ xmlDocPtr doc;
80
+ xmlXPathContextPtr xpathCtx;
81
+ xmlXPathObjectPtr xpathObj;
82
+
83
+ assert(filename);
84
+ assert(xpathExpr);
85
+
86
+ /* Load XML document */
87
+ doc = xmlParseFile(filename);
88
+ if (doc == NULL) {
89
+ fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
90
+ return(-1);
91
+ }
92
+
93
+ /* Create xpath evaluation context */
94
+ xpathCtx = xmlXPathNewContext(doc);
95
+ if(xpathCtx == NULL) {
96
+ fprintf(stderr,"Error: unable to create new XPath context\n");
97
+ xmlFreeDoc(doc);
98
+ return(-1);
99
+ }
100
+
101
+ /* Register namespaces from list (if any) */
102
+ if((nsList != NULL) && (register_namespaces(xpathCtx, nsList) < 0)) {
103
+ fprintf(stderr,"Error: failed to register namespaces list \"%s\"\n", nsList);
104
+ xmlXPathFreeContext(xpathCtx);
105
+ xmlFreeDoc(doc);
106
+ return(-1);
107
+ }
108
+
109
+ /* Evaluate xpath expression */
110
+ xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
111
+ if(xpathObj == NULL) {
112
+ fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
113
+ xmlXPathFreeContext(xpathCtx);
114
+ xmlFreeDoc(doc);
115
+ return(-1);
116
+ }
117
+
118
+ /* Print results */
119
+ print_xpath_nodes(xpathObj->nodesetval, stdout);
120
+
121
+ /* Cleanup */
122
+ xmlXPathFreeObject(xpathObj);
123
+ xmlXPathFreeContext(xpathCtx);
124
+ xmlFreeDoc(doc);
125
+
126
+ return(0);
127
+ }
128
+
129
+ /**
130
+ * register_namespaces:
131
+ * @xpathCtx: the pointer to an XPath context.
132
+ * @nsList: the list of known namespaces in
133
+ * "<prefix1>=<href1> <prefix2>=href2> ..." format.
134
+ *
135
+ * Registers namespaces from @nsList in @xpathCtx.
136
+ *
137
+ * Returns 0 on success and a negative value otherwise.
138
+ */
139
+ int
140
+ register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList) {
141
+ xmlChar* nsListDup;
142
+ xmlChar* prefix;
143
+ xmlChar* href;
144
+ xmlChar* next;
145
+
146
+ assert(xpathCtx);
147
+ assert(nsList);
148
+
149
+ nsListDup = xmlStrdup(nsList);
150
+ if(nsListDup == NULL) {
151
+ fprintf(stderr, "Error: unable to strdup namespaces list\n");
152
+ return(-1);
153
+ }
154
+
155
+ next = nsListDup;
156
+ while(next != NULL) {
157
+ /* skip spaces */
158
+ while((*next) == ' ') next++;
159
+ if((*next) == '\0') break;
160
+
161
+ /* find prefix */
162
+ prefix = next;
163
+ next = (xmlChar*)xmlStrchr(next, '=');
164
+ if(next == NULL) {
165
+ fprintf(stderr,"Error: invalid namespaces list format\n");
166
+ xmlFree(nsListDup);
167
+ return(-1);
168
+ }
169
+ *(next++) = '\0';
170
+
171
+ /* find href */
172
+ href = next;
173
+ next = (xmlChar*)xmlStrchr(next, ' ');
174
+ if(next != NULL) {
175
+ *(next++) = '\0';
176
+ }
177
+
178
+ /* do register namespace */
179
+ if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0) {
180
+ fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
181
+ xmlFree(nsListDup);
182
+ return(-1);
183
+ }
184
+ }
185
+
186
+ xmlFree(nsListDup);
187
+ return(0);
188
+ }
189
+
190
+ /**
191
+ * print_xpath_nodes:
192
+ * @nodes: the nodes set.
193
+ * @output: the output file handle.
194
+ *
195
+ * Prints the @nodes content to @output.
196
+ */
197
+ void
198
+ print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) {
199
+ xmlNodePtr cur;
200
+ int size;
201
+ int i;
202
+
203
+ assert(output);
204
+ size = (nodes) ? nodes->nodeNr : 0;
205
+
206
+ fprintf(output, "Result (%d nodes):\n", size);
207
+ for(i = 0; i < size; ++i) {
208
+ assert(nodes->nodeTab[i]);
209
+
210
+ if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
211
+ xmlNsPtr ns;
212
+
213
+ ns = (xmlNsPtr)nodes->nodeTab[i];
214
+ cur = (xmlNodePtr)ns->next;
215
+ if(cur->ns) {
216
+ fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n",
217
+ ns->prefix, ns->href, cur->ns->href, cur->name);
218
+ } else {
219
+ fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n",
220
+ ns->prefix, ns->href, cur->name);
221
+ }
222
+ } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
223
+ cur = nodes->nodeTab[i];
224
+ if(cur->ns) {
225
+ fprintf(output, "= element node \"%s:%s\"\n",
226
+ cur->ns->href, cur->name);
227
+ } else {
228
+ fprintf(output, "= element node \"%s\"\n",
229
+ cur->name);
230
+ }
231
+ } else {
232
+ cur = nodes->nodeTab[i];
233
+ fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type);
234
+ }
235
+ }
236
+ }
237
+
238
+ #else
239
+ int main(void) {
240
+ fprintf(stderr, "XPath support not compiled in\n");
241
+ return 0;
242
+ }
243
+ #endif
local-test-libxml2-delta-01/afc-libxml2/example/xpath2.c ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * section: XPath
3
+ * synopsis: Load a document, locate subelements with XPath, modify
4
+ * said elements and save the resulting document.
5
+ * purpose: Shows how to make a full round-trip from a load/edit/save
6
+ * usage: xpath2 <xml-file> <xpath-expr> <new-value>
7
+ * test: xpath2 test3.xml '//discarded' discarded > xpath2.tmp && diff xpath2.tmp $(srcdir)/xpath2.res
8
+ * author: Aleksey Sanin and Daniel Veillard
9
+ * copy: see Copyright for the status of this software.
10
+ */
11
+ #include <stdlib.h>
12
+ #include <stdio.h>
13
+ #include <string.h>
14
+ #include <assert.h>
15
+
16
+ #include <libxml/tree.h>
17
+ #include <libxml/parser.h>
18
+ #include <libxml/xpath.h>
19
+ #include <libxml/xpathInternals.h>
20
+
21
+ #if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_SAX1_ENABLED) && \
22
+ defined(LIBXML_OUTPUT_ENABLED)
23
+
24
+
25
+ static void usage(const char *name);
26
+ static int example4(const char *filename, const xmlChar * xpathExpr,
27
+ const xmlChar * value);
28
+ static void update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar * value);
29
+
30
+
31
+ int
32
+ main(int argc, char **argv) {
33
+ /* Parse command line and process file */
34
+ if (argc != 4) {
35
+ fprintf(stderr, "Error: wrong number of arguments.\n");
36
+ usage(argv[0]);
37
+ return(-1);
38
+ }
39
+
40
+ /* Init libxml */
41
+ xmlInitParser();
42
+ LIBXML_TEST_VERSION
43
+
44
+ /* Do the main job */
45
+ if (example4(argv[1], BAD_CAST argv[2], BAD_CAST argv[3])) {
46
+ usage(argv[0]);
47
+ return(-1);
48
+ }
49
+
50
+ return 0;
51
+ }
52
+
53
+ /**
54
+ * usage:
55
+ * @name: the program name.
56
+ *
57
+ * Prints usage information.
58
+ */
59
+ static void
60
+ usage(const char *name) {
61
+ assert(name);
62
+
63
+ fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> <value>\n", name);
64
+ }
65
+
66
+ /**
67
+ * example4:
68
+ * @filename: the input XML filename.
69
+ * @xpathExpr: the xpath expression for evaluation.
70
+ * @value: the new node content.
71
+ *
72
+ * Parses input XML file, evaluates XPath expression and update the nodes
73
+ * then print the result.
74
+ *
75
+ * Returns 0 on success and a negative value otherwise.
76
+ */
77
+ static int
78
+ example4(const char* filename, const xmlChar* xpathExpr, const xmlChar* value) {
79
+ xmlDocPtr doc;
80
+ xmlXPathContextPtr xpathCtx;
81
+ xmlXPathObjectPtr xpathObj;
82
+
83
+ assert(filename);
84
+ assert(xpathExpr);
85
+ assert(value);
86
+
87
+ /* Load XML document */
88
+ doc = xmlParseFile(filename);
89
+ if (doc == NULL) {
90
+ fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
91
+ return(-1);
92
+ }
93
+
94
+ /* Create xpath evaluation context */
95
+ xpathCtx = xmlXPathNewContext(doc);
96
+ if(xpathCtx == NULL) {
97
+ fprintf(stderr,"Error: unable to create new XPath context\n");
98
+ xmlFreeDoc(doc);
99
+ return(-1);
100
+ }
101
+
102
+ /* Evaluate xpath expression */
103
+ xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
104
+ if(xpathObj == NULL) {
105
+ fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
106
+ xmlXPathFreeContext(xpathCtx);
107
+ xmlFreeDoc(doc);
108
+ return(-1);
109
+ }
110
+
111
+ /* update selected nodes */
112
+ update_xpath_nodes(xpathObj->nodesetval, value);
113
+
114
+
115
+ /* Cleanup of XPath data */
116
+ xmlXPathFreeObject(xpathObj);
117
+ xmlXPathFreeContext(xpathCtx);
118
+
119
+ /* dump the resulting document */
120
+ xmlDocDump(stdout, doc);
121
+
122
+
123
+ /* free the document */
124
+ xmlFreeDoc(doc);
125
+
126
+ return(0);
127
+ }
128
+
129
+ /**
130
+ * update_xpath_nodes:
131
+ * @nodes: the nodes set.
132
+ * @value: the new value for the node(s)
133
+ *
134
+ * Prints the @nodes content to @output.
135
+ */
136
+ static void
137
+ update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar* value) {
138
+ int size;
139
+ int i;
140
+
141
+ assert(value);
142
+ size = (nodes) ? nodes->nodeNr : 0;
143
+
144
+ /*
145
+ * NOTE: the nodes are processed in reverse order, i.e. reverse document
146
+ * order because xmlNodeSetContent can actually free up descendant
147
+ * of the node and such nodes may have been selected too ! Handling
148
+ * in reverse order ensure that descendant are accessed first, before
149
+ * they get removed. Mixing XPath and modifications on a tree must be
150
+ * done carefully !
151
+ */
152
+ for(i = size - 1; i >= 0; i--) {
153
+ assert(nodes->nodeTab[i]);
154
+
155
+ xmlNodeSetContent(nodes->nodeTab[i], value);
156
+ /*
157
+ * All the elements returned by an XPath query are pointers to
158
+ * elements from the tree *except* namespace nodes where the XPath
159
+ * semantic is different from the implementation in libxml2 tree.
160
+ * As a result when a returned node set is freed when
161
+ * xmlXPathFreeObject() is called, that routine must check the
162
+ * element type. But node from the returned set may have been removed
163
+ * by xmlNodeSetContent() resulting in access to freed data.
164
+ * This can be exercised by running
165
+ * valgrind xpath2 test3.xml '//discarded' discarded
166
+ * There is 2 ways around it:
167
+ * - make a copy of the pointers to the nodes from the result set
168
+ * then call xmlXPathFreeObject() and then modify the nodes
169
+ * or
170
+ * - remove the reference to the modified nodes from the node set
171
+ * as they are processed, if they are not namespace nodes.
172
+ */
173
+ if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
174
+ nodes->nodeTab[i] = NULL;
175
+ }
176
+ }
177
+
178
+ #else
179
+ int main(void) {
180
+ fprintf(stderr, "XPath support not compiled in\n");
181
+ return 0;
182
+ }
183
+ #endif
local-test-libxml2-delta-01/afc-libxml2/include/Makefile.am ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ## Process this file with automake to produce Makefile.in
2
+ SUBDIRS=libxml private
3
+
4
+ EXTRA_DIST = wsockcompat.h meson.build
5
+
local-test-libxml2-delta-01/afc-libxml2/include/meson.build ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ inc_dir = include_directories('.')
local-test-libxml2-delta-01/afc-libxml2/include/wsockcompat.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* include/wsockcompat.h
2
+ * Windows -> Berkeley Sockets compatibility things.
3
+ */
4
+
5
+ #if !defined __XML_WSOCKCOMPAT_H__
6
+ #define __XML_WSOCKCOMPAT_H__
7
+
8
+ #include <errno.h>
9
+ #include <winsock2.h>
10
+
11
+ /* Fix for old MinGW. */
12
+ #ifndef _WINSOCKAPI_
13
+ #define _WINSOCKAPI_
14
+ #endif
15
+
16
+ /* the following is a workaround a problem for 'inline' keyword in said
17
+ header when compiled with Borland C++ 6 */
18
+ #if defined(__BORLANDC__) && !defined(__cplusplus)
19
+ #define inline __inline
20
+ #define _inline __inline
21
+ #endif
22
+
23
+ #include <ws2tcpip.h>
24
+
25
+ /* Check if ws2tcpip.h is a recent version which provides getaddrinfo() */
26
+ #if defined(GetAddrInfo)
27
+ #include <wspiapi.h>
28
+ #ifndef SUPPORT_IP6
29
+ #define SUPPORT_IP6
30
+ #endif
31
+ #endif
32
+
33
+ #ifndef ECONNRESET
34
+ #define ECONNRESET WSAECONNRESET
35
+ #endif
36
+ #ifndef EINPROGRESS
37
+ #define EINPROGRESS WSAEINPROGRESS
38
+ #endif
39
+ #ifndef EINTR
40
+ #define EINTR WSAEINTR
41
+ #endif
42
+ #ifndef ESHUTDOWN
43
+ #define ESHUTDOWN WSAESHUTDOWN
44
+ #endif
45
+ #ifndef EWOULDBLOCK
46
+ #define EWOULDBLOCK WSAEWOULDBLOCK
47
+ #endif
48
+
49
+ #endif /* __XML_WSOCKCOMPAT_H__ */
local-test-libxml2-delta-01/afc-libxml2/m4/ax_append_flag.m4 ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
12
+ # added in between.
13
+ #
14
+ # If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
15
+ # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
16
+ # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
17
+ # FLAG.
18
+ #
19
+ # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
20
+ #
21
+ # LICENSE
22
+ #
23
+ # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
24
+ # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
25
+ #
26
+ # Copying and distribution of this file, with or without modification, are
27
+ # permitted in any medium without royalty provided the copyright notice
28
+ # and this notice are preserved. This file is offered as-is, without any
29
+ # warranty.
30
+
31
+ #serial 8
32
+
33
+ AC_DEFUN([AX_APPEND_FLAG],
34
+ [dnl
35
+ AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
36
+ AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
37
+ AS_VAR_SET_IF(FLAGS,[
38
+ AS_CASE([" AS_VAR_GET(FLAGS) "],
39
+ [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
40
+ [
41
+ AS_VAR_APPEND(FLAGS,[" $1"])
42
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
43
+ ])
44
+ ],
45
+ [
46
+ AS_VAR_SET(FLAGS,[$1])
47
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
48
+ ])
49
+ AS_VAR_POPDEF([FLAGS])dnl
50
+ ])dnl AX_APPEND_FLAG
local-test-libxml2-delta-01/afc-libxml2/m4/ax_append_link_flags.m4 ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # For every FLAG1, FLAG2 it is checked whether the linker works with the
12
+ # flag. If it does, the flag is added FLAGS-VARIABLE
13
+ #
14
+ # If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
15
+ # used. During the check the flag is always added to the linker's flags.
16
+ #
17
+ # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18
+ # when the check is done. The check is thus made with the flags: "LDFLAGS
19
+ # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20
+ # issue an error when a bad flag is given.
21
+ #
22
+ # INPUT gives an alternative input source to AC_COMPILE_IFELSE.
23
+ #
24
+ # NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
25
+ # Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
26
+ #
27
+ # LICENSE
28
+ #
29
+ # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
30
+ #
31
+ # Copying and distribution of this file, with or without modification, are
32
+ # permitted in any medium without royalty provided the copyright notice
33
+ # and this notice are preserved. This file is offered as-is, without any
34
+ # warranty.
35
+
36
+ #serial 7
37
+
38
+ AC_DEFUN([AX_APPEND_LINK_FLAGS],
39
+ [AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
40
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
41
+ for flag in $1; do
42
+ AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
43
+ done
44
+ ])dnl AX_APPEND_LINK_FLAGS
local-test-libxml2-delta-01/afc-libxml2/m4/ax_check_link_flag.m4 ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ===========================================================================
2
+ # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8
+ #
9
+ # DESCRIPTION
10
+ #
11
+ # Check whether the given FLAG works with the linker or gives an error.
12
+ # (Warnings, however, are ignored)
13
+ #
14
+ # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15
+ # success/failure.
16
+ #
17
+ # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18
+ # when the check is done. The check is thus made with the flags: "LDFLAGS
19
+ # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20
+ # issue an error when a bad flag is given.
21
+ #
22
+ # INPUT gives an alternative input source to AC_LINK_IFELSE.
23
+ #
24
+ # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25
+ # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26
+ #
27
+ # LICENSE
28
+ #
29
+ # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
30
+ # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
31
+ #
32
+ # Copying and distribution of this file, with or without modification, are
33
+ # permitted in any medium without royalty provided the copyright notice
34
+ # and this notice are preserved. This file is offered as-is, without any
35
+ # warranty.
36
+
37
+ #serial 6
38
+
39
+ AC_DEFUN([AX_CHECK_LINK_FLAG],
40
+ [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41
+ AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42
+ AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43
+ ax_check_save_flags=$LDFLAGS
44
+ LDFLAGS="$LDFLAGS $4 $1"
45
+ AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46
+ [AS_VAR_SET(CACHEVAR,[yes])],
47
+ [AS_VAR_SET(CACHEVAR,[no])])
48
+ LDFLAGS=$ax_check_save_flags])
49
+ AS_VAR_IF(CACHEVAR,yes,
50
+ [m4_default([$2], :)],
51
+ [m4_default([$3], :)])
52
+ AS_VAR_POPDEF([CACHEVAR])dnl
53
+ ])dnl AX_CHECK_LINK_FLAGS