magic_xml 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +22 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/doc/classes/Array.html +148 -0
- data/doc/classes/File.html +113 -0
- data/doc/classes/Hash.html +117 -0
- data/doc/classes/Patterns_all.html +145 -0
- data/doc/classes/Patterns_any.html +145 -0
- data/doc/classes/String.html +470 -0
- data/doc/classes/Symbol.html +145 -0
- data/doc/classes/XML.html +1881 -0
- data/doc/classes/XML_Comment.html +148 -0
- data/doc/classes/XML_PI.html +145 -0
- data/doc/classes/XML_Tests.html +1727 -0
- data/doc/files/magic_xml_rb.html +186 -0
- data/doc/files/simple_examples/xml_hello_f_rb.html +88 -0
- data/doc/files/simple_examples/xml_hello_m_rb.html +88 -0
- data/doc/files/simple_examples/xml_list_f_rb.html +88 -0
- data/doc/files/simple_examples/xml_list_m_rb.html +88 -0
- data/doc/files/tests_rb.html +94 -0
- data/doc/files/xquery_use_cases/parts/q1_rb.html +117 -0
- data/doc/files/xquery_use_cases/rdb/q10_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q11_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q12_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q13_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q14_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q15_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q16_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q17_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q18_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q1_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q2_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q3_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q5_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q6_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q7_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q8_rb.html +88 -0
- data/doc/files/xquery_use_cases/rdb/q9_rb.html +88 -0
- data/doc/files/xquery_use_cases/seq/q1_rb.html +88 -0
- data/doc/files/xquery_use_cases/seq/q2_rb.html +88 -0
- data/doc/files/xquery_use_cases/seq/q3_rb.html +88 -0
- data/doc/files/xquery_use_cases/seq/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/seq/q5_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q10_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q1_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q2_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q3_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q5_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q6_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q7_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q8a_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q8b_rb.html +88 -0
- data/doc/files/xquery_use_cases/sgml/q9_rb.html +88 -0
- data/doc/files/xquery_use_cases/solution_sizes_rb.html +88 -0
- data/doc/files/xquery_use_cases/string/q1_rb.html +88 -0
- data/doc/files/xquery_use_cases/string/q2_rb.html +93 -0
- data/doc/files/xquery_use_cases/string/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/string/q5_rb.html +88 -0
- data/doc/files/xquery_use_cases/test_driver_rb.html +92 -0
- data/doc/files/xquery_use_cases/tree/q1_rb.html +111 -0
- data/doc/files/xquery_use_cases/tree/q2_rb.html +88 -0
- data/doc/files/xquery_use_cases/tree/q3_rb.html +88 -0
- data/doc/files/xquery_use_cases/tree/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/tree/q5_rb.html +88 -0
- data/doc/files/xquery_use_cases/tree/q6_rb.html +113 -0
- data/doc/files/xquery_use_cases/xmp/q10_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q11_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q12_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q1_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q2_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q3_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q4_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q5_rb.html +92 -0
- data/doc/files/xquery_use_cases/xmp/q6_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q7_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q8_rb.html +88 -0
- data/doc/files/xquery_use_cases/xmp/q9_rb.html +88 -0
- data/doc/fr_class_index.html +56 -0
- data/doc/fr_file_index.html +110 -0
- data/doc/fr_method_index.html +159 -0
- data/doc/index.html +26 -0
- data/doc/rdoc-style.css +175 -0
- data/lib/magic_xml.rb +1400 -0
- data/simple_examples/README +14 -0
- data/simple_examples/xml_hello_f.rb +32 -0
- data/simple_examples/xml_hello_m.rb +32 -0
- data/simple_examples/xml_list_f.rb +36 -0
- data/simple_examples/xml_list_m.rb +36 -0
- data/test/helper.rb +9 -0
- data/test/test_magic_xml.rb +855 -0
- data/xquery_use_cases/README +17 -0
- data/xquery_use_cases/parts/README +12 -0
- data/xquery_use_cases/parts/partlist.xml +13 -0
- data/xquery_use_cases/parts/q1.out +16 -0
- data/xquery_use_cases/parts/q1.rb +38 -0
- data/xquery_use_cases/parts/q1.xquery +18 -0
- data/xquery_use_cases/rdb/README +50 -0
- data/xquery_use_cases/rdb/bids.xml +81 -0
- data/xquery_use_cases/rdb/items.xml +57 -0
- data/xquery_use_cases/rdb/q1.out +10 -0
- data/xquery_use_cases/rdb/q1.rb +31 -0
- data/xquery_use_cases/rdb/q1.xquery +14 -0
- data/xquery_use_cases/rdb/q10.out +27 -0
- data/xquery_use_cases/rdb/q10.rb +37 -0
- data/xquery_use_cases/rdb/q10.xquery +15 -0
- data/xquery_use_cases/rdb/q11.out +7 -0
- data/xquery_use_cases/rdb/q11.rb +38 -0
- data/xquery_use_cases/rdb/q11.xquery +15 -0
- data/xquery_use_cases/rdb/q12.out +12 -0
- data/xquery_use_cases/rdb/q12.rb +42 -0
- data/xquery_use_cases/rdb/q12.xquery +28 -0
- data/xquery_use_cases/rdb/q13.out +32 -0
- data/xquery_use_cases/rdb/q13.rb +45 -0
- data/xquery_use_cases/rdb/q13.xquery +15 -0
- data/xquery_use_cases/rdb/q14.out +14 -0
- data/xquery_use_cases/rdb/q14.rb +42 -0
- data/xquery_use_cases/rdb/q14.xquery +14 -0
- data/xquery_use_cases/rdb/q15.out +5 -0
- data/xquery_use_cases/rdb/q15.rb +31 -0
- data/xquery_use_cases/rdb/q15.xquery +9 -0
- data/xquery_use_cases/rdb/q16.out +35 -0
- data/xquery_use_cases/rdb/q16.rb +35 -0
- data/xquery_use_cases/rdb/q16.xquery +17 -0
- data/xquery_use_cases/rdb/q17.out +1 -0
- data/xquery_use_cases/rdb/q17.rb +35 -0
- data/xquery_use_cases/rdb/q17.xquery +11 -0
- data/xquery_use_cases/rdb/q18.out +32 -0
- data/xquery_use_cases/rdb/q18.rb +40 -0
- data/xquery_use_cases/rdb/q18.xquery +19 -0
- data/xquery_use_cases/rdb/q2.out +22 -0
- data/xquery_use_cases/rdb/q2.rb +36 -0
- data/xquery_use_cases/rdb/q2.xquery +14 -0
- data/xquery_use_cases/rdb/q3.out +8 -0
- data/xquery_use_cases/rdb/q3.rb +34 -0
- data/xquery_use_cases/rdb/q3.xquery +16 -0
- data/xquery_use_cases/rdb/q4.out +14 -0
- data/xquery_use_cases/rdb/q4.rb +31 -0
- data/xquery_use_cases/rdb/q4.xquery +11 -0
- data/xquery_use_cases/rdb/q5.out +12 -0
- data/xquery_use_cases/rdb/q5.rb +46 -0
- data/xquery_use_cases/rdb/q5.xquery +25 -0
- data/xquery_use_cases/rdb/q6.out +14 -0
- data/xquery_use_cases/rdb/q6.rb +38 -0
- data/xquery_use_cases/rdb/q6.xquery +15 -0
- data/xquery_use_cases/rdb/q7.out +1 -0
- data/xquery_use_cases/rdb/q7.rb +30 -0
- data/xquery_use_cases/rdb/q7.xquery +10 -0
- data/xquery_use_cases/rdb/q8.out +1 -0
- data/xquery_use_cases/rdb/q8.rb +23 -0
- data/xquery_use_cases/rdb/q8.xquery +8 -0
- data/xquery_use_cases/rdb/q9.out +22 -0
- data/xquery_use_cases/rdb/q9.rb +32 -0
- data/xquery_use_cases/rdb/q9.xquery +16 -0
- data/xquery_use_cases/rdb/users.xml +25 -0
- data/xquery_use_cases/seq/README +12 -0
- data/xquery_use_cases/seq/q1.out +1 -0
- data/xquery_use_cases/seq/q1.rb +25 -0
- data/xquery_use_cases/seq/q1.xquery +2 -0
- data/xquery_use_cases/seq/q2.out +2 -0
- data/xquery_use_cases/seq/q2.rb +25 -0
- data/xquery_use_cases/seq/q2.xquery +2 -0
- data/xquery_use_cases/seq/q3.out +2 -0
- data/xquery_use_cases/seq/q3.rb +26 -0
- data/xquery_use_cases/seq/q3.xquery +3 -0
- data/xquery_use_cases/seq/q4.out +0 -0
- data/xquery_use_cases/seq/q4.rb +27 -0
- data/xquery_use_cases/seq/q4.xquery +4 -0
- data/xquery_use_cases/seq/q5.out +5 -0
- data/xquery_use_cases/seq/q5.rb +29 -0
- data/xquery_use_cases/seq/q5.xquery +10 -0
- data/xquery_use_cases/seq/report1.xml +40 -0
- data/xquery_use_cases/sgml/README +53 -0
- data/xquery_use_cases/sgml/q1.out +44 -0
- data/xquery_use_cases/sgml/q1.rb +23 -0
- data/xquery_use_cases/sgml/q1.xquery +5 -0
- data/xquery_use_cases/sgml/q10.out +1 -0
- data/xquery_use_cases/sgml/q10.rb +28 -0
- data/xquery_use_cases/sgml/q10.xquery +7 -0
- data/xquery_use_cases/sgml/q2.out +26 -0
- data/xquery_use_cases/sgml/q2.rb +23 -0
- data/xquery_use_cases/sgml/q2.xquery +5 -0
- data/xquery_use_cases/sgml/q3.out +6 -0
- data/xquery_use_cases/sgml/q3.rb +28 -0
- data/xquery_use_cases/sgml/q3.xquery +7 -0
- data/xquery_use_cases/sgml/q4.out +4 -0
- data/xquery_use_cases/sgml/q4.rb +25 -0
- data/xquery_use_cases/sgml/q4.xquery +5 -0
- data/xquery_use_cases/sgml/q5.out +3 -0
- data/xquery_use_cases/sgml/q5.rb +23 -0
- data/xquery_use_cases/sgml/q5.xquery +5 -0
- data/xquery_use_cases/sgml/q6.out +1 -0
- data/xquery_use_cases/sgml/q6.rb +27 -0
- data/xquery_use_cases/sgml/q6.xquery +6 -0
- data/xquery_use_cases/sgml/q7.out +1 -0
- data/xquery_use_cases/sgml/q7.rb +27 -0
- data/xquery_use_cases/sgml/q7.xquery +7 -0
- data/xquery_use_cases/sgml/q8a.out +34 -0
- data/xquery_use_cases/sgml/q8a.rb +27 -0
- data/xquery_use_cases/sgml/q8a.xquery +5 -0
- data/xquery_use_cases/sgml/q8b.out +26 -0
- data/xquery_use_cases/sgml/q8b.rb +32 -0
- data/xquery_use_cases/sgml/q8b.xquery +5 -0
- data/xquery_use_cases/sgml/q9.out +9 -0
- data/xquery_use_cases/sgml/q9.rb +29 -0
- data/xquery_use_cases/sgml/q9.xquery +6 -0
- data/xquery_use_cases/sgml/sgml.xml +101 -0
- data/xquery_use_cases/solution_sizes.rb +48 -0
- data/xquery_use_cases/string/README +29 -0
- data/xquery_use_cases/string/company-data.xml +20 -0
- data/xquery_use_cases/string/q1.out +4 -0
- data/xquery_use_cases/string/q1.rb +25 -0
- data/xquery_use_cases/string/q1.xquery +1 -0
- data/xquery_use_cases/string/q2.out +13 -0
- data/xquery_use_cases/string/q2.rb +32 -0
- data/xquery_use_cases/string/q2.xquery +23 -0
- data/xquery_use_cases/string/q4.out +50 -0
- data/xquery_use_cases/string/q4.rb +34 -0
- data/xquery_use_cases/string/q4.xquery +14 -0
- data/xquery_use_cases/string/q5.out +12 -0
- data/xquery_use_cases/string/q5.rb +33 -0
- data/xquery_use_cases/string/q5.xquery +8 -0
- data/xquery_use_cases/string/string.xml +82 -0
- data/xquery_use_cases/test_driver.rb +60 -0
- data/xquery_use_cases/tree/README +23 -0
- data/xquery_use_cases/tree/book.xml +50 -0
- data/xquery_use_cases/tree/q1.out +23 -0
- data/xquery_use_cases/tree/q1.rb +31 -0
- data/xquery_use_cases/tree/q1.xquery +14 -0
- data/xquery_use_cases/tree/q2.out +11 -0
- data/xquery_use_cases/tree/q2.rb +27 -0
- data/xquery_use_cases/tree/q2.xquery +10 -0
- data/xquery_use_cases/tree/q3.out +2 -0
- data/xquery_use_cases/tree/q3.rb +26 -0
- data/xquery_use_cases/tree/q3.xquery +2 -0
- data/xquery_use_cases/tree/q4.out +1 -0
- data/xquery_use_cases/tree/q4.rb +23 -0
- data/xquery_use_cases/tree/q4.xquery +5 -0
- data/xquery_use_cases/tree/q5.out +9 -0
- data/xquery_use_cases/tree/q5.rb +30 -0
- data/xquery_use_cases/tree/q5.xquery +8 -0
- data/xquery_use_cases/tree/q6.out +30 -0
- data/xquery_use_cases/tree/q6.rb +35 -0
- data/xquery_use_cases/tree/q6.xquery +21 -0
- data/xquery_use_cases/xmp/README +41 -0
- data/xquery_use_cases/xmp/bib.xml +35 -0
- data/xquery_use_cases/xmp/books.xml +15 -0
- data/xquery_use_cases/xmp/prices.xml +32 -0
- data/xquery_use_cases/xmp/q1.out +8 -0
- data/xquery_use_cases/xmp/q1.rb +29 -0
- data/xquery_use_cases/xmp/q1.xquery +10 -0
- data/xquery_use_cases/xmp/q10.out +11 -0
- data/xquery_use_cases/xmp/q10.rb +36 -0
- data/xquery_use_cases/xmp/q10.xquery +11 -0
- data/xquery_use_cases/xmp/q11.out +35 -0
- data/xquery_use_cases/xmp/q11.rb +37 -0
- data/xquery_use_cases/xmp/q11.xquery +18 -0
- data/xquery_use_cases/xmp/q12.out +6 -0
- data/xquery_use_cases/xmp/q12.rb +35 -0
- data/xquery_use_cases/xmp/q12.xquery +20 -0
- data/xquery_use_cases/xmp/q2.out +37 -0
- data/xquery_use_cases/xmp/q2.rb +30 -0
- data/xquery_use_cases/xmp/q2.xquery +12 -0
- data/xquery_use_cases/xmp/q3.out +34 -0
- data/xquery_use_cases/xmp/q3.rb +27 -0
- data/xquery_use_cases/xmp/q3.xquery +10 -0
- data/xquery_use_cases/xmp/q4.out +31 -0
- data/xquery_use_cases/xmp/q4.rb +44 -0
- data/xquery_use_cases/xmp/q4.xquery +21 -0
- data/xquery_use_cases/xmp/q5.out +17 -0
- data/xquery_use_cases/xmp/q5.rb +38 -0
- data/xquery_use_cases/xmp/q5.xquery +13 -0
- data/xquery_use_cases/xmp/q6.out +28 -0
- data/xquery_use_cases/xmp/q6.rb +33 -0
- data/xquery_use_cases/xmp/q6.xquery +19 -0
- data/xquery_use_cases/xmp/q7.out +8 -0
- data/xquery_use_cases/xmp/q7.rb +30 -0
- data/xquery_use_cases/xmp/q7.xquery +12 -0
- data/xquery_use_cases/xmp/q8.out +7 -0
- data/xquery_use_cases/xmp/q8.rb +29 -0
- data/xquery_use_cases/xmp/q8.xquery +9 -0
- data/xquery_use_cases/xmp/q9.out +4 -0
- data/xquery_use_cases/xmp/q9.rb +29 -0
- data/xquery_use_cases/xmp/q9.xquery +7 -0
- data/xquery_use_cases/xmp/reviews.xml +24 -0
- metadata +342 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!DOCTYPE book SYSTEM "book.dtd">
|
|
3
|
+
<book>
|
|
4
|
+
<title>Data on the Web</title>
|
|
5
|
+
<author>Serge Abiteboul</author>
|
|
6
|
+
<author>Peter Buneman</author>
|
|
7
|
+
<author>Dan Suciu</author>
|
|
8
|
+
<section id="intro" difficulty="easy" >
|
|
9
|
+
<title>Introduction</title>
|
|
10
|
+
<p>Text ... </p>
|
|
11
|
+
<section>
|
|
12
|
+
<title>Audience</title>
|
|
13
|
+
<p>Text ... </p>
|
|
14
|
+
</section>
|
|
15
|
+
<section>
|
|
16
|
+
<title>Web Data and the Two Cultures</title>
|
|
17
|
+
<p>Text ... </p>
|
|
18
|
+
<figure height="400" width="400">
|
|
19
|
+
<title>Traditional client/server architecture</title>
|
|
20
|
+
<image source="csarch.gif"/>
|
|
21
|
+
</figure>
|
|
22
|
+
<p>Text ... </p>
|
|
23
|
+
</section>
|
|
24
|
+
</section>
|
|
25
|
+
<section id="syntax" difficulty="medium" >
|
|
26
|
+
<title>A Syntax For Data</title>
|
|
27
|
+
<p>Text ... </p>
|
|
28
|
+
<figure height="200" width="500">
|
|
29
|
+
<title>Graph representations of structures</title>
|
|
30
|
+
<image source="graphs.gif"/>
|
|
31
|
+
</figure>
|
|
32
|
+
<p>Text ... </p>
|
|
33
|
+
<section>
|
|
34
|
+
<title>Base Types</title>
|
|
35
|
+
<p>Text ... </p>
|
|
36
|
+
</section>
|
|
37
|
+
<section>
|
|
38
|
+
<title>Representing Relational Databases</title>
|
|
39
|
+
<p>Text ... </p>
|
|
40
|
+
<figure height="250" width="400">
|
|
41
|
+
<title>Examples of Relations</title>
|
|
42
|
+
<image source="relations.gif"/>
|
|
43
|
+
</figure>
|
|
44
|
+
</section>
|
|
45
|
+
<section>
|
|
46
|
+
<title>Representing Object Databases</title>
|
|
47
|
+
<p>Text ... </p>
|
|
48
|
+
</section>
|
|
49
|
+
</section>
|
|
50
|
+
</book>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<toc>
|
|
2
|
+
<section id="intro" difficulty="easy">
|
|
3
|
+
<title>Introduction</title>
|
|
4
|
+
<section>
|
|
5
|
+
<title>Audience</title>
|
|
6
|
+
</section>
|
|
7
|
+
<section>
|
|
8
|
+
<title>Web Data and the Two Cultures</title>
|
|
9
|
+
</section>
|
|
10
|
+
</section>
|
|
11
|
+
<section id="syntax" difficulty="medium">
|
|
12
|
+
<title>A Syntax For Data</title>
|
|
13
|
+
<section>
|
|
14
|
+
<title>Base Types</title>
|
|
15
|
+
</section>
|
|
16
|
+
<section>
|
|
17
|
+
<title>Representing Relational Databases</title>
|
|
18
|
+
</section>
|
|
19
|
+
<section>
|
|
20
|
+
<title>Representing Object Databases</title>
|
|
21
|
+
</section>
|
|
22
|
+
</section>
|
|
23
|
+
</toc>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def local_toc(node)
|
|
24
|
+
node.children(:section).map{|c|
|
|
25
|
+
XML.section(c.attrs, c.child(:title), local_toc(c))
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
XML.toc! {
|
|
30
|
+
add! local_toc(XML.load('book.xml'))
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare function local:toc($book-or-section as element()) as element()*
|
|
2
|
+
{
|
|
3
|
+
for $section in $book-or-section/section
|
|
4
|
+
return
|
|
5
|
+
<section>
|
|
6
|
+
{ $section/@* , $section/title , local:toc($section) }
|
|
7
|
+
</section>
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
<toc>
|
|
11
|
+
{
|
|
12
|
+
for $s in doc("book.xml")/book return local:toc($s)
|
|
13
|
+
}
|
|
14
|
+
</toc>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<figlist>
|
|
2
|
+
<figure height="400" width="400">
|
|
3
|
+
<title>Traditional client/server architecture</title>
|
|
4
|
+
</figure>
|
|
5
|
+
<figure height="200" width="500">
|
|
6
|
+
<title>Graph representations of structures</title>
|
|
7
|
+
</figure>
|
|
8
|
+
<figure height="250" width ="400">
|
|
9
|
+
<title>Examples of Relations</title>
|
|
10
|
+
</figure>
|
|
11
|
+
</figlist>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
XML.figlist! {
|
|
24
|
+
XML.load('book.xml').descendants(:figure) {|f|
|
|
25
|
+
figure!(f.attrs, f.children(:title))
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
doc = XML.load('book.xml')
|
|
24
|
+
|
|
25
|
+
XML.section_count!(doc.descendants(:section).size)
|
|
26
|
+
XML.figure_count!(doc.descendants(:figure).size)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<top_section_count>2</top_section_count>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
XML.top_section_count!(XML.load('book.xml').children(:section).size)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<section_list>
|
|
2
|
+
<section title="Introduction" figcount="0"/>
|
|
3
|
+
<section title="Audience" figcount="0"/>
|
|
4
|
+
<section title="Web Data and the Two Cultures" figcount="1"/>
|
|
5
|
+
<section title="A Syntax For Data" figcount="1"/>
|
|
6
|
+
<section title="Base Types" figcount="0"/>
|
|
7
|
+
<section title="Representing Relational Databases" figcount="1"/>
|
|
8
|
+
<section title="Representing Object Databases" figcount="0"/>
|
|
9
|
+
</section_list>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
XML.section_list! {
|
|
24
|
+
XML.load('book.xml').descendants(:section) {|s|
|
|
25
|
+
section!({
|
|
26
|
+
:title => s[:@title],
|
|
27
|
+
:figcount => s.children(:figure).size,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<toc>
|
|
2
|
+
<section id="intro" difficulty="easy">
|
|
3
|
+
<title>Introduction</title>
|
|
4
|
+
<figcount>0</figcount>
|
|
5
|
+
<section>
|
|
6
|
+
<title>Audience</title>
|
|
7
|
+
<figcount>0</figcount>
|
|
8
|
+
</section>
|
|
9
|
+
<section>
|
|
10
|
+
<title>Web Data and the Two Cultures</title>
|
|
11
|
+
<figcount>1</figcount>
|
|
12
|
+
</section>
|
|
13
|
+
</section>
|
|
14
|
+
<section id="syntax" difficulty="medium">
|
|
15
|
+
<title>A Syntax For Data</title>
|
|
16
|
+
<figcount>1</figcount>
|
|
17
|
+
<section>
|
|
18
|
+
<title>Base Types</title>
|
|
19
|
+
<figcount>0</figcount>
|
|
20
|
+
</section>
|
|
21
|
+
<section>
|
|
22
|
+
<title>Representing Relational Databases</title>
|
|
23
|
+
<figcount>1</figcount>
|
|
24
|
+
</section>
|
|
25
|
+
<section>
|
|
26
|
+
<title>Representing Object Databases</title>
|
|
27
|
+
<figcount>0</figcount>
|
|
28
|
+
</section>
|
|
29
|
+
</section>
|
|
30
|
+
</toc>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def section_summary(s)
|
|
24
|
+
XML.section(s.attrs) {
|
|
25
|
+
add! s.child(:title)
|
|
26
|
+
figcount! s.children(:figure).size
|
|
27
|
+
add! s.children(:section).map{|c| section_summary(c)}
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
XML.toc! {
|
|
32
|
+
XML.load('book.xml').children(:section) {|s|
|
|
33
|
+
add! section_summary(s)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare function local:section-summary($book-or-section as element()*)
|
|
2
|
+
as element()*
|
|
3
|
+
{
|
|
4
|
+
for $section in $book-or-section
|
|
5
|
+
return
|
|
6
|
+
<section>
|
|
7
|
+
{ $section/@* }
|
|
8
|
+
{ $section/title }
|
|
9
|
+
<figcount>
|
|
10
|
+
{ count($section/figure) }
|
|
11
|
+
</figcount>
|
|
12
|
+
{ local:section-summary($section/section) }
|
|
13
|
+
</section>
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
<toc>
|
|
17
|
+
{
|
|
18
|
+
for $s in doc("book.xml")/book/section
|
|
19
|
+
return local:section-summary($s)
|
|
20
|
+
}
|
|
21
|
+
</toc>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Use Case "XMP": Experiences and Exemplars
|
|
2
|
+
from XML Query Use Cases.
|
|
3
|
+
|
|
4
|
+
Source: http://www.w3.org/TR/xquery-use-cases/#xmp
|
|
5
|
+
|
|
6
|
+
Q1 - List books published by Addison-Wesley after 1991,
|
|
7
|
+
including their year and title.
|
|
8
|
+
Q2 - Create a flat list of all the title-author pairs,
|
|
9
|
+
with each pair enclosed in a "result" element.
|
|
10
|
+
Q3 - For each book in the bibliography, list the title and
|
|
11
|
+
authors, grouped inside a "result" element.
|
|
12
|
+
Q4 - For each author in the bibliography, list the author's
|
|
13
|
+
name and the titles of all books by that author,
|
|
14
|
+
grouped inside a "result" element.
|
|
15
|
+
Q5 - For each book found at both bstore1.example.com and
|
|
16
|
+
bstore2.example.com, list the title of the book and
|
|
17
|
+
its price from each source.
|
|
18
|
+
Q6 - For each book that has at least one author, list the
|
|
19
|
+
title and first two authors, and an empty "et-al"
|
|
20
|
+
element if the book has additional authors.
|
|
21
|
+
Q7 - List the titles and years of all books published
|
|
22
|
+
by Addison-Wesley after 1991, in alphabetic order.
|
|
23
|
+
Q8 - Find books in which the name of some element ends
|
|
24
|
+
with the string "or" and the same element contains
|
|
25
|
+
the string "Suciu" somewhere in its content.
|
|
26
|
+
For each such book, return the title and the qualifying element.
|
|
27
|
+
Q9 - In the document "books.xml", find all section or chapter
|
|
28
|
+
titles that contain the word "XML", regardless of the
|
|
29
|
+
level of nesting.
|
|
30
|
+
Q10 - In the document "prices.xml", find the minimum price
|
|
31
|
+
for each book, in the form of a "minprice" element
|
|
32
|
+
with the book title as its title attribute.
|
|
33
|
+
Q11 - For each book with an author, return the book with
|
|
34
|
+
its title and authors. For each book with an editor,
|
|
35
|
+
return a reference with the book title and the editor's affiliation.
|
|
36
|
+
Q12 - Find pairs of books that have different titles but
|
|
37
|
+
the same set of authors (possibly in a different order).
|
|
38
|
+
|
|
39
|
+
magic/xml solutions more or less follow XQuery solutions,
|
|
40
|
+
with significant changes only where naive translation
|
|
41
|
+
would result in very cumbersome code.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<bib>
|
|
2
|
+
<book year="1994">
|
|
3
|
+
<title>TCP/IP Illustrated</title>
|
|
4
|
+
<author><last>Stevens</last><first>W.</first></author>
|
|
5
|
+
<publisher>Addison-Wesley</publisher>
|
|
6
|
+
<price>65.95</price>
|
|
7
|
+
</book>
|
|
8
|
+
|
|
9
|
+
<book year="1992">
|
|
10
|
+
<title>Advanced Programming in the Unix environment</title>
|
|
11
|
+
<author><last>Stevens</last><first>W.</first></author>
|
|
12
|
+
<publisher>Addison-Wesley</publisher>
|
|
13
|
+
<price>65.95</price>
|
|
14
|
+
</book>
|
|
15
|
+
|
|
16
|
+
<book year="2000">
|
|
17
|
+
<title>Data on the Web</title>
|
|
18
|
+
<author><last>Abiteboul</last><first>Serge</first></author>
|
|
19
|
+
<author><last>Buneman</last><first>Peter</first></author>
|
|
20
|
+
<author><last>Suciu</last><first>Dan</first></author>
|
|
21
|
+
<publisher>Morgan Kaufmann Publishers</publisher>
|
|
22
|
+
<price>39.95</price>
|
|
23
|
+
</book>
|
|
24
|
+
|
|
25
|
+
<book year="1999">
|
|
26
|
+
<title>The Economics of Technology and Content for Digital TV</title>
|
|
27
|
+
<editor>
|
|
28
|
+
<last>Gerbarg</last><first>Darcy</first>
|
|
29
|
+
<affiliation>CITI</affiliation>
|
|
30
|
+
</editor>
|
|
31
|
+
<publisher>Kluwer Academic Publishers</publisher>
|
|
32
|
+
<price>129.95</price>
|
|
33
|
+
</book>
|
|
34
|
+
|
|
35
|
+
</bib>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<chapter>
|
|
2
|
+
<title>Data Model</title>
|
|
3
|
+
<section>
|
|
4
|
+
<title>Syntax For Data Model</title>
|
|
5
|
+
</section>
|
|
6
|
+
<section>
|
|
7
|
+
<title>XML</title>
|
|
8
|
+
<section>
|
|
9
|
+
<title>Basic Syntax</title>
|
|
10
|
+
</section>
|
|
11
|
+
<section>
|
|
12
|
+
<title>XML and Semistructured Data</title>
|
|
13
|
+
</section>
|
|
14
|
+
</section>
|
|
15
|
+
</chapter>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<prices>
|
|
2
|
+
<book>
|
|
3
|
+
<title>Advanced Programming in the Unix environment</title>
|
|
4
|
+
<source>bstore2.example.com</source>
|
|
5
|
+
<price>65.95</price>
|
|
6
|
+
</book>
|
|
7
|
+
<book>
|
|
8
|
+
<title>Advanced Programming in the Unix environment</title>
|
|
9
|
+
<source>bstore1.example.com</source>
|
|
10
|
+
<price>65.95</price>
|
|
11
|
+
</book>
|
|
12
|
+
<book>
|
|
13
|
+
<title>TCP/IP Illustrated</title>
|
|
14
|
+
<source>bstore2.example.com</source>
|
|
15
|
+
<price>65.95</price>
|
|
16
|
+
</book>
|
|
17
|
+
<book>
|
|
18
|
+
<title>TCP/IP Illustrated</title>
|
|
19
|
+
<source>bstore1.example.com</source>
|
|
20
|
+
<price>65.95</price>
|
|
21
|
+
</book>
|
|
22
|
+
<book>
|
|
23
|
+
<title>Data on the Web</title>
|
|
24
|
+
<source>bstore2.example.com</source>
|
|
25
|
+
<price>34.95</price>
|
|
26
|
+
</book>
|
|
27
|
+
<book>
|
|
28
|
+
<title>Data on the Web</title>
|
|
29
|
+
<source>bstore1.example.com</source>
|
|
30
|
+
<price>39.95</price>
|
|
31
|
+
</book>
|
|
32
|
+
</prices>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
XML.bib! {
|
|
24
|
+
XML.load('bib.xml').children(:book) {|b|
|
|
25
|
+
if b[:@publisher] == "Addison-Wesley" and b[:year].to_i > 1991
|
|
26
|
+
book!({:year => b[:year]}, b.child(:title))
|
|
27
|
+
end
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<results>
|
|
2
|
+
<minprice title="Advanced Programming in the Unix environment">
|
|
3
|
+
<price>65.95</price>
|
|
4
|
+
</minprice>
|
|
5
|
+
<minprice title="TCP/IP Illustrated">
|
|
6
|
+
<price>65.95</price>
|
|
7
|
+
</minprice>
|
|
8
|
+
<minprice title="Data on the Web">
|
|
9
|
+
<price>34.95</price>
|
|
10
|
+
</minprice>
|
|
11
|
+
</results>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/ruby -I../.. -rmagic_xml
|
|
2
|
+
#Copyright (c) 2006-2007 Tomasz Wegrzanowski <Tomasz.Wegrzanowski@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
#Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
+
#copy of this software and associated documentation files (the "Software"),
|
|
6
|
+
#to deal in the Software without restriction, including without limitation
|
|
7
|
+
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
#and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
+
#Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
#The above copyright notice and this permission notice shall be included in
|
|
12
|
+
#all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
18
|
+
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
#DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
XML.results! {
|
|
24
|
+
doc = XML.load('prices.xml')
|
|
25
|
+
doc.children(:book).children(:title).map{|node| node.text}.uniq.each{|title|
|
|
26
|
+
minprice!({:title => title}) {
|
|
27
|
+
price! {
|
|
28
|
+
text! doc.children(:book).find_all{|book|
|
|
29
|
+
book[:@title] == title
|
|
30
|
+
}.map{|book|
|
|
31
|
+
book[:@price].to_f
|
|
32
|
+
}.min
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|