rsvg2 1.1.5-x86-mingw32 → 1.1.6-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/1.8/rsvg2.so +0 -0
- data/lib/1.9/rsvg2.so +0 -0
- data/vendor/local/bin/libxml2-2.dll +0 -0
- data/vendor/local/bin/xmlcatalog.exe +0 -0
- data/vendor/local/bin/xmllint.exe +0 -0
- data/vendor/local/include/libxml2/libxml/DOCBparser.h +9 -9
- data/vendor/local/include/libxml2/libxml/HTMLparser.h +25 -23
- data/vendor/local/include/libxml2/libxml/HTMLtree.h +19 -19
- data/vendor/local/include/libxml2/libxml/SAX.h +37 -37
- data/vendor/local/include/libxml2/libxml/SAX2.h +34 -34
- data/vendor/local/include/libxml2/libxml/c14n.h +1 -1
- data/vendor/local/include/libxml2/libxml/catalog.h +35 -35
- data/vendor/local/include/libxml2/libxml/debugXML.h +26 -26
- data/vendor/local/include/libxml2/libxml/dict.h +16 -5
- data/vendor/local/include/libxml2/libxml/encoding.h +28 -14
- data/vendor/local/include/libxml2/libxml/hash.h +24 -24
- data/vendor/local/include/libxml2/libxml/list.h +26 -26
- data/vendor/local/include/libxml2/libxml/nanoftp.h +44 -24
- data/vendor/local/include/libxml2/libxml/nanohttp.h +13 -13
- data/vendor/local/include/libxml2/libxml/parser.h +78 -73
- data/vendor/local/include/libxml2/libxml/parserInternals.h +106 -73
- data/vendor/local/include/libxml2/libxml/schemasInternals.h +2 -2
- data/vendor/local/include/libxml2/libxml/schematron.h +11 -11
- data/vendor/local/include/libxml2/libxml/tree.h +203 -152
- data/vendor/local/include/libxml2/libxml/valid.h +72 -72
- data/vendor/local/include/libxml2/libxml/xlink.h +7 -7
- data/vendor/local/include/libxml2/libxml/xmlIO.h +71 -65
- data/vendor/local/include/libxml2/libxml/xmlautomata.h +22 -22
- data/vendor/local/include/libxml2/libxml/xmlerror.h +6 -6
- data/vendor/local/include/libxml2/libxml/xmlexports.h +2 -2
- data/vendor/local/include/libxml2/libxml/xmlmodule.h +1 -1
- data/vendor/local/include/libxml2/libxml/xmlreader.h +24 -20
- data/vendor/local/include/libxml2/libxml/xmlsave.h +2 -1
- data/vendor/local/include/libxml2/libxml/xmlschemas.h +30 -2
- data/vendor/local/include/libxml2/libxml/xmlschemastypes.h +20 -20
- data/vendor/local/include/libxml2/libxml/xmlstring.h +3 -3
- data/vendor/local/include/libxml2/libxml/xmlversion.h +29 -7
- data/vendor/local/include/libxml2/libxml/xmlwriter.h +4 -1
- data/vendor/local/include/libxml2/libxml/xpath.h +47 -43
- data/vendor/local/include/libxml2/libxml/xpathInternals.h +81 -79
- data/vendor/local/include/libxml2/libxml/xpointer.h +23 -23
- data/vendor/local/lib/libxml2.def +16 -14
- data/vendor/local/lib/libxml2.dll.a +0 -0
- data/vendor/local/lib/libxml2.lib +0 -0
- data/vendor/local/lib/pkgconfig/libxml-2.0.pc +3 -3
- data/vendor/local/manifest/libxml2-dev_2.9.0-1_win32.mft +268 -0
- data/vendor/local/manifest/libxml2_2.9.0-1_win32.mft +2 -0
- data/vendor/local/share/doc/libxml2-2.9.0/Copyright +27 -0
- data/vendor/local/share/doc/libxml2-2.9.0/examples/testHTML.c +880 -0
- data/vendor/local/share/doc/libxml2-2.9.0/examples/testSAX.c +1198 -0
- data/vendor/local/share/doc/libxml2-2.9.0/examples/testXPath.c +229 -0
- data/vendor/local/share/doc/libxml2-2.9.0/examples/xmllint.c +3770 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/DOM.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/FAQ.html +282 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/Libxml2-Logo-180x168.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/Libxml2-Logo-90x34.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/encoding.html +207 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/examples.xml +751 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/examples.xsl +174 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/book1.html +13 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/home.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/index.html +13 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/left.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-DOCBparser.html +51 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-HTMLparser.html +184 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-HTMLtree.html +73 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-SAX.html +125 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-SAX2.html +128 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-c14n.html +38 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-catalog.html +142 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-chvalid.html +72 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-debugXML.html +120 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-dict.html +58 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-encoding.html +124 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-entities.html +79 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-globals.html +152 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-hash.html +116 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-lib.html +13 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-list.html +120 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-nanoftp.html +94 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-nanohttp.html +65 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-parser.html +559 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-parserInternals.html +322 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-pattern.html +76 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-relaxng.html +162 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-schemasInternals.html +373 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-schematron.html +81 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-threads.html +72 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-tree.html +989 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-uri.html +73 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-valid.html +289 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xinclude.html +59 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xlink.html +82 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlIO.html +212 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlautomata.html +85 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlerror.html +864 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlexports.html +20 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlmemory.html +107 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlmodule.html +38 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlreader.html +330 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlregexp.html +143 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlsave.html +60 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlschemas.html +185 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlschemastypes.html +123 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlstring.html +108 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlunicode.html +512 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlversion.html +62 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xmlwriter.html +261 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xpath.html +310 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xpathInternals.html +394 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/libxml-xpointer.html +83 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/right.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/html/up.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/index.html +14 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/io1.c +166 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/io1.res +5 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/io2.c +58 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/io2.res +2 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/libxml.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/parse1.c +56 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/parse2.c +72 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/parse3.c +60 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/parse4.c +143 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader1.c +107 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader1.res +14 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader2.c +122 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader3.c +120 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader3.res +13 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader4.c +122 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/reader4.res +3 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/redhat.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/smallfootonly.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/structure.gif +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/test1.xml +1 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/test2.xml +13 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/test3.xml +39 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/testWriter.c +1198 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tree1.c +94 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tree1.res +4 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tree2.c +118 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tree2.res +18 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tst.xml +7 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apa.html +8 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apb.html +14 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apc.html +82 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apd.html +76 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ape.html +78 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apf.html +67 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/apg.html +75 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/aph.html +76 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/api.html +4 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s02.html +14 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s03.html +47 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s04.html +54 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s05.html +55 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s06.html +35 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s07.html +30 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s08.html +38 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ar01s09.html +63 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/blank.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/1.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/10.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/2.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/3.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/4.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/5.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/6.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/7.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/8.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/callouts/9.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/caution.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/draft.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/home.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/important.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/next.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/note.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/prev.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/tip.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/toc-blank.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/toc-minus.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/toc-plus.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/up.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/images/warning.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includeaddattribute.c +64 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includeaddkeyword.c +75 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includeconvert.c +73 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includegetattribute.c +72 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includekeyword.c +79 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/includexpath.c +74 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/index.html +14 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/ix01.html +1 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/tutorial/xmltutorial.pdf +1336 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/w3c.png +0 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/writer.xml +2 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/xml.html +5715 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/xpath1.c +250 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/xpath1.res +5 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/xpath2.c +190 -0
- data/vendor/local/share/doc/libxml2-2.9.0/html/xpath2.res +30 -0
- data/vendor/local/share/gtk-doc/html/libxml2/general.html +1 -1
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-HTMLparser.html +3 -1
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-dict.html +16 -1
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-encoding.html +11 -1
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-nanoftp.html +15 -5
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-parser.html +8 -4
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-parserInternals.html +20 -5
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-tree.html +72 -18
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlIO.html +10 -0
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlerror.html +5 -3
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlmodule.html +2 -2
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlreader.html +8 -3
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlsave.html +2 -1
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlschemas.html +15 -0
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlversion.html +12 -2
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xmlwriter.html +8 -3
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xpath.html +3 -0
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2-xpathInternals.html +9 -9
- data/vendor/local/share/gtk-doc/html/libxml2/libxml2.devhelp +42 -2
- data/vendor/local/share/man/man1/xml2-config.1 +0 -1
- data/vendor/local/share/man/man1/xmlcatalog.1 +204 -93
- data/vendor/local/share/man/man3/libxml.3 +1 -1
- data/vendor/local/src/dieterv/packaging/libxml2_2.9.0-1_win32.log +867 -0
- data/vendor/local/src/dieterv/packaging/libxml2_2.9.0-1_win32.sh +68 -0
- metadata +163 -7
@@ -0,0 +1,250 @@
|
|
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
|
+
/* Shutdown libxml */
|
49
|
+
xmlCleanupParser();
|
50
|
+
|
51
|
+
/*
|
52
|
+
* this is to debug memory for regression tests
|
53
|
+
*/
|
54
|
+
xmlMemoryDump();
|
55
|
+
return 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* usage:
|
60
|
+
* @name: the program name.
|
61
|
+
*
|
62
|
+
* Prints usage information.
|
63
|
+
*/
|
64
|
+
static void
|
65
|
+
usage(const char *name) {
|
66
|
+
assert(name);
|
67
|
+
|
68
|
+
fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> [<known-ns-list>]\n", name);
|
69
|
+
fprintf(stderr, "where <known-ns-list> is a list of known namespaces\n");
|
70
|
+
fprintf(stderr, "in \"<prefix1>=<href1> <prefix2>=href2> ...\" format\n");
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* execute_xpath_expression:
|
75
|
+
* @filename: the input XML filename.
|
76
|
+
* @xpathExpr: the xpath expression for evaluation.
|
77
|
+
* @nsList: the optional list of known namespaces in
|
78
|
+
* "<prefix1>=<href1> <prefix2>=href2> ..." format.
|
79
|
+
*
|
80
|
+
* Parses input XML file, evaluates XPath expression and prints results.
|
81
|
+
*
|
82
|
+
* Returns 0 on success and a negative value otherwise.
|
83
|
+
*/
|
84
|
+
int
|
85
|
+
execute_xpath_expression(const char* filename, const xmlChar* xpathExpr, const xmlChar* nsList) {
|
86
|
+
xmlDocPtr doc;
|
87
|
+
xmlXPathContextPtr xpathCtx;
|
88
|
+
xmlXPathObjectPtr xpathObj;
|
89
|
+
|
90
|
+
assert(filename);
|
91
|
+
assert(xpathExpr);
|
92
|
+
|
93
|
+
/* Load XML document */
|
94
|
+
doc = xmlParseFile(filename);
|
95
|
+
if (doc == NULL) {
|
96
|
+
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
|
97
|
+
return(-1);
|
98
|
+
}
|
99
|
+
|
100
|
+
/* Create xpath evaluation context */
|
101
|
+
xpathCtx = xmlXPathNewContext(doc);
|
102
|
+
if(xpathCtx == NULL) {
|
103
|
+
fprintf(stderr,"Error: unable to create new XPath context\n");
|
104
|
+
xmlFreeDoc(doc);
|
105
|
+
return(-1);
|
106
|
+
}
|
107
|
+
|
108
|
+
/* Register namespaces from list (if any) */
|
109
|
+
if((nsList != NULL) && (register_namespaces(xpathCtx, nsList) < 0)) {
|
110
|
+
fprintf(stderr,"Error: failed to register namespaces list \"%s\"\n", nsList);
|
111
|
+
xmlXPathFreeContext(xpathCtx);
|
112
|
+
xmlFreeDoc(doc);
|
113
|
+
return(-1);
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Evaluate xpath expression */
|
117
|
+
xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
|
118
|
+
if(xpathObj == NULL) {
|
119
|
+
fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
|
120
|
+
xmlXPathFreeContext(xpathCtx);
|
121
|
+
xmlFreeDoc(doc);
|
122
|
+
return(-1);
|
123
|
+
}
|
124
|
+
|
125
|
+
/* Print results */
|
126
|
+
print_xpath_nodes(xpathObj->nodesetval, stdout);
|
127
|
+
|
128
|
+
/* Cleanup */
|
129
|
+
xmlXPathFreeObject(xpathObj);
|
130
|
+
xmlXPathFreeContext(xpathCtx);
|
131
|
+
xmlFreeDoc(doc);
|
132
|
+
|
133
|
+
return(0);
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* register_namespaces:
|
138
|
+
* @xpathCtx: the pointer to an XPath context.
|
139
|
+
* @nsList: the list of known namespaces in
|
140
|
+
* "<prefix1>=<href1> <prefix2>=href2> ..." format.
|
141
|
+
*
|
142
|
+
* Registers namespaces from @nsList in @xpathCtx.
|
143
|
+
*
|
144
|
+
* Returns 0 on success and a negative value otherwise.
|
145
|
+
*/
|
146
|
+
int
|
147
|
+
register_namespaces(xmlXPathContextPtr xpathCtx, const xmlChar* nsList) {
|
148
|
+
xmlChar* nsListDup;
|
149
|
+
xmlChar* prefix;
|
150
|
+
xmlChar* href;
|
151
|
+
xmlChar* next;
|
152
|
+
|
153
|
+
assert(xpathCtx);
|
154
|
+
assert(nsList);
|
155
|
+
|
156
|
+
nsListDup = xmlStrdup(nsList);
|
157
|
+
if(nsListDup == NULL) {
|
158
|
+
fprintf(stderr, "Error: unable to strdup namespaces list\n");
|
159
|
+
return(-1);
|
160
|
+
}
|
161
|
+
|
162
|
+
next = nsListDup;
|
163
|
+
while(next != NULL) {
|
164
|
+
/* skip spaces */
|
165
|
+
while((*next) == ' ') next++;
|
166
|
+
if((*next) == '\0') break;
|
167
|
+
|
168
|
+
/* find prefix */
|
169
|
+
prefix = next;
|
170
|
+
next = (xmlChar*)xmlStrchr(next, '=');
|
171
|
+
if(next == NULL) {
|
172
|
+
fprintf(stderr,"Error: invalid namespaces list format\n");
|
173
|
+
xmlFree(nsListDup);
|
174
|
+
return(-1);
|
175
|
+
}
|
176
|
+
*(next++) = '\0';
|
177
|
+
|
178
|
+
/* find href */
|
179
|
+
href = next;
|
180
|
+
next = (xmlChar*)xmlStrchr(next, ' ');
|
181
|
+
if(next != NULL) {
|
182
|
+
*(next++) = '\0';
|
183
|
+
}
|
184
|
+
|
185
|
+
/* do register namespace */
|
186
|
+
if(xmlXPathRegisterNs(xpathCtx, prefix, href) != 0) {
|
187
|
+
fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", prefix, href);
|
188
|
+
xmlFree(nsListDup);
|
189
|
+
return(-1);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
xmlFree(nsListDup);
|
194
|
+
return(0);
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* print_xpath_nodes:
|
199
|
+
* @nodes: the nodes set.
|
200
|
+
* @output: the output file handle.
|
201
|
+
*
|
202
|
+
* Prints the @nodes content to @output.
|
203
|
+
*/
|
204
|
+
void
|
205
|
+
print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) {
|
206
|
+
xmlNodePtr cur;
|
207
|
+
int size;
|
208
|
+
int i;
|
209
|
+
|
210
|
+
assert(output);
|
211
|
+
size = (nodes) ? nodes->nodeNr : 0;
|
212
|
+
|
213
|
+
fprintf(output, "Result (%d nodes):\n", size);
|
214
|
+
for(i = 0; i < size; ++i) {
|
215
|
+
assert(nodes->nodeTab[i]);
|
216
|
+
|
217
|
+
if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
|
218
|
+
xmlNsPtr ns;
|
219
|
+
|
220
|
+
ns = (xmlNsPtr)nodes->nodeTab[i];
|
221
|
+
cur = (xmlNodePtr)ns->next;
|
222
|
+
if(cur->ns) {
|
223
|
+
fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n",
|
224
|
+
ns->prefix, ns->href, cur->ns->href, cur->name);
|
225
|
+
} else {
|
226
|
+
fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n",
|
227
|
+
ns->prefix, ns->href, cur->name);
|
228
|
+
}
|
229
|
+
} else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) {
|
230
|
+
cur = nodes->nodeTab[i];
|
231
|
+
if(cur->ns) {
|
232
|
+
fprintf(output, "= element node \"%s:%s\"\n",
|
233
|
+
cur->ns->href, cur->name);
|
234
|
+
} else {
|
235
|
+
fprintf(output, "= element node \"%s\"\n",
|
236
|
+
cur->name);
|
237
|
+
}
|
238
|
+
} else {
|
239
|
+
cur = nodes->nodeTab[i];
|
240
|
+
fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
#else
|
246
|
+
int main(void) {
|
247
|
+
fprintf(stderr, "XPath support not compiled in\n");
|
248
|
+
exit(1);
|
249
|
+
}
|
250
|
+
#endif
|
@@ -0,0 +1,190 @@
|
|
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
|
+
/* Shutdown libxml */
|
51
|
+
xmlCleanupParser();
|
52
|
+
|
53
|
+
/*
|
54
|
+
* this is to debug memory for regression tests
|
55
|
+
*/
|
56
|
+
xmlMemoryDump();
|
57
|
+
return 0;
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* usage:
|
62
|
+
* @name: the program name.
|
63
|
+
*
|
64
|
+
* Prints usage information.
|
65
|
+
*/
|
66
|
+
static void
|
67
|
+
usage(const char *name) {
|
68
|
+
assert(name);
|
69
|
+
|
70
|
+
fprintf(stderr, "Usage: %s <xml-file> <xpath-expr> <value>\n", name);
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* example4:
|
75
|
+
* @filename: the input XML filename.
|
76
|
+
* @xpathExpr: the xpath expression for evaluation.
|
77
|
+
* @value: the new node content.
|
78
|
+
*
|
79
|
+
* Parses input XML file, evaluates XPath expression and update the nodes
|
80
|
+
* then print the result.
|
81
|
+
*
|
82
|
+
* Returns 0 on success and a negative value otherwise.
|
83
|
+
*/
|
84
|
+
static int
|
85
|
+
example4(const char* filename, const xmlChar* xpathExpr, const xmlChar* value) {
|
86
|
+
xmlDocPtr doc;
|
87
|
+
xmlXPathContextPtr xpathCtx;
|
88
|
+
xmlXPathObjectPtr xpathObj;
|
89
|
+
|
90
|
+
assert(filename);
|
91
|
+
assert(xpathExpr);
|
92
|
+
assert(value);
|
93
|
+
|
94
|
+
/* Load XML document */
|
95
|
+
doc = xmlParseFile(filename);
|
96
|
+
if (doc == NULL) {
|
97
|
+
fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
|
98
|
+
return(-1);
|
99
|
+
}
|
100
|
+
|
101
|
+
/* Create xpath evaluation context */
|
102
|
+
xpathCtx = xmlXPathNewContext(doc);
|
103
|
+
if(xpathCtx == NULL) {
|
104
|
+
fprintf(stderr,"Error: unable to create new XPath context\n");
|
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
|
+
/* update selected nodes */
|
119
|
+
update_xpath_nodes(xpathObj->nodesetval, value);
|
120
|
+
|
121
|
+
|
122
|
+
/* Cleanup of XPath data */
|
123
|
+
xmlXPathFreeObject(xpathObj);
|
124
|
+
xmlXPathFreeContext(xpathCtx);
|
125
|
+
|
126
|
+
/* dump the resulting document */
|
127
|
+
xmlDocDump(stdout, doc);
|
128
|
+
|
129
|
+
|
130
|
+
/* free the document */
|
131
|
+
xmlFreeDoc(doc);
|
132
|
+
|
133
|
+
return(0);
|
134
|
+
}
|
135
|
+
|
136
|
+
/**
|
137
|
+
* update_xpath_nodes:
|
138
|
+
* @nodes: the nodes set.
|
139
|
+
* @value: the new value for the node(s)
|
140
|
+
*
|
141
|
+
* Prints the @nodes content to @output.
|
142
|
+
*/
|
143
|
+
static void
|
144
|
+
update_xpath_nodes(xmlNodeSetPtr nodes, const xmlChar* value) {
|
145
|
+
int size;
|
146
|
+
int i;
|
147
|
+
|
148
|
+
assert(value);
|
149
|
+
size = (nodes) ? nodes->nodeNr : 0;
|
150
|
+
|
151
|
+
/*
|
152
|
+
* NOTE: the nodes are processed in reverse order, i.e. reverse document
|
153
|
+
* order because xmlNodeSetContent can actually free up descendant
|
154
|
+
* of the node and such nodes may have been selected too ! Handling
|
155
|
+
* in reverse order ensure that descendant are accessed first, before
|
156
|
+
* they get removed. Mixing XPath and modifications on a tree must be
|
157
|
+
* done carefully !
|
158
|
+
*/
|
159
|
+
for(i = size - 1; i >= 0; i--) {
|
160
|
+
assert(nodes->nodeTab[i]);
|
161
|
+
|
162
|
+
xmlNodeSetContent(nodes->nodeTab[i], value);
|
163
|
+
/*
|
164
|
+
* All the elements returned by an XPath query are pointers to
|
165
|
+
* elements from the tree *except* namespace nodes where the XPath
|
166
|
+
* semantic is different from the implementation in libxml2 tree.
|
167
|
+
* As a result when a returned node set is freed when
|
168
|
+
* xmlXPathFreeObject() is called, that routine must check the
|
169
|
+
* element type. But node from the returned set may have been removed
|
170
|
+
* by xmlNodeSetContent() resulting in access to freed data.
|
171
|
+
* This can be exercised by running
|
172
|
+
* valgrind xpath2 test3.xml '//discarded' discarded
|
173
|
+
* There is 2 ways around it:
|
174
|
+
* - make a copy of the pointers to the nodes from the result set
|
175
|
+
* then call xmlXPathFreeObject() and then modify the nodes
|
176
|
+
* or
|
177
|
+
* - remove the reference to the modified nodes from the node set
|
178
|
+
* as they are processed, if they are not namespace nodes.
|
179
|
+
*/
|
180
|
+
if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
|
181
|
+
nodes->nodeTab[i] = NULL;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
#else
|
186
|
+
int main(void) {
|
187
|
+
fprintf(stderr, "XPath support not compiled in\n");
|
188
|
+
exit(1);
|
189
|
+
}
|
190
|
+
#endif
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<doc>
|
3
|
+
<parent>
|
4
|
+
<discarded>discarded</discarded>
|
5
|
+
<preserved/>
|
6
|
+
This text node must be discarded
|
7
|
+
<discarded>discarded</discarded>
|
8
|
+
<preserved>
|
9
|
+
content1
|
10
|
+
<child1/>
|
11
|
+
<child2>content2</child2>
|
12
|
+
<preserved>too</preserved>
|
13
|
+
<child2>content3</child2>
|
14
|
+
<preserved/>
|
15
|
+
<child2>content4</child2>
|
16
|
+
<preserved/>
|
17
|
+
<child2>content5</child2>
|
18
|
+
content6
|
19
|
+
</preserved>
|
20
|
+
This text node must be discarded
|
21
|
+
<discarded>discarded</discarded>
|
22
|
+
This text node must be discarded
|
23
|
+
<preserved/>
|
24
|
+
This text node must be discarded
|
25
|
+
<preserved/>
|
26
|
+
This text node must be discarded
|
27
|
+
<discarded>discarded</discarded>
|
28
|
+
This text node must be discarded
|
29
|
+
</parent>
|
30
|
+
</doc>
|