diff options
Diffstat (limited to 'examples')
213 files changed, 1892 insertions, 0 deletions
diff --git a/examples/N-order b/examples/N-order new file mode 100644 index 0000000..a244998 --- /dev/null +++ b/examples/N-order @@ -0,0 +1,4 @@ +#!/bin/sh +# make sure -N after other option is allowed +./xmlstarlet sel -T -N n=n -t -v /n:x xml/foo.xml 2>&1 >/dev/null +./xmlstarlet ed -P -N n=n -d /n:x xml/foo.xml 2>&1 >/dev/null diff --git a/examples/bigxml b/examples/bigxml new file mode 100644 index 0000000..0cb746b --- /dev/null +++ b/examples/bigxml @@ -0,0 +1,17 @@ +#!/bin/sh +# check error messages on lines past 2^16 + +SEDLINUM_PROG='s/^\([^:][^:]*:[0-9]\{4\}\)[0-9]\.[0-9][0-9]*:.*$/\1x/p' + +xmldoc() +{ + BAD="$1" + DOCTYPE="$2" + + echo '<?xml version="1.0"?>' + [ -n "$DOCTYPE" ] && echo "$DOCTYPE" + echo '<root>' + ${AWK:-awk} 'BEGIN{for(i=0; i < 69999; i++) print ""}' < /dev/null + echo "$BAD" + echo '</root>' +} diff --git a/examples/bigxml-dtd b/examples/bigxml-dtd new file mode 100644 index 0000000..948d989 --- /dev/null +++ b/examples/bigxml-dtd @@ -0,0 +1,5 @@ +#!/bin/sh +. ./bigxml +xmldoc '<a>foo</a>' \ + | ./xmlstarlet val --dtd dtd/bigxml.dtd --err - 2>&1 >/dev/null \ + | ${SED:-sed} -n "$SEDLINUM_PROG" diff --git a/examples/bigxml-embed b/examples/bigxml-embed new file mode 100644 index 0000000..be39c26 --- /dev/null +++ b/examples/bigxml-embed @@ -0,0 +1,6 @@ +#!/bin/sh +. ./bigxml +xmldoc '<a> foo </a>' \ + '<!DOCTYPE root [<!ELEMENT root (a*)> <!ELEMENT a EMPTY>]>' \ + | ./xmlstarlet val --embed --err - \ + 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" diff --git a/examples/bigxml-embed-ref b/examples/bigxml-embed-ref new file mode 100644 index 0000000..d796475 --- /dev/null +++ b/examples/bigxml-embed-ref @@ -0,0 +1,7 @@ +#!/bin/sh +. ./bigxml +xmldoc '<a>foo</a>' '<!DOCTYPE root SYSTEM "dtd/bigxml.dtd">' \ + | ./xmlstarlet val --embed --err - 2>&1 >/dev/null \ + | ${SED:-sed} -n "$SEDLINUM_PROG" \ + | head -n 1 # a bug in libxml 2.9.0 causes extra errors to be + # printed, so we take just the first diff --git a/examples/bigxml-relaxng b/examples/bigxml-relaxng new file mode 100644 index 0000000..7616471 --- /dev/null +++ b/examples/bigxml-relaxng @@ -0,0 +1,4 @@ +#!/bin/sh +. ./bigxml +xmldoc '<a> foo </a>' | ./xmlstarlet val --relaxng relaxng/bigxml.rng --err - \ + 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" diff --git a/examples/bigxml-well-formed b/examples/bigxml-well-formed new file mode 100644 index 0000000..e664a21 --- /dev/null +++ b/examples/bigxml-well-formed @@ -0,0 +1,4 @@ +#!/bin/sh +. ./bigxml +xmldoc '<b></c>' | ./xmlstarlet val --well-formed --err - \ + 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" diff --git a/examples/bigxml-xsd b/examples/bigxml-xsd new file mode 100644 index 0000000..01ee6b8 --- /dev/null +++ b/examples/bigxml-xsd @@ -0,0 +1,4 @@ +#!/bin/sh +. ./bigxml +xmldoc '<b/>' | ./xmlstarlet val --xsd xsd/bigxml.xsd --err - \ + 2>&1 >/dev/null | ${SED:-sed} -n "$SEDLINUM_PROG" diff --git a/examples/c14n-default-attr b/examples/c14n-default-attr new file mode 100644 index 0000000..525615d --- /dev/null +++ b/examples/c14n-default-attr @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet c14n xml/c14n-default-attr.xml diff --git a/examples/c14n-newlines b/examples/c14n-newlines new file mode 100644 index 0000000..522ff79 --- /dev/null +++ b/examples/c14n-newlines @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet c14n xml/c14n.xml | tr '\r' R | grep R diff --git a/examples/c14n1 b/examples/c14n1 new file mode 100644 index 0000000..56a66e4 --- /dev/null +++ b/examples/c14n1 @@ -0,0 +1,3 @@ +#!/bin/sh +# XML canonicalization +./xmlstarlet c14n --with-comments ../examples/xml/structure.xml ; echo $? diff --git a/examples/c14n2 b/examples/c14n2 new file mode 100644 index 0000000..5695ad3 --- /dev/null +++ b/examples/c14n2 @@ -0,0 +1,3 @@ +#!/bin/sh +# XML exclusive canonicalization +./xmlstarlet c14n --exc-with-comments ../examples/xml/c14n.xml ../examples/xml/c14n.xpath diff --git a/examples/command-help b/examples/command-help new file mode 100644 index 0000000..3482bcb --- /dev/null +++ b/examples/command-help @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ -n "$EXEEXT" ] && [ "$OSTYPE" = MSYS ] ; then + EXEEXT=.exe +fi + +for command in ed sel tr val fo el c14n ls esc unesc pyx p2x ; do + ./xmlstarlet $command --help | ${SED:-sed} -n \ + "s@^\\(Usage: \\).*xml$EXEEXT\\( $command\\).*@\\1xml\\2@p" +done diff --git a/examples/count1 b/examples/count1 new file mode 100644 index 0000000..92f822e --- /dev/null +++ b/examples/count1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Count elements matching XPath expression +./xmlstarlet sel -T -t -v "count(/xml/table/rec/numField)" xml/table.xml diff --git a/examples/countnode1 b/examples/countnode1 new file mode 100644 index 0000000..bc4fa40 --- /dev/null +++ b/examples/countnode1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Count all nodes in XML document +./xmlstarlet sel -T -t -f -o " " -v "count(//node())" --nl xml/table.xml xml/tab-obj.xml diff --git a/examples/delete1 b/examples/delete1 new file mode 100644 index 0000000..620e540 --- /dev/null +++ b/examples/delete1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Delete elements matching XPath expression +./xmlstarlet ed -d '/xml/table/rec[@id="2"]' xml/table.xml diff --git a/examples/docbook1 b/examples/docbook1 new file mode 100644 index 0000000..4cb8380 --- /dev/null +++ b/examples/docbook1 @@ -0,0 +1,4 @@ +#!/bin/sh +# Generate HTML from given SGML docbook document +./xmlstarlet tr --omit-decl --docbook /usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl sgml/docbook1.sgml | \ + ./xmlstarlet fo --html --indent-spaces 2 diff --git a/examples/dtd/bigxml.dtd b/examples/dtd/bigxml.dtd new file mode 100644 index 0000000..4ba3dee --- /dev/null +++ b/examples/dtd/bigxml.dtd @@ -0,0 +1,2 @@ +<!ELEMENT root (a*)> +<!ELEMENT a EMPTY> diff --git a/examples/dtd/tab-obj.dtd b/examples/dtd/tab-obj.dtd new file mode 100644 index 0000000..2cfc16f --- /dev/null +++ b/examples/dtd/tab-obj.dtd @@ -0,0 +1,17 @@ +<!ELEMENT numField ( #PCDATA ) > + +<!ELEMENT object ( property+ ) > +<!ATTLIST object name NMTOKEN #REQUIRED > + +<!ELEMENT property ( #PCDATA ) > +<!ATTLIST property name NMTOKEN #REQUIRED > + +<!ELEMENT rec ( numField, stringField, object? ) > +<!ATTLIST rec id NMTOKEN #REQUIRED > + +<!ELEMENT stringField ( #PCDATA ) > + +<!ELEMENT table ( rec+ ) > + +<!ELEMENT xml ( table ) > + diff --git a/examples/dtd/table.dtd b/examples/dtd/table.dtd new file mode 100644 index 0000000..211f105 --- /dev/null +++ b/examples/dtd/table.dtd @@ -0,0 +1,11 @@ +<!ELEMENT numField ( #PCDATA ) > + +<!ELEMENT rec ( numField, stringField ) > +<!ATTLIST rec id NMTOKEN #REQUIRED > + +<!ELEMENT stringField ( #PCDATA ) > + +<!ELEMENT table ( rec+ ) > + +<!ELEMENT xml ( table ) > + diff --git a/examples/dtd1 b/examples/dtd1 new file mode 100644 index 0000000..8f291bd --- /dev/null +++ b/examples/dtd1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Validate XML document against DTD +./xmlstarlet val --dtd dtd/table.dtd xml/tab-obj.xml >/dev/null 2>&1; echo $? diff --git a/examples/dtd2 b/examples/dtd2 new file mode 100644 index 0000000..d9a8f14 --- /dev/null +++ b/examples/dtd2 @@ -0,0 +1,3 @@ +#!/bin/sh +# Validate XML document against DTD +./xmlstarlet val --dtd dtd/table.dtd xml/table.xml >/dev/null 2>&1; echo $? diff --git a/examples/dtd3 b/examples/dtd3 new file mode 100644 index 0000000..4049489 --- /dev/null +++ b/examples/dtd3 @@ -0,0 +1,3 @@ +#!/bin/sh +# Validate XML document against DTD +./xmlstarlet val --dtd xml/foo.dtd xml/foo.xml 2>/dev/null diff --git a/examples/dtd4 b/examples/dtd4 new file mode 100644 index 0000000..065e3ee --- /dev/null +++ b/examples/dtd4 @@ -0,0 +1,3 @@ +#!/bin/sh +# make sure we don't look for embedded dtd if not asked +./xmlstarlet val --dtd dtd/table.dtd xml/table.xml diff --git a/examples/ed-2op b/examples/ed-2op new file mode 100644 index 0000000..f5903b1 --- /dev/null +++ b/examples/ed-2op @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -a '/xml/table/rec[@id=1]' -t elem -n newrec -v value -d '/xml/table/rec[@id!=1]' xml/table.xml diff --git a/examples/ed-append b/examples/ed-append new file mode 100644 index 0000000..31d386b --- /dev/null +++ b/examples/ed-append @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -a '/xml/table/rec[@id=1]' -t elem -n newrec -v value xml/table.xml diff --git a/examples/ed-backref-delete b/examples/ed-backref-delete new file mode 100644 index 0000000..0d7672a --- /dev/null +++ b/examples/ed-backref-delete @@ -0,0 +1,6 @@ +#!/bin/sh +./xmlstarlet ed \ + -s /xml/table/rec -t elem -n new-field -v new-value \ + -d '$prev' \ + -i '$prev' -t attr -n new-attr -v new-attr-value \ + xml/table.xml diff --git a/examples/ed-backref1 b/examples/ed-backref1 new file mode 100644 index 0000000..985ce9b --- /dev/null +++ b/examples/ed-backref1 @@ -0,0 +1,5 @@ +#!/bin/sh +./xmlstarlet ed \ + -s /xml/table/rec -t elem -n new-field -v new-value \ + -i '$prev' -t attr -n new-attr -v new-attr-value \ + xml/table.xml diff --git a/examples/ed-backref2 b/examples/ed-backref2 new file mode 100644 index 0000000..3420ba0 --- /dev/null +++ b/examples/ed-backref2 @@ -0,0 +1,7 @@ +#!/bin/sh +./xmlstarlet ed \ + -s /xml/table/rec -t elem -n new-field -v new-value \ + --var new-field '$prev' \ + -i '$new-field' -t attr -n new-attr -v new-attr-value \ + -s '$new-field' -t elem -n new-subelem -v '' \ + xml/table.xml | ./xmlstarlet c14n diff --git a/examples/ed-expr b/examples/ed-expr new file mode 100644 index 0000000..9ed1041 --- /dev/null +++ b/examples/ed-expr @@ -0,0 +1,6 @@ +#!/bin/sh +./xmlstarlet ed \ + -u /xml/table/rec/@id -x .+1 \ + -a /xml/table -t elem -n highest-record -v '' \ + -u '$xstar:prev' -x '/xml/table/rec[numField=math:max(../rec/numField)]' \ + xml/table.xml diff --git a/examples/ed-insert b/examples/ed-insert new file mode 100644 index 0000000..b9bc9af --- /dev/null +++ b/examples/ed-insert @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -i '/xml/table/rec[@id=1]' -t attr -n first -v yes xml/table.xml diff --git a/examples/ed-literal b/examples/ed-literal new file mode 100644 index 0000000..d674942 --- /dev/null +++ b/examples/ed-literal @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -u /doc -v '"<>& " & < >' xml/foo.xml diff --git a/examples/ed-move b/examples/ed-move new file mode 100644 index 0000000..4b0fc86 --- /dev/null +++ b/examples/ed-move @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -m '/xml/table/rec[@id=1]/@id' '/xml/table' xml/table.xml diff --git a/examples/ed-namespace b/examples/ed-namespace new file mode 100644 index 0000000..3cc07be --- /dev/null +++ b/examples/ed-namespace @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -d "//namespace::xsi" xml/S0.xml diff --git a/examples/ed-nop b/examples/ed-nop new file mode 100644 index 0000000..c343d8c --- /dev/null +++ b/examples/ed-nop @@ -0,0 +1,4 @@ +#!/bin/sh +# libxml2 returns a NULL nodeset instead of an empty nodeset for this +# xpath expression +./xmlstarlet ed -S -N n=nn -d /n:doc/foo xml/foo.xml diff --git a/examples/ed-subnode b/examples/ed-subnode new file mode 100644 index 0000000..ead761b --- /dev/null +++ b/examples/ed-subnode @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet ed -s '/xml/table/rec[@id=1]' -t elem -n newrec -v value xml/table.xml diff --git a/examples/elem-depth b/examples/elem-depth new file mode 100644 index 0000000..8488e98 --- /dev/null +++ b/examples/elem-depth @@ -0,0 +1,3 @@ +#!/bin/sh +# display unique elements up to depth 2 +./xmlstarlet el -d2 ./xml/tab-obj.xml diff --git a/examples/elem-uniq b/examples/elem-uniq new file mode 100644 index 0000000..e8fe875 --- /dev/null +++ b/examples/elem-uniq @@ -0,0 +1,3 @@ +#!/bin/sh +# display unique elements +./xmlstarlet el -u ./xml/tab-obj.xml diff --git a/examples/elem1 b/examples/elem1 new file mode 100644 index 0000000..a4b5bca --- /dev/null +++ b/examples/elem1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Display element structure of XML document +./xmlstarlet el ./xml/tab-obj.xml diff --git a/examples/elem2 b/examples/elem2 new file mode 100644 index 0000000..1b9243d --- /dev/null +++ b/examples/elem2 @@ -0,0 +1,3 @@ +#!/bin/sh +# Display element structure of XML document (including attributes) +./xmlstarlet el -a ./xml/tab-obj.xml diff --git a/examples/elem3 b/examples/elem3 new file mode 100644 index 0000000..259101e --- /dev/null +++ b/examples/elem3 @@ -0,0 +1,3 @@ +#!/bin/sh +# Display element structure of XML document (including attribute values) +./xmlstarlet el -v ./xml/tab-obj.xml diff --git a/examples/escape1 b/examples/escape1 new file mode 100644 index 0000000..b5c7574 --- /dev/null +++ b/examples/escape1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Escape special XML characters +cat xml/structure.xml | ./xmlstarlet esc diff --git a/examples/exslt-ed b/examples/exslt-ed new file mode 100644 index 0000000..21069f0 --- /dev/null +++ b/examples/exslt-ed @@ -0,0 +1,5 @@ +#!/bin/sh +# Use EXSLT functions +echo '<x/>' | ./xmlstarlet ed -O -u /x -x 'date:day-name("2011-09-24")' +echo '<x/>' | ./xmlstarlet ed -O -u /x -x 'math:abs(-1000)' +echo '<x><n>a</n><n>b</n><n>a</n></x>' | ./xmlstarlet ed -O -u /x -x 'count(set:distinct(/x/*))' diff --git a/examples/exslt1 b/examples/exslt1 new file mode 100644 index 0000000..5d0ba7f --- /dev/null +++ b/examples/exslt1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Calculate EXSLT (XSLT extentions) XPath value +echo "<x/>" | ./xmlstarlet sel -T -t -v "math:abs(-1000)" --nl diff --git a/examples/external-entity b/examples/external-entity new file mode 100644 index 0000000..a087c19 --- /dev/null +++ b/examples/external-entity @@ -0,0 +1,4 @@ +#!/bin/sh +./xmlstarlet sel -t -c //foo xml/external-pe.xml | ./xmlstarlet c14n +echo +./xmlstarlet sel -T -t -v //foo --nl xml/external-pe.xml diff --git a/examples/findfile1 b/examples/findfile1 new file mode 100644 index 0000000..1afb1a4 --- /dev/null +++ b/examples/findfile1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Find XML files matching XPath expression (containing 'object' element) +./xmlstarlet sel -T -t -m //object -f --nl xml/table.xml xml/tab-obj.xml diff --git a/examples/foreach-literal.sh b/examples/foreach-literal.sh new file mode 100644 index 0000000..87a507e --- /dev/null +++ b/examples/foreach-literal.sh @@ -0,0 +1,8 @@ +#!/bin/sh +the_test abc +the_test "a'c" +the_test 'a"c' +the_test a\'\"c +the_test \"\'a\'b\"\" +the_test '!@#$%^&*()_+-=~`\|'\''";:/?.>,<[]{}' +the_test ']]>' diff --git a/examples/foreach-xpath.sh b/examples/foreach-xpath.sh new file mode 100644 index 0000000..62af650 --- /dev/null +++ b/examples/foreach-xpath.sh @@ -0,0 +1,8 @@ +#!/bin/sh +the_test "'abc'" +the_test \"a\'c\" +the_test \'a\"c\' +the_test 'concat("a'\''", '\'\"c\'\) +the_test 'concat('\'\"\',\ \"\'a\'b\",\ \'\"\"\'\) +the_test 'concat("!@#$%^&*()_+-=~`\|'\'\",\''";:/?.>,<[]{}'\'\) +the_test '"]]>"' diff --git a/examples/genxml1 b/examples/genxml1 new file mode 100644 index 0000000..5465b18 --- /dev/null +++ b/examples/genxml1 @@ -0,0 +1,4 @@ +#!/bin/sh +# Generate XML document using command line xml sel +echo "<x/>" | ./xmlstarlet sel -t -m / -e xml -e child -a data -o value | ./xmlstarlet c14n +echo diff --git a/examples/hello1 b/examples/hello1 new file mode 100644 index 0000000..4c9fca1 --- /dev/null +++ b/examples/hello1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Apply XSLT stylesheet to HTML input file +./xmlstarlet tr --html xsl/hello1.xsl html/hello1.html diff --git a/examples/html/hello1.html b/examples/html/hello1.html new file mode 100644 index 0000000..1998f6c --- /dev/null +++ b/examples/html/hello1.html @@ -0,0 +1,10 @@ +<html> +<head> + <title>Hello World</title> + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> +</head> +<body> + <div align="center">Hello World!<br></div> +</body> +</html> + diff --git a/examples/j2ee/web.xml b/examples/j2ee/web.xml new file mode 100644 index 0000000..52a2ddb --- /dev/null +++ b/examples/j2ee/web.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> +<web-app> + <servlet> + <servlet-name>TestServlet</servlet-name> + <servlet-class>TestServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>TestServlet</servlet-name> + <url-pattern>/TestServlet</url-pattern> + </servlet-mapping> + <welcome-file-list> + <welcome-file>TestServlet.html</welcome-file> + </welcome-file-list> +</web-app> + diff --git a/examples/localname1 b/examples/localname1 new file mode 100644 index 0000000..4ae1742 --- /dev/null +++ b/examples/localname1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Use local-name() XSLT function in XPath expression +./xmlstarlet sel -T -t -v "//*[local-name()='query']" --nl xsql/jobserve.xsql diff --git a/examples/look1 b/examples/look1 new file mode 100644 index 0000000..e40b7a9 --- /dev/null +++ b/examples/look1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Select text value of an XML element mathing given XPath expression +./xmlstarlet sel -T -t -m "/xml/table/rec[@id='2']" -v numField --nl xml/table.xml diff --git a/examples/move1 b/examples/move1 new file mode 100644 index 0000000..7a8967c --- /dev/null +++ b/examples/move1 @@ -0,0 +1,4 @@ +#!/bin/sh +# Move element node +echo '<x id="1"><a/><b/></x>' | ./xmlstarlet ed -m "//b" "//a" + diff --git a/examples/noindent1 b/examples/noindent1 new file mode 100644 index 0000000..7c042a1 --- /dev/null +++ b/examples/noindent1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Format XML document disabling indent +cat xml/tab-obj.xml | ./xmlstarlet fo --noindent diff --git a/examples/ns1 b/examples/ns1 new file mode 100644 index 0000000..46f5421 --- /dev/null +++ b/examples/ns1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Predefine namespaces for XPath expressions +./xmlstarlet sel -T -N xsql=urn:oracle-xsql -t -v /xsql:query --nl xsql/jobserve.xsql diff --git a/examples/pyx b/examples/pyx new file mode 100644 index 0000000..2422c8a --- /dev/null +++ b/examples/pyx @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet pyx xml/books.xml | ./xmlstarlet depyx | ./xmlstarlet c14n diff --git a/examples/pyx-ns b/examples/pyx-ns new file mode 100644 index 0000000..6b0a786 --- /dev/null +++ b/examples/pyx-ns @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet pyx xml/c14n.xml | ./xmlstarlet depyx | ./xmlstarlet c14n diff --git a/examples/rdf/em.rdf b/examples/rdf/em.rdf new file mode 100644 index 0000000..19566ba --- /dev/null +++ b/examples/rdf/em.rdf @@ -0,0 +1,11 @@ +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"> + + <contact:Person rdf:about="http://www.w3.org/People/EM/contact#me"> + <contact:fullName>Eric Miller</contact:fullName> + <contact:mailbox rdf:resource="mailto:em@w3.org"/> + <contact:personalTitle>Dr.</contact:personalTitle> + </contact:Person> + +</rdf:RDF> + diff --git a/examples/recover1 b/examples/recover1 new file mode 100644 index 0000000..06164eb --- /dev/null +++ b/examples/recover1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Recover malformed XML document +./xmlstarlet fo -R xml/malformed.xml 2>/dev/null diff --git a/examples/relaxng/address-bad.xml b/examples/relaxng/address-bad.xml new file mode 100644 index 0000000..35bb986 --- /dev/null +++ b/examples/relaxng/address-bad.xml @@ -0,0 +1,11 @@ +<addressBook> + <card> + <name>John Smith</name> + <email>js@example.com</email> + </card> + <card> + <name>Fred Bloggs</name> + <email>fb@example.net</email> + </card> + <reord></record> +</addressBook> diff --git a/examples/relaxng/address.rng b/examples/relaxng/address.rng new file mode 100644 index 0000000..86f8cd1 --- /dev/null +++ b/examples/relaxng/address.rng @@ -0,0 +1,12 @@ +<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"> + <zeroOrMore> + <element name="card"> + <element name="name"> + <text/> + </element> + <element name="email"> + <text/> + </element> + </element> + </zeroOrMore> +</element> diff --git a/examples/relaxng/address.xml b/examples/relaxng/address.xml new file mode 100644 index 0000000..edac8ba --- /dev/null +++ b/examples/relaxng/address.xml @@ -0,0 +1,10 @@ +<addressBook> + <card> + <name>John Smith</name> + <email>js@example.com</email> + </card> + <card> + <name>Fred Bloggs</name> + <email>fb@example.net</email> + </card> +</addressBook> diff --git a/examples/relaxng/bigxml.rng b/examples/relaxng/bigxml.rng new file mode 100644 index 0000000..8c22f16 --- /dev/null +++ b/examples/relaxng/bigxml.rng @@ -0,0 +1,5 @@ +<element name="root" xmlns="http://relaxng.org/ns/structure/1.0"> + <zeroOrMore> + <element name="a"> <empty/></element> + </zeroOrMore> +</element> diff --git a/examples/rename-attr1 b/examples/rename-attr1 new file mode 100644 index 0000000..9fee306 --- /dev/null +++ b/examples/rename-attr1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Rename attributes +./xmlstarlet ed -r "//*/@id" -v ID xml/tab-obj.xml diff --git a/examples/rename-elem1 b/examples/rename-elem1 new file mode 100644 index 0000000..3709be2 --- /dev/null +++ b/examples/rename-elem1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Rename elements +./xmlstarlet ed -r "/xml/table/rec" -v record xml/tab-obj.xml diff --git a/examples/results/N-order.out b/examples/results/N-order.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/N-order.out diff --git a/examples/results/bigxml-dtd.out b/examples/results/bigxml-dtd.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml-dtd.out diff --git a/examples/results/bigxml-embed-ref.out b/examples/results/bigxml-embed-ref.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml-embed-ref.out diff --git a/examples/results/bigxml-embed.out b/examples/results/bigxml-embed.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml-embed.out diff --git a/examples/results/bigxml-relaxng.out b/examples/results/bigxml-relaxng.out new file mode 100644 index 0000000..7c8969f --- /dev/null +++ b/examples/results/bigxml-relaxng.out @@ -0,0 +1 @@ +-:7000x diff --git a/examples/results/bigxml-well-formed.out b/examples/results/bigxml-well-formed.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml-well-formed.out diff --git a/examples/results/bigxml-xsd.out b/examples/results/bigxml-xsd.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml-xsd.out diff --git a/examples/results/bigxml.out b/examples/results/bigxml.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/bigxml.out diff --git a/examples/results/c14n-default-attr.out b/examples/results/c14n-default-attr.out new file mode 100644 index 0000000..2d449fe --- /dev/null +++ b/examples/results/c14n-default-attr.out @@ -0,0 +1 @@ +<doc attr="default"></doc>
\ No newline at end of file diff --git a/examples/results/c14n-newlines.out b/examples/results/c14n-newlines.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/c14n-newlines.out diff --git a/examples/results/c14n1.out b/examples/results/c14n1.out new file mode 100644 index 0000000..4010be7 --- /dev/null +++ b/examples/results/c14n1.out @@ -0,0 +1,14 @@ +<a1> + <a11> + <a111> + <a1111></a1111> + </a111> + <a112> + <a1121></a1121> + </a112> + </a11> + <a12></a12> + <a13> + <a131></a131> + </a13> +</a1>0 diff --git a/examples/results/c14n2.out b/examples/results/c14n2.out new file mode 100644 index 0000000..7c35341 --- /dev/null +++ b/examples/results/c14n2.out @@ -0,0 +1,3 @@ +<n1:elem1 xmlns:n1="http://b.example"> +content +</n1:elem1>
\ No newline at end of file diff --git a/examples/results/command-help.out b/examples/results/command-help.out new file mode 100644 index 0000000..0d6b5a0 --- /dev/null +++ b/examples/results/command-help.out @@ -0,0 +1,12 @@ +Usage: xml ed +Usage: xml sel +Usage: xml tr +Usage: xml val +Usage: xml fo +Usage: xml el +Usage: xml c14n +Usage: xml ls +Usage: xml esc +Usage: xml unesc +Usage: xml pyx +Usage: xml p2x diff --git a/examples/results/count1.out b/examples/results/count1.out new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/examples/results/count1.out @@ -0,0 +1 @@ +3
\ No newline at end of file diff --git a/examples/results/countnode1.out b/examples/results/countnode1.out new file mode 100644 index 0000000..5b420f1 --- /dev/null +++ b/examples/results/countnode1.out @@ -0,0 +1,2 @@ +xml/table.xml 32 +xml/tab-obj.xml 41 diff --git a/examples/results/delete1.out b/examples/results/delete1.out new file mode 100644 index 0000000..5971fba --- /dev/null +++ b/examples/results/delete1.out @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/docbook1.out b/examples/results/docbook1.out new file mode 100644 index 0000000..e41f015 --- /dev/null +++ b/examples/results/docbook1.out @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<html> + <head> + <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"/> + <title>DocBook document example</title> + <meta name="generator" content="DocBook XSL Stylesheets V1.48"/> + </head> + <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> + <div class="book"> + <div class="titlepage"> + <div> + <h1 class="title"><a name="id2765244"/>DocBook document example</h1> + </div> + <div> + <h3 class="author">Mikhail Grushinskiy</h3> + </div> + <div> + <p class="copyright">Copyright © 2002 Mikhail Grushinskiy</p> + </div> + <hr/> + </div> + <div class="toc"> + <p> + <b>Table of Contents</b> + </p> + <dl> + <dt> + <a href="#id2765482">Sample document</a> + </dt> + <dt>1. <a href="#id2767329">XMLStarlet Example</a></dt> + </dl> + </div> + <div class="preface"> + <div class="titlepage"> + <div> + <h2 class="title"><a name="id2765482"/>Sample document</h2> + </div> + </div> + <p>A simple DocBook example document.</p> + </div> + <div class="chapter"> + <div class="titlepage"> + <div> + <h2 class="title"><a name="id2767329"/>Chapter 1. XMLStarlet Example</h2> + </div> + </div> + <p>The <span class="emphasis"><i>XMLStarlet</i></span> command line toolkit + allows querying/checking/editing/transforming/formatting XML documents + from command line</p> + <p>To find out more on how to use the + <span class="emphasis"><i>XMLStarlet</i></span> for XML processing, point + your browser to <a href="http://xmlstar.sourceforge.net/" target="_top">http://xmlstar.sourceforge.net/</a>. + </p> + </div> + </div> + </body> +</html> diff --git a/examples/results/dtd1.out b/examples/results/dtd1.out new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/examples/results/dtd1.out @@ -0,0 +1 @@ +1 diff --git a/examples/results/dtd2.out b/examples/results/dtd2.out new file mode 100644 index 0000000..573541a --- /dev/null +++ b/examples/results/dtd2.out @@ -0,0 +1 @@ +0 diff --git a/examples/results/dtd3.out b/examples/results/dtd3.out new file mode 100644 index 0000000..29afc5b --- /dev/null +++ b/examples/results/dtd3.out @@ -0,0 +1 @@ +xml/foo.xml - invalid diff --git a/examples/results/dtd4.out b/examples/results/dtd4.out new file mode 100644 index 0000000..41e1b68 --- /dev/null +++ b/examples/results/dtd4.out @@ -0,0 +1 @@ +xml/table.xml - valid diff --git a/examples/results/ed-2op.out b/examples/results/ed-2op.out new file mode 100644 index 0000000..ff35181 --- /dev/null +++ b/examples/results/ed-2op.out @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <newrec>value</newrec> + </table> +</xml> diff --git a/examples/results/ed-append.out b/examples/results/ed-append.out new file mode 100644 index 0000000..0c7c37e --- /dev/null +++ b/examples/results/ed-append.out @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <newrec>value</newrec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/ed-backref-delete.out b/examples/results/ed-backref-delete.out new file mode 100644 index 0000000..fd347de --- /dev/null +++ b/examples/results/ed-backref-delete.out @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/ed-backref1.out b/examples/results/ed-backref1.out new file mode 100644 index 0000000..d8b7893 --- /dev/null +++ b/examples/results/ed-backref1.out @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <new-field new-attr="new-attr-value">new-value</new-field> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + <new-field new-attr="new-attr-value">new-value</new-field> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + <new-field new-attr="new-attr-value">new-value</new-field> + </rec> + </table> +</xml> diff --git a/examples/results/ed-backref2.out b/examples/results/ed-backref2.out new file mode 100644 index 0000000..6d823ce --- /dev/null +++ b/examples/results/ed-backref2.out @@ -0,0 +1,19 @@ +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <new-field new-attr="new-attr-value">new-value<new-subelem></new-subelem></new-field> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + <new-field new-attr="new-attr-value">new-value<new-subelem></new-subelem></new-field> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + <new-field new-attr="new-attr-value">new-value<new-subelem></new-subelem></new-field> + </rec> + </table> +</xml>
\ No newline at end of file diff --git a/examples/results/ed-expr.out b/examples/results/ed-expr.out new file mode 100644 index 0000000..bb19961 --- /dev/null +++ b/examples/results/ed-expr.out @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="2"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <rec id="3"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="4"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> + <highest-record> + <rec id="3"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + </highest-record> +</xml> diff --git a/examples/results/ed-insert.out b/examples/results/ed-insert.out new file mode 100644 index 0000000..49ee98e --- /dev/null +++ b/examples/results/ed-insert.out @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1" first="yes"> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/ed-literal.out b/examples/results/ed-literal.out new file mode 100644 index 0000000..05b2bba --- /dev/null +++ b/examples/results/ed-literal.out @@ -0,0 +1,3 @@ +<?xml version="1.0"?> +<!DOCTYPE doc SYSTEM "foo.dtd"> +<doc>"<>& &quot; &amp; &lt; &gt;</doc> diff --git a/examples/results/ed-move.out b/examples/results/ed-move.out new file mode 100644 index 0000000..c165165 --- /dev/null +++ b/examples/results/ed-move.out @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<xml> + <table id="1"> + <rec> + <numField>123</numField> + <stringField>String Value</stringField> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/ed-namespace.out b/examples/results/ed-namespace.out new file mode 100644 index 0000000..8e13af1 --- /dev/null +++ b/examples/results/ed-namespace.out @@ -0,0 +1,3 @@ +<doc xmlns="http://www.foo.com/namespaces/my"> + <el/> +</doc> diff --git a/examples/results/ed-nop.out b/examples/results/ed-nop.out new file mode 100644 index 0000000..5323054 --- /dev/null +++ b/examples/results/ed-nop.out @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<!DOCTYPE doc SYSTEM "foo.dtd"> +<doc> +<foo>This is a "foo" line.</foo> +<bar>This is a "bar" line.</bar> +<foo>This is another "foo" line.</foo> +</doc> diff --git a/examples/results/ed-subnode.out b/examples/results/ed-subnode.out new file mode 100644 index 0000000..9f008cc --- /dev/null +++ b/examples/results/ed-subnode.out @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <newrec>value</newrec> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/elem-depth.out b/examples/results/elem-depth.out new file mode 100644 index 0000000..97c7349 --- /dev/null +++ b/examples/results/elem-depth.out @@ -0,0 +1,2 @@ +xml +xml/table diff --git a/examples/results/elem-uniq.out b/examples/results/elem-uniq.out new file mode 100644 index 0000000..7c97a24 --- /dev/null +++ b/examples/results/elem-uniq.out @@ -0,0 +1,7 @@ +xml +xml/table +xml/table/rec +xml/table/rec/numField +xml/table/rec/object +xml/table/rec/object/property +xml/table/rec/stringField diff --git a/examples/results/elem1.out b/examples/results/elem1.out new file mode 100644 index 0000000..ccc1825 --- /dev/null +++ b/examples/results/elem1.out @@ -0,0 +1,14 @@ +xml +xml/table +xml/table/rec +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec/object +xml/table/rec/object/property +xml/table/rec/object/property +xml/table/rec +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec +xml/table/rec/numField +xml/table/rec/stringField diff --git a/examples/results/elem2.out b/examples/results/elem2.out new file mode 100644 index 0000000..14737b5 --- /dev/null +++ b/examples/results/elem2.out @@ -0,0 +1,20 @@ +xml +xml/table +xml/table/rec +xml/table/rec/@id +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec/object +xml/table/rec/object/@name +xml/table/rec/object/property +xml/table/rec/object/property/@name +xml/table/rec/object/property +xml/table/rec/object/property/@name +xml/table/rec +xml/table/rec/@id +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec +xml/table/rec/@id +xml/table/rec/numField +xml/table/rec/stringField diff --git a/examples/results/elem3.out b/examples/results/elem3.out new file mode 100644 index 0000000..0df31dd --- /dev/null +++ b/examples/results/elem3.out @@ -0,0 +1,14 @@ +xml +xml/table +xml/table/rec[@id='1'] +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec/object[@name='Obj1'] +xml/table/rec/object/property[@name='size'] +xml/table/rec/object/property[@name='type'] +xml/table/rec[@id='2'] +xml/table/rec/numField +xml/table/rec/stringField +xml/table/rec[@id='3'] +xml/table/rec/numField +xml/table/rec/stringField diff --git a/examples/results/escape1.out b/examples/results/escape1.out new file mode 100644 index 0000000..e7982eb --- /dev/null +++ b/examples/results/escape1.out @@ -0,0 +1,14 @@ +<a1> + <a11> + <a111> + <a1111/> + </a111> + <a112> + <a1121/> + </a112> + </a11> + <a12/> + <a13> + <a131/> + </a13> +</a1> diff --git a/examples/results/exslt-ed.out b/examples/results/exslt-ed.out new file mode 100644 index 0000000..e670310 --- /dev/null +++ b/examples/results/exslt-ed.out @@ -0,0 +1,3 @@ +<x>Saturday</x> +<x>1000</x> +<x>2</x> diff --git a/examples/results/exslt1.out b/examples/results/exslt1.out new file mode 100644 index 0000000..83b33d2 --- /dev/null +++ b/examples/results/exslt1.out @@ -0,0 +1 @@ +1000 diff --git a/examples/results/external-entity.out b/examples/results/external-entity.out new file mode 100644 index 0000000..9ca413f --- /dev/null +++ b/examples/results/external-entity.out @@ -0,0 +1,2 @@ +<foo>bar</foo> +bar diff --git a/examples/results/findfile1.out b/examples/results/findfile1.out new file mode 100644 index 0000000..ddc3803 --- /dev/null +++ b/examples/results/findfile1.out @@ -0,0 +1 @@ +xml/tab-obj.xml diff --git a/examples/results/genxml1.out b/examples/results/genxml1.out new file mode 100644 index 0000000..1cd3352 --- /dev/null +++ b/examples/results/genxml1.out @@ -0,0 +1 @@ +<xml><child data="value"></child></xml> diff --git a/examples/results/hello1.out b/examples/results/hello1.out new file mode 100644 index 0000000..c57eff5 --- /dev/null +++ b/examples/results/hello1.out @@ -0,0 +1 @@ +Hello World!
\ No newline at end of file diff --git a/examples/results/localname1.out b/examples/results/localname1.out new file mode 100644 index 0000000..983fe6e --- /dev/null +++ b/examples/results/localname1.out @@ -0,0 +1,6 @@ + + SELECT substr(title,1,26) short_title, title, location, skills + FROM job + WHERE UPPER(title) LIKE '%ORACLE%' + ORDER BY first_posted DESC + diff --git a/examples/results/look1.out b/examples/results/look1.out new file mode 100644 index 0000000..99ca0d5 --- /dev/null +++ b/examples/results/look1.out @@ -0,0 +1 @@ +346 diff --git a/examples/results/move1.out b/examples/results/move1.out new file mode 100644 index 0000000..e02efd8 --- /dev/null +++ b/examples/results/move1.out @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<x id="1"> + <a> + <b/> + </a> +</x> diff --git a/examples/results/noindent1.out b/examples/results/noindent1.out new file mode 100644 index 0000000..8760759 --- /dev/null +++ b/examples/results/noindent1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> +<table> +<rec id="1"> +<numField>123</numField> +<stringField>String Value</stringField> +<object name="Obj1"> +<property name="size">10</property> +<property name="type">Data</property> +</object> +</rec> +<rec id="2"> +<numField>346</numField> +<stringField>Text Value</stringField> +</rec> +<rec id="3"> +<numField>-23</numField> +<stringField>stringValue</stringField> +</rec> +</table> +</xml> diff --git a/examples/results/ns1.out b/examples/results/ns1.out new file mode 100644 index 0000000..983fe6e --- /dev/null +++ b/examples/results/ns1.out @@ -0,0 +1,6 @@ + + SELECT substr(title,1,26) short_title, title, location, skills + FROM job + WHERE UPPER(title) LIKE '%ORACLE%' + ORDER BY first_posted DESC + diff --git a/examples/results/pyx-ns.out b/examples/results/pyx-ns.out new file mode 100644 index 0000000..7a6ca3f --- /dev/null +++ b/examples/results/pyx-ns.out @@ -0,0 +1,5 @@ +<n0:pdu xmlns:n0="http://a.example.com"> +<n1:elem1 xmlns:n1="http://b.example"> +content +</n1:elem1> +</n0:pdu>
\ No newline at end of file diff --git a/examples/results/pyx.out b/examples/results/pyx.out new file mode 100644 index 0000000..db5d41b --- /dev/null +++ b/examples/results/pyx.out @@ -0,0 +1,14 @@ +<books> +<begin></begin> +<book type="hardback"> +<title>Atlas Shrugged</title> +<author>Ayn Rand</author> +<isbn id="1">0525934189<br></br></isbn> +</book> +Next Book +<book type="paperback"> +<title>A Burnt-Out Case</title> +<author>Graham Greene</author> +<isbn id="2">0140185399<br></br></isbn> +</book> +</books>
\ No newline at end of file diff --git a/examples/results/recover1.out b/examples/results/recover1.out new file mode 100644 index 0000000..fb7102d --- /dev/null +++ b/examples/results/recover1.out @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<test_output> + <test_name>foo</test_name> + <subtest>...</subtest> +</test_output> diff --git a/examples/results/rename-attr1.out b/examples/results/rename-attr1.out new file mode 100644 index 0000000..13e0a33 --- /dev/null +++ b/examples/results/rename-attr1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec ID="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec ID="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec ID="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/rename-elem1.out b/examples/results/rename-elem1.out new file mode 100644 index 0000000..1f8d3bb --- /dev/null +++ b/examples/results/rename-elem1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <record id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </record> + <record id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </record> + <record id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </record> + </table> +</xml> diff --git a/examples/results/schema1.out b/examples/results/schema1.out new file mode 100644 index 0000000..a1ed3bd --- /dev/null +++ b/examples/results/schema1.out @@ -0,0 +1,2 @@ +xml/tab-obj.xml +1 diff --git a/examples/results/sel-if.out b/examples/results/sel-if.out new file mode 100644 index 0000000..830ab19 --- /dev/null +++ b/examples/results/sel-if.out @@ -0,0 +1,6 @@ +yes +all +no +all +maybe +all diff --git a/examples/results/sel-literal.out b/examples/results/sel-literal.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/sel-literal.out diff --git a/examples/results/sel-many-values.out b/examples/results/sel-many-values.out new file mode 100644 index 0000000..5f5fbe7 --- /dev/null +++ b/examples/results/sel-many-values.out @@ -0,0 +1,3 @@ +1 +2 +3
\ No newline at end of file diff --git a/examples/results/sel-root.out b/examples/results/sel-root.out new file mode 100644 index 0000000..6fee35f --- /dev/null +++ b/examples/results/sel-root.out @@ -0,0 +1,2 @@ +<xsl-select><x></x></xsl-select> +<xsl-select><x></x><x></x></xsl-select> diff --git a/examples/results/sel-xpath-c.out b/examples/results/sel-xpath-c.out new file mode 100644 index 0000000..2baab9a --- /dev/null +++ b/examples/results/sel-xpath-c.out @@ -0,0 +1,7 @@ +abc +a'c +a"c +a'"c +"'a'b"" +!@#$%^&*()_+-=~`\|'";:/?.>,<[]{} +]]> diff --git a/examples/results/sel-xpath-i.out b/examples/results/sel-xpath-i.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/sel-xpath-i.out diff --git a/examples/results/sel-xpath-m.out b/examples/results/sel-xpath-m.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/sel-xpath-m.out diff --git a/examples/results/sel-xpath-v.out b/examples/results/sel-xpath-v.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/results/sel-xpath-v.out diff --git a/examples/results/sel1.out b/examples/results/sel1.out new file mode 100644 index 0000000..c622814 --- /dev/null +++ b/examples/results/sel1.out @@ -0,0 +1,4 @@ +<ROOT><rec id="1"><numField>123</numField><stringField>String Value</stringField></rec> +<rec id="2"><numField>346</numField><stringField>Text Value</stringField></rec> +<rec id="3"><numField>-23</numField><stringField>stringValue</stringField></rec> +</ROOT>
\ No newline at end of file diff --git a/examples/results/sort1.out b/examples/results/sort1.out new file mode 100644 index 0000000..0488af5 --- /dev/null +++ b/examples/results/sort1.out @@ -0,0 +1,3 @@ +3|-23|stringValue +2|346|Text Value +1|123|String Value diff --git a/examples/results/sort2.out b/examples/results/sort2.out new file mode 100644 index 0000000..e36f68a --- /dev/null +++ b/examples/results/sort2.out @@ -0,0 +1,10 @@ +A +a +E +e +B +b +C +c +D +d diff --git a/examples/results/sort3.out b/examples/results/sort3.out new file mode 100644 index 0000000..3fce669 --- /dev/null +++ b/examples/results/sort3.out @@ -0,0 +1,10 @@ +a +A +b +B +c +C +d +D +e +E diff --git a/examples/results/structure1.out b/examples/results/structure1.out new file mode 100644 index 0000000..5eb1948 --- /dev/null +++ b/examples/results/structure1.out @@ -0,0 +1,9 @@ +a1 +a1.a11 +a1.a11.a111 +a1.a11.a111.a1111 +a1.a11.a112 +a1.a11.a112.a1121 +a1.a12 +a1.a13 +a1.a13.a131 diff --git a/examples/results/sum1.out b/examples/results/sum1.out new file mode 100644 index 0000000..0187835 --- /dev/null +++ b/examples/results/sum1.out @@ -0,0 +1 @@ +446 diff --git a/examples/results/tab1.out b/examples/results/tab1.out new file mode 100644 index 0000000..338eb72 --- /dev/null +++ b/examples/results/tab1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/table1.out b/examples/results/table1.out new file mode 100644 index 0000000..7dac0ea --- /dev/null +++ b/examples/results/table1.out @@ -0,0 +1,3 @@ +1|123|String Value +2|346|Text Value +3|-23|stringValue diff --git a/examples/results/table2.out b/examples/results/table2.out new file mode 100644 index 0000000..7dac0ea --- /dev/null +++ b/examples/results/table2.out @@ -0,0 +1,3 @@ +1|123|String Value +2|346|Text Value +3|-23|stringValue diff --git a/examples/results/table3.out b/examples/results/table3.out new file mode 100644 index 0000000..5ce5d52 --- /dev/null +++ b/examples/results/table3.out @@ -0,0 +1,5 @@ +=================== +1|123|String Value +2|346|Text Value +3|-23|stringValue +=================== diff --git a/examples/results/tree1.out b/examples/results/tree1.out new file mode 100644 index 0000000..0279695 --- /dev/null +++ b/examples/results/tree1.out @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ISO-8859-1"?>
+<books>
+ <book type="hardback">
+ <isbn id="1">0525934189</isbn>
+ </book>
+ <book type="paperback">
+ <isbn id="2">0140185399</isbn>
+ </book>
+</books>
diff --git a/examples/results/unicode1.out b/examples/results/unicode1.out new file mode 100644 index 0000000..cbc9f3c --- /dev/null +++ b/examples/results/unicode1.out @@ -0,0 +1,3 @@ +français +français +français diff --git a/examples/results/update-attr1.out b/examples/results/update-attr1.out new file mode 100644 index 0000000..9578728 --- /dev/null +++ b/examples/results/update-attr1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="5"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/update-elem1.out b/examples/results/update-elem1.out new file mode 100644 index 0000000..4b03f27 --- /dev/null +++ b/examples/results/update-elem1.out @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>0</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/results/valid1.out b/examples/results/valid1.out new file mode 100644 index 0000000..e21ffbe --- /dev/null +++ b/examples/results/valid1.out @@ -0,0 +1,62 @@ +=============================================== +Well-Formedness Validation Tests +- 1 ------------------------------------------- +xml/table.xml - valid +xml/tab-obj.xml - valid +xml/tab-bad.xml - invalid +1 +- 2 ------------------------------------------- +xml/table.xml +xml/tab-obj.xml +1 +- 3 ------------------------------------------- +xml/tab-bad.xml +1 +- 4 ------------------------------------------- +0 +=============================================== +DTD Validation Tests +- 1 ------------------------------------------- +xml/table.xml - valid +xml/tab-obj.xml - invalid +xml/tab-bad.xml - invalid +1 +- 2 ------------------------------------------- +xml/table.xml +1 +- 3 ------------------------------------------- +xml/tab-obj.xml +xml/tab-bad.xml +1 +- 4 ------------------------------------------- +0 +=============================================== +Schema Validation Tests +- 1 ------------------------------------------- +xml/table.xml - valid +xml/tab-obj.xml - invalid +xml/tab-bad.xml - invalid +1 +- 2 ------------------------------------------- +xml/table.xml +1 +- 3 ------------------------------------------- +xml/tab-obj.xml +xml/tab-bad.xml +1 +- 4 ------------------------------------------- +0 +=============================================== +RelaxNG Schema Validation Tests +- 1 ------------------------------------------- +relaxng/address.xml - valid +relaxng/address-bad.xml - invalid +1 +- 2 ------------------------------------------- +relaxng/address.xml +1 +- 3 ------------------------------------------- +relaxng/address-bad.xml +1 +- 4 ------------------------------------------- +0 diff --git a/examples/results/xinclude1.out b/examples/results/xinclude1.out new file mode 100644 index 0000000..d369b2f --- /dev/null +++ b/examples/results/xinclude1.out @@ -0,0 +1,8 @@ +<document xmlns:xi="http://www.w3.org/2003/XInclude"> + <p>120 Mz is adequate for an average home user.</p> + <disclaimer> + <p>The opinions represented herein represent those of the individual + and should not be interpreted as official policy endorsed by this + organization.</p> +</disclaimer> +</document>
\ No newline at end of file diff --git a/examples/results/xsl-param1.out b/examples/results/xsl-param1.out new file mode 100644 index 0000000..c155c07 --- /dev/null +++ b/examples/results/xsl-param1.out @@ -0,0 +1 @@ +Count=3 diff --git a/examples/results/xsl-sum1.out b/examples/results/xsl-sum1.out new file mode 100644 index 0000000..0187835 --- /dev/null +++ b/examples/results/xsl-sum1.out @@ -0,0 +1 @@ +446 diff --git a/examples/schema1 b/examples/schema1 new file mode 100644 index 0000000..cb88052 --- /dev/null +++ b/examples/schema1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Validate against XSD schema +./xmlstarlet val -b -s xsd/table.xsd xml/table.xml xml/tab-obj.xml 2>/dev/null; echo $? diff --git a/examples/sel-if b/examples/sel-if new file mode 100644 index 0000000..c6acd1d --- /dev/null +++ b/examples/sel-if @@ -0,0 +1,4 @@ +#!/bin/sh +echo '<x/>' | ./xmlstarlet sel -T -t -i 'true()' -o yes -n --else -o no -n -b -o all -n +echo '<x/>' | ./xmlstarlet sel -T -t -i 'false()' -o yes -n --else -o no -n -b -o all -n +echo '<x/>' | ./xmlstarlet sel -T -t -i 'false()' -o yes -n --elif 'true()' -o maybe -n --else -o no -n -b -o all -n diff --git a/examples/sel-literal b/examples/sel-literal new file mode 100644 index 0000000..ee78448 --- /dev/null +++ b/examples/sel-literal @@ -0,0 +1,6 @@ +#!/bin/sh +the_test() { + ./xmlstarlet sel --text -t -m /doc -o "$1" --nl xml/foo.xml +} + +. "${srcdir-..}"/examples/foreach-literal.sh diff --git a/examples/sel-many-values b/examples/sel-many-values new file mode 100644 index 0000000..6cf4cc8 --- /dev/null +++ b/examples/sel-many-values @@ -0,0 +1,2 @@ +#!/bin/sh +./xmlstarlet sel -T -t -v //@id xml/table.xml diff --git a/examples/sel-root b/examples/sel-root new file mode 100644 index 0000000..12a9bb2 --- /dev/null +++ b/examples/sel-root @@ -0,0 +1,5 @@ +#!/bin/sh +echo '<x/>' | ./xmlstarlet sel --root -t -c / | ./xmlstarlet c14n +echo +echo '<x/>' | ./xmlstarlet sel --root -t -c / -t -c / | ./xmlstarlet c14n +echo diff --git a/examples/sel-xpath-c b/examples/sel-xpath-c new file mode 100644 index 0000000..602ee4e --- /dev/null +++ b/examples/sel-xpath-c @@ -0,0 +1,6 @@ +#!/bin/sh +the_test() { + ./xmlstarlet sel --text -t -m /doc -c "$1" --nl xml/foo.xml +} + +. "${srcdir-..}"/examples/foreach-xpath.sh diff --git a/examples/sel-xpath-i b/examples/sel-xpath-i new file mode 100644 index 0000000..ad3cba2 --- /dev/null +++ b/examples/sel-xpath-i @@ -0,0 +1,6 @@ +#!/bin/sh +the_test() { + ./xmlstarlet sel --text -t -i "$1" -v "$1" --nl xml/foo.xml +} + +. "${srcdir-..}"/examples/foreach-xpath.sh diff --git a/examples/sel-xpath-m b/examples/sel-xpath-m new file mode 100644 index 0000000..cfe7786 --- /dev/null +++ b/examples/sel-xpath-m @@ -0,0 +1,6 @@ +#!/bin/sh +the_test() { + ./xmlstarlet sel --text -t -m "/*[boolean($1)]" -v "$1" --nl xml/foo.xml +} + +. "${srcdir-..}"/examples/foreach-xpath.sh diff --git a/examples/sel-xpath-v b/examples/sel-xpath-v new file mode 100644 index 0000000..e9bec7b --- /dev/null +++ b/examples/sel-xpath-v @@ -0,0 +1,6 @@ +#!/bin/sh +the_test() { + ./xmlstarlet sel --text -t -m /doc -v "$1" --nl xml/foo.xml +} + +. "${srcdir-..}"/examples/foreach-xpath.sh diff --git a/examples/sel1 b/examples/sel1 new file mode 100644 index 0000000..ab24a6c --- /dev/null +++ b/examples/sel1 @@ -0,0 +1,3 @@ +#!/bin/sh +# xsl:copy-of in xml sel command +./xmlstarlet sel -B -t -e ROOT -m /xml/table/rec -c . -n xml/table.xml | ./xmlstarlet c14n diff --git a/examples/sgml/docbook1.sgml b/examples/sgml/docbook1.sgml new file mode 100644 index 0000000..c8bd6b8 --- /dev/null +++ b/examples/sgml/docbook1.sgml @@ -0,0 +1,41 @@ +<!DOCTYPE book + PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> +<book> + + <bookinfo> + <title>DocBook document example</title> + <author> + <firstname>Mikhail</firstname> + <surname>Grushinskiy</surname> + </author> + + <copyright> + <year>2002</year> + <holder>Mikhail Grushinskiy</holder> + </copyright> + </bookinfo> + + <preface> + <title>Sample document</title> + + <para>A simple DocBook example document.</para> + </preface> + + <chapter> + <title>XMLStarlet Example</title> + + <para>The <emphasis>XMLStarlet</emphasis> command line toolkit + allows querying/checking/editing/transforming/formatting XML documents + from command line</para> + + <para>To find out more on how to use the + <emphasis>XMLStarlet</emphasis> for XML processing, point + your browser to <ulink + url="http://xmlstar.sourceforge.net/">http://xmlstar.sourceforge.net/</ulink>. + </para> + + </chapter> + +</book> + diff --git a/examples/sort1 b/examples/sort1 new file mode 100644 index 0000000..aa21316 --- /dev/null +++ b/examples/sort1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Query XML document and produce sorted text table +./xmlstarlet sel -T -t -m /xml/table/rec -s D:N:- "@id" -v "concat(@id,'|',numField,'|',stringField)" -n xml/table.xml diff --git a/examples/sort2 b/examples/sort2 new file mode 100644 index 0000000..49a6d45 --- /dev/null +++ b/examples/sort2 @@ -0,0 +1,4 @@ +#!/bin/sh +# Sort on two fields +./xmlstarlet sel -T -t -m /root/elem -s A:N:U @rank -s A:T:U @name -v @name -n xml/unsorted.xml + diff --git a/examples/sort3 b/examples/sort3 new file mode 100644 index 0000000..ba07e99 --- /dev/null +++ b/examples/sort3 @@ -0,0 +1,4 @@ +#!/bin/sh +# lower case first +./xmlstarlet sel -T -t -m /root/elem -s A:T:L @name -v @name -n xml/unsorted.xml + diff --git a/examples/structure1 b/examples/structure1 new file mode 100644 index 0000000..13884e7 --- /dev/null +++ b/examples/structure1 @@ -0,0 +1,5 @@ +#!/bin/sh +# Print structure of XML element using xml sel (advanced XPath expressions and xml sel command usage) +./xmlstarlet sel -T -t -m '//*' \ +-m 'ancestor-or-self::*' -v 'name()' -i 'not(position()=last())' -o . -b -b -n \ +xml/structure.xml diff --git a/examples/sum1 b/examples/sum1 new file mode 100644 index 0000000..03a24d1 --- /dev/null +++ b/examples/sum1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Calculating running sum on XML document +./xmlstarlet sel -T -t -v "sum(/xml/table/rec/numField)" --nl xml/table.xml diff --git a/examples/svg/sample.svg b/examples/svg/sample.svg new file mode 100644 index 0000000..107e134 --- /dev/null +++ b/examples/svg/sample.svg @@ -0,0 +1,14 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg width="5cm" height="4cm" version="1.1" + xmlns="http://www.w3.org/2000/svg"> + <desc>Four separate rectangles</desc> + <rect x="0.5cm" y="0.5cm" width="2cm" height="1cm"/> + <rect x="0.5cm" y="2cm" width="1cm" height="1.5cm"/> + <rect x="3cm" y="0.5cm" width="1.5cm" height="2cm"/> + <rect x="3.5cm" y="3cm" width="1cm" height="0.5cm"/> + <!-- Show outline of canvas using 'rect' element --> + <rect x=".01cm" y=".01cm" width="4.98cm" height="3.98cm" + fill="none" stroke="blue" stroke-width=".02cm" /> +</svg> diff --git a/examples/tab1 b/examples/tab1 new file mode 100644 index 0000000..4c701cb --- /dev/null +++ b/examples/tab1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Indent XML document with tabs +cat xml/tab-obj.xml | ./xmlstarlet fo --indent-tab diff --git a/examples/table1 b/examples/table1 new file mode 100644 index 0000000..cb42053 --- /dev/null +++ b/examples/table1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Generate plain text table from XML document +./xmlstarlet sel -T -t -m /xml/table/rec -v "@id" -o "|" -v numField -o "|" -v stringField -n xml/table.xml diff --git a/examples/table2 b/examples/table2 new file mode 100644 index 0000000..cb20a4b --- /dev/null +++ b/examples/table2 @@ -0,0 +1,3 @@ +#!/bin/sh +# Generate plain text table from XML document +./xmlstarlet sel -T -t -m /xml/table/rec -v "concat(@id,'|',numField,'|',stringField)" -n xml/table.xml diff --git a/examples/table3 b/examples/table3 new file mode 100644 index 0000000..00d5666 --- /dev/null +++ b/examples/table3 @@ -0,0 +1,6 @@ +#!/bin/sh +# Generate plain text table from XML document +./xmlstarlet sel -T \ + -t -o "===================" -n \ + -m xml/table/rec -v "concat(@id,'|',numField,'|',stringField)" -n \ + -t -o "===================" -n xml/table.xml diff --git a/examples/tests.mk b/examples/tests.mk new file mode 100644 index 0000000..807a345 --- /dev/null +++ b/examples/tests.mk @@ -0,0 +1,103 @@ +LOG_COMPILER = abs_builddir=$(abs_builddir) \ +EXEEXT=$(EXEEXT) SED=$(SED) AWK=$(AWK) SHELL=$(SHELL) \ + $(SHELL) $(srcdir)/tests/runTest.sh + +# split tests into fast and slow, so we can run just the fast ones + +SLOW_TESTS =\ +examples/bigxml-dtd\ +examples/bigxml-embed-ref\ +examples/bigxml-embed\ +examples/bigxml-relaxng\ +examples/bigxml-well-formed\ +examples/bigxml-xsd + +QUICK_TESTS =\ +examples/c14n-default-attr\ +examples/c14n-newlines\ +examples/c14n1\ +examples/c14n2\ +examples/command-help\ +examples/count1\ +examples/countnode1\ +examples/delete1\ +examples/dtd1\ +examples/dtd2\ +examples/dtd3\ +examples/dtd4\ +examples/ed-2op\ +examples/ed-append\ +examples/ed-backref-delete\ +examples/ed-backref1\ +examples/ed-backref2\ +examples/ed-expr\ +examples/ed-insert\ +examples/ed-literal\ +examples/ed-move\ +examples/ed-namespace\ +examples/ed-nop\ +examples/ed-subnode\ +examples/elem1\ +examples/elem2\ +examples/elem3\ +examples/elem-depth\ +examples/elem-uniq\ +examples/escape1\ +examples/exslt-ed\ +examples/exslt1\ +examples/external-entity\ +examples/findfile1\ +examples/genxml1\ +examples/hello1\ +examples/localname1\ +examples/look1\ +examples/move1\ +examples/N-order\ +examples/noindent1\ +examples/ns1\ +examples/pyx\ +examples/pyx-ns\ +examples/recover1\ +examples/rename-attr1\ +examples/rename-elem1\ +examples/schema1\ +examples/sel-literal\ +examples/sel-if\ +examples/sel-many-values\ +examples/sel-root\ +examples/sel-xpath-c\ +examples/sel-xpath-i\ +examples/sel-xpath-m\ +examples/sel-xpath-v\ +examples/sel1\ +examples/sort1\ +examples/sort2\ +examples/sort3\ +examples/structure1\ +examples/sum1\ +examples/tab1\ +examples/table1\ +examples/table2\ +examples/table3\ +examples/unicode1\ +examples/update-attr1\ +examples/update-elem1\ +examples/valid1\ +examples/xinclude1\ +examples/xsl-param1\ +examples/xsl-sum1 + +# default to all the tests +TESTS = $(SLOW_TESTS) $(QUICK_TESTS) + +# qcheck is just tests listed in QUICK_TESTS +qcheck : + @$(MAKE) TESTS="$(QUICK_TESTS)" check + +XFAIL_TESTS =\ +examples/bigxml-dtd\ +examples/ed-namespace + +if !HAVE_EXSLT_XPATH_REGISTER +XFAIL_TESTS += examples/exslt-ed +endif diff --git a/examples/tree1 b/examples/tree1 new file mode 100644 index 0000000..e027168 --- /dev/null +++ b/examples/tree1 @@ -0,0 +1,4 @@ +#!/bin/sh +# Print subtree of elements having given element as a descendant (advanced XPath) +./xmlstarlet ed -d '//node()[not(descendant-or-self::isbn or parent::isbn)] | //*[parent::isbn]' xml/books.xml + diff --git a/examples/unicode1 b/examples/unicode1 new file mode 100644 index 0000000..d55fbf7 --- /dev/null +++ b/examples/unicode1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Select from XML document containing unicode characters +./xmlstarlet sel -T -t -m "//test[@lang='français']/@lang" -v . -n xml/unicode.xml diff --git a/examples/update-attr1 b/examples/update-attr1 new file mode 100644 index 0000000..9913961 --- /dev/null +++ b/examples/update-attr1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Update value of an attribute +./xmlstarlet ed -u '/xml/table/rec[@id=3]/@id' -v 5 xml/tab-obj.xml diff --git a/examples/update-elem1 b/examples/update-elem1 new file mode 100644 index 0000000..b9bf2bb --- /dev/null +++ b/examples/update-elem1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Update value of an element +./xmlstarlet ed -u '/xml/table/rec[@id=1]/numField' -v 0 xml/tab-obj.xml diff --git a/examples/valid1 b/examples/valid1 new file mode 100644 index 0000000..7fc17d1 --- /dev/null +++ b/examples/valid1 @@ -0,0 +1,45 @@ +#!/bin/sh +# Validate XML documents using well-formedness/DTD/XSD/RelaxNG checks +echo "===============================================" +echo "Well-Formedness Validation Tests" +echo "- 1 -------------------------------------------" +./xmlstarlet val xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 2 -------------------------------------------" +./xmlstarlet val -g xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 3 -------------------------------------------" +./xmlstarlet val -b xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 4 -------------------------------------------" +./xmlstarlet val -q xml/table.xml xml/tab-obj.xml 2>/dev/null; echo $? + +echo "===============================================" +echo "DTD Validation Tests" +echo "- 1 -------------------------------------------" +./xmlstarlet val -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 2 -------------------------------------------" +./xmlstarlet val -g -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 3 -------------------------------------------" +./xmlstarlet val -b -d dtd/table.dtd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 4 -------------------------------------------" +./xmlstarlet val -q -d dtd/table.dtd xml/table.xml 2>/dev/null; echo $? + +echo "===============================================" +echo "Schema Validation Tests" +echo "- 1 -------------------------------------------" +./xmlstarlet val -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 2 -------------------------------------------" +./xmlstarlet val -g -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 3 -------------------------------------------" +./xmlstarlet val -b -s xsd/table.xsd xml/table.xml xml/tab-obj.xml xml/tab-bad.xml 2>/dev/null; echo $? +echo "- 4 -------------------------------------------" +./xmlstarlet val -q -s xsd/table.xsd xml/table.xml 2>/dev/null; echo $? + +echo "===============================================" +echo "RelaxNG Schema Validation Tests" +echo "- 1 -------------------------------------------" +./xmlstarlet val -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? +echo "- 2 -------------------------------------------" +./xmlstarlet val -g -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? +echo "- 3 -------------------------------------------" +./xmlstarlet val -b -r relaxng/address.rng relaxng/address.xml relaxng/address-bad.xml 2>/dev/null; echo $? +echo "- 4 -------------------------------------------" +./xmlstarlet val -q -r relaxng/address.rng relaxng/address.xml 2>/dev/null; echo $? diff --git a/examples/vxml/root.vxml b/examples/vxml/root.vxml new file mode 100644 index 0000000..23aadd1 --- /dev/null +++ b/examples/vxml/root.vxml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<vxml version="1.0"> + <form id="HelloWorld"> + <block> + <audio src="">Hello World!</audio> + </block> + </form> +</vxml> diff --git a/examples/wsdl/quote.wsdl b/examples/wsdl/quote.wsdl new file mode 100644 index 0000000..c639090 --- /dev/null +++ b/examples/wsdl/quote.wsdl @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<definitions name="StockQuote" + targetNamespace="http://example.com/stockquote.wsdl" + xmlns:tns="http://example.com/stockquote.wsdl" + xmlns:xsd1="http://example.com/stockquote.xsd" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + + <types> + <schema targetNamespace="http://example.com/stockquote.xsd" + xmlns="http://www.w3.org/2000/10/XMLSchema"> + <element name="TradePriceRequest"> + <complexType> + <all> + <element name="tickerSymbol" type="string"/> + </all> + </complexType> + </element> + <element name="TradePrice"> + <complexType> + <all> + <element name="price" type="float"/> + </all> + </complexType> + </element> + </schema> + </types> + + <message name="GetLastTradePriceInput"> + <part name="body" element="xsd1:TradePriceRequest"/> + </message> + + <message name="GetLastTradePriceOutput"> + <part name="body" element="xsd1:TradePrice"/> + </message> + + <portType name="StockQuotePortType"> + <operation name="GetLastTradePrice"> + <input message="tns:GetLastTradePriceInput"/> + <output message="tns:GetLastTradePriceOutput"/> + </operation> + </portType> + + <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="GetLastTradePrice"> + <soap:operation soapAction="http://example.com/GetLastTradePrice"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + </binding> + + <service name="StockQuoteService"> + <documentation>My first service</documentation> + <port name="StockQuotePort" binding="tns:StockQuoteBinding"> + <soap:address location="http://example.com/stockquote"/> + </port> + </service> + +</definitions> + diff --git a/examples/xinclude1 b/examples/xinclude1 new file mode 100644 index 0000000..a8b7036 --- /dev/null +++ b/examples/xinclude1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Include one XML document into another using XInclude +./xmlstarlet tr --xinclude xsl/cat.xsl xml/document.xml | ./xmlstarlet c14n diff --git a/examples/xmi/example.xmi b/examples/xmi/example.xmi new file mode 100644 index 0000000..1f9c9f1 --- /dev/null +++ b/examples/xmi/example.xmi @@ -0,0 +1,8 @@ +<xmi:XMI version="2.0" xmlns:UML=" http://schema.omg.org/spec/UML/1.4" +xmlns:xmi=" http://schema.omg.org/spec/XMI/2.0"> +<xmi:Metamodel name="UML" version="1.4" href="UML.xml"/> +<xmi:Model name="example" version="1" href="example.xml"/> +<UML:Class name="C1"> +<feature xmi:type="UML:Attribute" name="a1" visibility="private"/> +</UML:Class> +</xmi:XMI> diff --git a/examples/xml/S0.xml b/examples/xml/S0.xml new file mode 100644 index 0000000..45d4c54 --- /dev/null +++ b/examples/xml/S0.xml @@ -0,0 +1,4 @@ +<doc xmlns="http://www.foo.com/namespaces/my" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<el/> +</doc> diff --git a/examples/xml/books.xml b/examples/xml/books.xml new file mode 100644 index 0000000..f12955b --- /dev/null +++ b/examples/xml/books.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="ISO-8859-1"?>
+<books>
+<begin/>
+<book type='hardback'>
+<title>Atlas Shrugged</title>
+<author>Ayn Rand</author>
+<isbn id='1'>0525934189<br/></isbn>
+</book>
+Next Book
+<book type='paperback'>
+<title>A Burnt-Out Case</title>
+<author>Graham Greene</author>
+<isbn id="2">0140185399<br/></isbn>
+</book>
+</books>
diff --git a/examples/xml/c14n-default-attr.xml b/examples/xml/c14n-default-attr.xml new file mode 100644 index 0000000..95e2c36 --- /dev/null +++ b/examples/xml/c14n-default-attr.xml @@ -0,0 +1,3 @@ +<!DOCTYPE doc [<!ATTLIST doc attr CDATA "default">]> +<doc/> + diff --git a/examples/xml/c14n.xml b/examples/xml/c14n.xml new file mode 100644 index 0000000..fd8c0a6 --- /dev/null +++ b/examples/xml/c14n.xml @@ -0,0 +1,5 @@ +<n0:pdu xmlns:n0='http://a.example.com'> +<n1:elem1 xmlns:n1='http://b.example'> +content +</n1:elem1> +</n0:pdu> diff --git a/examples/xml/c14n.xpath b/examples/xml/c14n.xpath new file mode 100644 index 0000000..38bff9d --- /dev/null +++ b/examples/xml/c14n.xpath @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<XPath xmlns:n0="http://a.example.com" xmlns:n1="http://b.example"> +(//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] +</XPath> diff --git a/examples/xml/disclaimer.xml b/examples/xml/disclaimer.xml new file mode 100644 index 0000000..3abf43c --- /dev/null +++ b/examples/xml/disclaimer.xml @@ -0,0 +1,6 @@ +<?xml version='1.0'?> +<disclaimer> + <p>The opinions represented herein represent those of the individual + and should not be interpreted as official policy endorsed by this + organization.</p> +</disclaimer> diff --git a/examples/xml/document.xml b/examples/xml/document.xml new file mode 100644 index 0000000..b4f32ec --- /dev/null +++ b/examples/xml/document.xml @@ -0,0 +1,5 @@ +<?xml version='1.0'?> +<document xmlns:xi="http://www.w3.org/2003/XInclude"> + <p>120 Mz is adequate for an average home user.</p> + <xi:include href="disclaimer.xml"/> +</document> diff --git a/examples/xml/entity.xml b/examples/xml/entity.xml new file mode 100644 index 0000000..dae3383 --- /dev/null +++ b/examples/xml/entity.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<foo>bar</foo> diff --git a/examples/xml/external-pe.xml b/examples/xml/external-pe.xml new file mode 100644 index 0000000..aa82005 --- /dev/null +++ b/examples/xml/external-pe.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<!DOCTYPE test [ +<!ELEMENT test (foo)> +<!ELEMENT foo (#PCDATA)> +<!ENTITY entity SYSTEM "entity.xml"> +]> +<!-- Test of external parsed entity. --> +<test>&entity;</test> diff --git a/examples/xml/foo.dtd b/examples/xml/foo.dtd new file mode 100644 index 0000000..36e7dfc --- /dev/null +++ b/examples/xml/foo.dtd @@ -0,0 +1,3 @@ +<!ELEMENT doc ( foo+, bar+ ) > +<!ELEMENT foo ( #PCDATA ) > +<!ELEMENT bar ( #PCDATA ) > diff --git a/examples/xml/foo.xml b/examples/xml/foo.xml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/xml/foo.xml diff --git a/examples/xml/malformed.xml b/examples/xml/malformed.xml new file mode 100644 index 0000000..5e90081 --- /dev/null +++ b/examples/xml/malformed.xml @@ -0,0 +1,4 @@ +<test_output> + <test_name>foo</testname> + <subtest>...</subtest> +</test_output> diff --git a/examples/xml/structure.xml b/examples/xml/structure.xml new file mode 100644 index 0000000..c1ec651 --- /dev/null +++ b/examples/xml/structure.xml @@ -0,0 +1,14 @@ +<a1> + <a11> + <a111> + <a1111/> + </a111> + <a112> + <a1121/> + </a112> + </a11> + <a12/> + <a13> + <a131/> + </a13> +</a1> diff --git a/examples/xml/tab-bad.xml b/examples/xml/tab-bad.xml new file mode 100644 index 0000000..adb05a8 --- /dev/null +++ b/examples/xml/tab-bad.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </tble> +</xml> diff --git a/examples/xml/tab-obj.xml b/examples/xml/tab-obj.xml new file mode 100644 index 0000000..1f0383d --- /dev/null +++ b/examples/xml/tab-obj.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<xml> + <table> + <rec id="1"> + <numField>123</numField> + <stringField>String Value</stringField> + <object name="Obj1"> + <property name="size">10</property> + <property name="type">Data</property> + </object> + </rec> + <rec id="2"> + <numField>346</numField> + <stringField>Text Value</stringField> + </rec> + <rec id="3"> + <numField>-23</numField> + <stringField>stringValue</stringField> + </rec> + </table> +</xml> diff --git a/examples/xml/table.xml b/examples/xml/table.xml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/xml/table.xml diff --git a/examples/xml/unicode.xml b/examples/xml/unicode.xml new file mode 100644 index 0000000..618bfef --- /dev/null +++ b/examples/xml/unicode.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE doc [ + <!ELEMENT doc (test+)> + <!ELEMENT test (#PCDATA)> + <!ENTITY ccedil "ç"> + <!ATTLIST test lang CDATA #IMPLIED> +]> +<doc> + <test lang="français">UTF-8 character.</test> + <test lang="français">numeric ref.</test> + <test lang="français">entity ref.</test> +</doc> diff --git a/examples/xml/unsorted.xml b/examples/xml/unsorted.xml new file mode 100644 index 0000000..6ab629e --- /dev/null +++ b/examples/xml/unsorted.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<root> + <!-- rank 1 is vowel, rank 2 is consonant --> + <elem name="c" rank="2"/> + <elem name="e" rank="1"/> + <elem name="a" rank="1"/> + <elem name="d" rank="2"/> + <elem name="b" rank="2"/> + + <elem name="B" rank="2"/> + <elem name="A" rank="1"/> + <elem name="D" rank="2"/> + <elem name="E" rank="1"/> + <elem name="C" rank="2"/> +</root> diff --git a/examples/xml/xmlstarlet-pad.xml b/examples/xml/xmlstarlet-pad.xml new file mode 100644 index 0000000..9324575 --- /dev/null +++ b/examples/xml/xmlstarlet-pad.xml @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="Windows-1252" ?>
+<XML_DIZ_INFO>
+<MASTER_PAD_VERSION_INFO>
+ <MASTER_PAD_VERSION>1.15</MASTER_PAD_VERSION>
+ <MASTER_PAD_INFO>Portable Application Description, or PAD for short, is a data set that is used by shareware authors to disseminate information to anyone interested in their software products. To find out more go to http://www.asp-shareware.org/pad</MASTER_PAD_INFO>
+</MASTER_PAD_VERSION_INFO>
+<Company_Info>
+ <Company_Name>Mikhail Grushinskiy</Company_Name>
+ <Address_1 />
+ <Address_2 />
+ <City_Town />
+ <State_Province />
+ <Zip_Postal_Code />
+ <Country />
+ <Company_WebSite_URL>http://sourceforge.net/projects/xmlstar/</Company_WebSite_URL>
+<Contact_Info>
+ <Author_First_Name>Mikhail</Author_First_Name>
+ <Author_Last_Name>Grushinskiy</Author_Last_Name>
+ <Author_Email>mgrouch@users.sourceforge.net</Author_Email>
+ <Contact_First_Name />
+ <Contact_Last_Name />
+ <Contact_Email />
+ </Contact_Info>
+<Support_Info>
+ <Sales_Email />
+ <Support_Email />
+ <General_Email>mgrouch@users.sourceforge.net</General_Email>
+ <Sales_Phone />
+ <Support_Phone />
+ <General_Phone />
+ <Fax_Phone />
+ </Support_Info>
+</Company_Info>
+<Program_Info>
+ <Program_Name>xmlstarlet</Program_Name>
+ <Program_Version>0.3.0</Program_Version>
+ <Program_Release_Month>05</Program_Release_Month>
+ <Program_Release_Day>28</Program_Release_Day>
+ <Program_Release_Year>2003</Program_Release_Year>
+ <Program_Cost_Dollars />
+ <Program_Cost_Other_Code />
+ <Program_Cost_Other />
+ <Program_Type>Freeware</Program_Type>
+ <Program_Release_Status>Major Update</Program_Release_Status>
+ <Program_Install_Support>Install and Uninstall</Program_Install_Support>
+ <Program_OS_Support>Unix,Linux</Program_OS_Support>
+ <Program_Language>English</Program_Language>
+<File_Info>
+ <Filename_Versioned>xmlstarlet-0.3.0.tar.gz</Filename_Versioned>
+ <Filename_Previous />
+ <Filename_Generic />
+ <Filename_Long />
+ <File_Size_Bytes>155073</File_Size_Bytes>
+ <File_Size_K>151</File_Size_K>
+ <File_Size_MB>0.15</File_Size_MB>
+ </File_Info>
+<Expire_Info>
+ <Has_Expire_Info>N</Has_Expire_Info>
+ <Expire_Count />
+ <Expire_Based_On>Days</Expire_Based_On>
+ <Expire_Other_Info />
+ <Expire_Month />
+ <Expire_Day />
+ <Expire_Year />
+ </Expire_Info>
+ <Program_Change_Info />
+ <Program_Specific_Category>Utilities</Program_Specific_Category>
+ <Program_Categories>Development Tools</Program_Categories>
+ <Program_System_Requirements>POSIX UNIX</Program_System_Requirements>
+ <Includes_JAVA_VM>N</Includes_JAVA_VM>
+ <Includes_VB_Runtime>N</Includes_VB_Runtime>
+ <Includes_DirectX>N</Includes_DirectX>
+</Program_Info>
+<Program_Descriptions>
+<English>
+ <Keywords>xmlstarlet XML command line processing tool utility toolkit XSLT XSD RelaxNG validate query transform edit modify shell UNIX grep diff sed pyx</Keywords>
+ <Char_Desc_45>XMLStarlet Command Line XML Toolkit</Char_Desc_45>
+ <Char_Desc_80>XMLStarlet Command Line XML Toolkit</Char_Desc_80>
+ <Char_Desc_250>XMLStarlet is a set of command line utilities (tools) to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc</Char_Desc_250>
+ <Char_Desc_450>XMLStarlet is a set of command line utilities (tools) to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.
+
+This set of command line utilities can be used by those who deal with many XML documents on UNIX shell command prompt as well as for automated XML processing with shell scripts.</Char_Desc_450>
+ <Char_Desc_2000>XMLStarlet is a set of command line utilities (tools) to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.
+
+This set of command line utilities can be used by those who deal with many XML documents on UNIX shell command prompt as well as for automated XML processing with shell scripts.
+
+The toolkit's feature set includes options to:
+
+Check or validate XML files (simple well-formedness check, DTD, XSD, RelaxNG)
+
+Calculate values of XPath expressions on XML files (such as running sums, etc)
+
+Search XML files for matches to given XPath expressions
+
+Apply XSLT stylesheets to XML documents (including EXSLT support, and passing parameters to stylesheets)
+
+Query XML documents (ex. query for value of some elements of attributes, sorting, etc)
+
+Modify or edit XML documents (ex. delete some elements)
+
+Format or "beautify" XML documents (as changing indentation, etc)
+
+Fetch XML documents using http:// or ftp:// URLs
+
+Browse tree structure of XML documents (in similar way to 'ls' command for directories)
+
+Include one XML document into another using XInclude
+
+XML c14n canonicalization
+
+Escape/unescape special XML characters in input text
+
+Display directories in XML format
+
+XMLStarlet is open source freeware under MIT license which allows free use and distribution for both commercial and non-commercial projects.
+
+We welcome any user's feedback on this project which would greatly help us to improve its quality. Comments, suggestions, feature requests, bug reports can be done via SourceForge project web site (see XMLStarlet Sourceforge forums at http://sourceforge.net/forum/?group_id=66612, or XMLStarlet mailing list at http://lists.sourceforge.net/lists/listinfo/xmlstar-devel)</Char_Desc_2000>
+</English>
+</Program_Descriptions>
+<Web_Info>
+<Application_URLs>
+ <Application_Info_URL>http://xmlstar.sourceforge.net/</Application_Info_URL>
+ <Application_Order_URL>http://xmlstar.sourceforge.net/download.php</Application_Order_URL>
+ <Application_Screenshot_URL />
+ <Application_Icon_URL>http://xmlstar.sourceforge.net/img/xmlstarlet.png</Application_Icon_URL>
+ <Application_XML_File_URL />
+ </Application_URLs>
+<Download_URLs>
+ <Primary_Download_URL>http://xmlstar.sourceforge.net/download.php</Primary_Download_URL>
+ <Secondary_Download_URL>http://sourceforge.net/project/showfiles.php?group_id=66612</Secondary_Download_URL>
+ <Additional_Download_URL_1 />
+ <Additional_Download_URL_2 />
+ </Download_URLs>
+</Web_Info>
+<Permissions>
+ <Distribution_Permissions>Copyright (c) 2002,2003 Mikhail Grushinskiy. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.</Distribution_Permissions>
+ <EULA />
+</Permissions>
+</XML_DIZ_INFO>
diff --git a/examples/xml/xmlstarlet-xsa.xml b/examples/xml/xmlstarlet-xsa.xml new file mode 100644 index 0000000..698f09a --- /dev/null +++ b/examples/xml/xmlstarlet-xsa.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?>
+<!DOCTYPE xsa PUBLIC "-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML"
+ "http://www.garshol.priv.no/download/xsa/xsa.dtd">
+
+<xsa>
+ <vendor>
+ <name>Mikhail Grushinskiy</name>
+ <email>mgrouch@users.sourceforge.net</email>
+ <url>http://xmlstar.sourceforge.net/</url>
+ </vendor>
+
+ <product id="xmlstarlet">
+ <name>xmlstarlet</name>
+ <version>0.3.0</version>
+ <last-release>20030528</last-release>
+ <info-url>http://xmlstar.sourceforge.net/</info-url>
+ <changes>
+Changes since 0.2.0
+1. Many improvements to 'edit' option
+2. Improvements for namespaces support in 'select' option
+3. Fixes for 'ls' option
+4. New binaries for Solaris8-sparc/RedHat-7.3/Mandrake-9.1/
+5. Documentation and web site updates
+6. Improved build scripts and make files
+7. Additional examples and tests
+ </changes>
+ </product>
+</xsa>
diff --git a/examples/xmlstarlet b/examples/xmlstarlet new file mode 100644 index 0000000..7eb408d --- /dev/null +++ b/examples/xmlstarlet @@ -0,0 +1,14 @@ +#!/bin/sh +exepath=`dirname $0` +xml="${abs_builddir-$exepath/..}"/xml + +if [ x"$OSTYPE" = xmsys ] ; then + exec "$exepath/xmlstarlet.msys" "$xml" "$@" +fi + +if [ x"$VALGRIND" = xyes ] ; then + exec valgrind --error-exitcode=99 --quiet ${VALGRIND_OPTS} "$xml" "$@" +fi + +exec "$xml" "$@" + diff --git a/examples/xmlstarlet.msys b/examples/xmlstarlet.msys new file mode 100644 index 0000000..1d7c7f2 --- /dev/null +++ b/examples/xmlstarlet.msys @@ -0,0 +1,21 @@ +#!/bin/bash
+
+xml="$1"
+shift
+
+# MSYS does unix -> windows path conversion if there is a leading /
+# but not when the argument contains a semicolon, eg: /x ->
+# C:\Mingw\msys\1.0\x so we double all leading /'s to avoid this
+
+nargs=$#
+args=()
+for ((i = 0; i < nargs; i++)) ; do
+ if [[ "$1" = /* ]] && [[ "$1" != *\;* ]] ; then
+ args[$i]="/$1"
+ else
+ args[$i]="$1"
+ fi
+ shift
+done
+
+exec "$xml" "${args[@]}"
diff --git a/examples/xsd/bigxml.xsd b/examples/xsd/bigxml.xsd new file mode 100644 index 0000000..da58f2d --- /dev/null +++ b/examples/xsd/bigxml.xsd @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + + <xs:element name="a" maxOccurs="unbounded"> + <xs:complexType/> + </xs:element> + + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema> diff --git a/examples/xsd/table.xsd b/examples/xsd/table.xsd new file mode 100644 index 0000000..c24332a --- /dev/null +++ b/examples/xsd/table.xsd @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <xsd:element name="xml"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="table"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="rec" maxOccurs="unbounded"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="numField" type="xsd:int"/> + <xsd:element name="stringField" type="xsd:string"/> + </xsd:sequence> + <xsd:attribute name="id" type="xsd:NMTOKEN" use="required"/> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + </xsd:element> +</xsd:schema> diff --git a/examples/xsl-param1 b/examples/xsl-param1 new file mode 100644 index 0000000..88b3085 --- /dev/null +++ b/examples/xsl-param1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Passing parameters to XSLT stylesheet +./xmlstarlet tr xsl/param1.xsl -p Count='count(/xml/table/rec)' -s Text="Count=" xml/table.xml diff --git a/examples/xsl-sum1 b/examples/xsl-sum1 new file mode 100644 index 0000000..8a17113 --- /dev/null +++ b/examples/xsl-sum1 @@ -0,0 +1,3 @@ +#!/bin/sh +# Applying XSLT stylesheet to XML document +./xmlstarlet tr xsl/sum1.xsl xml/table.xml diff --git a/examples/xsl/cat.xsl b/examples/xsl/cat.xsl new file mode 100644 index 0000000..b328ba2 --- /dev/null +++ b/examples/xsl/cat.xsl @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="xml" encoding="utf-8" indent="no"/> + <xsl:template match="node()|@*"> + <xsl:copy-of select="/"/> + </xsl:template> +</xsl:stylesheet> diff --git a/examples/xsl/hello1.xsl b/examples/xsl/hello1.xsl new file mode 100644 index 0000000..cfb3eb0 --- /dev/null +++ b/examples/xsl/hello1.xsl @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="text"/> +<xsl:param name="inputFile">-</xsl:param> +<xsl:template match="/"> + <xsl:call-template name="t1"/> +</xsl:template> +<xsl:template name="t1"> + <xsl:for-each select="/"> + <xsl:value-of select="/html/body/div"/> + </xsl:for-each> +</xsl:template> +</xsl:stylesheet> diff --git a/examples/xsl/param1.xsl b/examples/xsl/param1.xsl new file mode 100644 index 0000000..ab306f6 --- /dev/null +++ b/examples/xsl/param1.xsl @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="text"/> +<xsl:param name="Text"/> +<xsl:param name="Count"/> +<xsl:template match="/"> + <xsl:call-template name="t1"/> +</xsl:template> +<xsl:template name="t1"> + <xsl:for-each select="/xml"> + <xsl:value-of select="$Text"/> + <xsl:value-of select="$Count"/> + <xsl:value-of select="' '"/> + </xsl:for-each> +</xsl:template> +</xsl:stylesheet> diff --git a/examples/xsl/sum1.xsl b/examples/xsl/sum1.xsl new file mode 100644 index 0000000..a595171 --- /dev/null +++ b/examples/xsl/sum1.xsl @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method="text"/> +<xsl:param name="inputFile">-</xsl:param> +<xsl:template match="/"> + <xsl:call-template name="t1"/> +</xsl:template> +<xsl:template name="t1"> + <xsl:value-of select="sum(/xml/table/rec/numField)"/> + <xsl:value-of select="' '"/> +</xsl:template> +</xsl:stylesheet> diff --git a/examples/xsp/dynamic.xsp b/examples/xsp/dynamic.xsp new file mode 100644 index 0000000..333b51d --- /dev/null +++ b/examples/xsp/dynamic.xsp @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<?cocoon-process type="xsp"?> +<?cocoon-process type="xslt"?> +<?xml-stylesheet href="sample.xsl" type="text/xsl"?> + +<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core"> + <page title="Time of Day"> + + <xsp:logic> + // Define a variable to hold the time of day + Date now = new Date(); + </xsp:logic> + + <p> + To the best of my knowledge, it's now + <!-- Substitute time of day here --> + <xsp:expr>now</xsp:expr> + </p> + </page> +</xsp:page> diff --git a/examples/xsql/jobserve.xsql b/examples/xsql/jobserve.xsql new file mode 100644 index 0000000..13dacf8 --- /dev/null +++ b/examples/xsql/jobserve.xsql @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<?xml-stylesheet type="text/xsl" href="jobserve.xsl"?> +<xsql:query connection="jobs" xmlns:xsql="urn:oracle-xsql" max-rows="5"> + SELECT substr(title,1,26) short_title, title, location, skills + FROM job + WHERE UPPER(title) LIKE '%ORACLE%' + ORDER BY first_posted DESC +</xsql:query> diff --git a/examples/xupdate/insxml.xup b/examples/xupdate/insxml.xup new file mode 100644 index 0000000..be0aca5 --- /dev/null +++ b/examples/xupdate/insxml.xup @@ -0,0 +1,17 @@ +<xupdate:modifications version="1.0" + xmlns:xupdate="http://www.xmldb.org/xupdate"> + + <xupdate:append select="/addresses" > + <xupdate:element name="address"> + <xupdate:attribute name="id">2</xupdate:attribute> + <name> + <first>Susan</first> + <last>Long</last> + </name> + <city>Tucson</city> + <state>Arizona</state> + <country>United States</country> + <phone type="home">430-304-3040</phone> + </xupdate:element> + </xupdate:append> +</xupdate:modifications> |