magic_xml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,45 @@
|
|
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
|
+
users = XML.load('users.xml')
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
XML.result! {
|
27
|
+
bids.descendants(:userid).map{|uid| uid.text}.uniq.sort.each{|uid|
|
28
|
+
users.each({:@userid => uid}){|u|
|
29
|
+
user_bids = bids.find_all{|b| b.is_a? XML and b[:@userid] == uid}
|
30
|
+
bidder! {
|
31
|
+
add! u.child(:userid)
|
32
|
+
add! u.child(:name)
|
33
|
+
bidcount! user_bids.size
|
34
|
+
sum = 0.0
|
35
|
+
user_bids.each{|b|
|
36
|
+
sum += b[:@bid].to_i
|
37
|
+
}
|
38
|
+
a = sum / user_bids.size
|
39
|
+
# This is ugly hack to get 1.0 print as "1" not as "1.0"
|
40
|
+
a = a.to_i if a.to_i == a
|
41
|
+
avgbid! a
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $uid in distinct-values(doc("bids.xml")//userid),
|
4
|
+
$u in doc("users.xml")//user_tuple[userid = $uid]
|
5
|
+
let $b := doc("bids.xml")//bid_tuple[userid = $uid]
|
6
|
+
order by $u/userid
|
7
|
+
return
|
8
|
+
<bidder>
|
9
|
+
{ $u/userid }
|
10
|
+
{ $u/name }
|
11
|
+
<bidcount>{ count($b) }</bidcount>
|
12
|
+
<avgbid>{ avg($b/bid) }</avgbid>
|
13
|
+
</bidder>
|
14
|
+
}
|
15
|
+
</result>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<result>
|
2
|
+
<popular_item>
|
3
|
+
<itemno>1002</itemno>
|
4
|
+
<avgbid>800</avgbid>
|
5
|
+
</popular_item>
|
6
|
+
<popular_item>
|
7
|
+
<itemno>1007</itemno>
|
8
|
+
<avgbid>200</avgbid>
|
9
|
+
</popular_item>
|
10
|
+
<popular_item>
|
11
|
+
<itemno>1001</itemno>
|
12
|
+
<avgbid>45</avgbid>
|
13
|
+
</popular_item>
|
14
|
+
</result>
|
@@ -0,0 +1,42 @@
|
|
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
|
+
bids = XML.load('bids.xml').children(:bid_tuple)
|
24
|
+
|
25
|
+
XML.result! {
|
26
|
+
bids_of_item = Hash.new([])
|
27
|
+
sum_bids_of_item = Hash.new(0.0)
|
28
|
+
bids.each{|b|
|
29
|
+
i = b[:@itemno]
|
30
|
+
bids_of_item[i] += [b]
|
31
|
+
sum_bids_of_item[i] += b[:@bid].to_i
|
32
|
+
}
|
33
|
+
bids_of_item.find_all{|i,b| b.size >= 3}.map{|i,b| [sum_bids_of_item[i] / b.size, i, b]}.sort.reverse.each{|a,i,b|
|
34
|
+
popular_item! {
|
35
|
+
itemno! i
|
36
|
+
# This is ugly hack to get 1.0 print as "1" not as "1.0"
|
37
|
+
a = a.to_i if a.to_i == a
|
38
|
+
avgbid! a
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $i in distinct-values(doc("bids.xml")//itemno)
|
4
|
+
let $b := doc("bids.xml")//bid_tuple[itemno = $i]
|
5
|
+
let $avgbid := avg($b/bid)
|
6
|
+
where count($b) >= 3
|
7
|
+
order by $avgbid descending
|
8
|
+
return
|
9
|
+
<popular_item>
|
10
|
+
<itemno>{ $i }</itemno>
|
11
|
+
<avgbid>{ $avgbid }</avgbid>
|
12
|
+
</popular_item>
|
13
|
+
}
|
14
|
+
</result>
|
@@ -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
|
+
users = XML.load('users.xml')
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
XML.result! {
|
27
|
+
users.each(XML){|u|
|
28
|
+
next unless bids.find_all{|b| b.is_a? XML and b[:@userid] == u[:@userid] and b[:@bid].to_i >= 100 }.size > 1
|
29
|
+
big_spender! u[:@name]
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<result>
|
4
|
+
<user>
|
5
|
+
<userid>U01</userid>
|
6
|
+
<name>Tom Jones</name>
|
7
|
+
<status>active</status>
|
8
|
+
</user>
|
9
|
+
<user>
|
10
|
+
<userid>U02</userid>
|
11
|
+
<name>Mary Doe</name>
|
12
|
+
<status>active</status>
|
13
|
+
</user>
|
14
|
+
<user>
|
15
|
+
<userid>U03</userid>
|
16
|
+
<name>Dee Linquent</name>
|
17
|
+
<status>active</status>
|
18
|
+
</user>
|
19
|
+
<user>
|
20
|
+
<userid>U04</userid>
|
21
|
+
<name>Roger Smith</name>
|
22
|
+
<status>active</status>
|
23
|
+
</user>
|
24
|
+
<user>
|
25
|
+
<userid>U05</userid>
|
26
|
+
<name>Jack Sprat</name>
|
27
|
+
<status>active</status>
|
28
|
+
</user>
|
29
|
+
<user>
|
30
|
+
<userid>U06</userid>
|
31
|
+
<name>Rip Van Winkle</name>
|
32
|
+
<status>inactive</status>
|
33
|
+
</user>
|
34
|
+
</result>
|
35
|
+
|
@@ -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
|
+
users = XML.load('users.xml').sort_by{|i| i[:@userid].to_i}
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
XML.result! {
|
27
|
+
users.each(XML){|u|
|
28
|
+
user_bids = bids.children({:@userid => u[:@userid]})
|
29
|
+
user! {
|
30
|
+
add! u.child(:userid)
|
31
|
+
add! u.child(:name)
|
32
|
+
status! (user_bids.empty? ? 'inactive' : 'active')
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $u in doc("users.xml")//user_tuple
|
4
|
+
let $b := doc("bids.xml")//bid_tuple[userid = $u/userid]
|
5
|
+
order by $u/userid
|
6
|
+
return
|
7
|
+
<user>
|
8
|
+
{ $u/userid }
|
9
|
+
{ $u/name }
|
10
|
+
{
|
11
|
+
if (empty($b))
|
12
|
+
then <status>inactive</status>
|
13
|
+
else <status>active</status>
|
14
|
+
}
|
15
|
+
</user>
|
16
|
+
}
|
17
|
+
</result>
|
@@ -0,0 +1 @@
|
|
1
|
+
<frequent_bidder />
|
@@ -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
|
+
users = XML.load('users.xml')
|
24
|
+
items = XML.load('items.xml')
|
25
|
+
bids = XML.load('bids.xml')
|
26
|
+
|
27
|
+
XML.frequent_bidder! {
|
28
|
+
users.each(XML){|u|
|
29
|
+
next unless items.all?{|item|
|
30
|
+
(!item.is_a? XML) or
|
31
|
+
bids.any?{|b| b.is_a? XML and item[:@itemno] == b[:@itemno] and u[:@userid] == b[:@userid]}
|
32
|
+
}
|
33
|
+
add! u.child(:name)
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<frequent_bidder>
|
2
|
+
{
|
3
|
+
for $u in doc("users.xml")//user_tuple
|
4
|
+
where
|
5
|
+
every $item in doc("items.xml")//item_tuple satisfies
|
6
|
+
some $b in doc("bids.xml")//bid_tuple satisfies
|
7
|
+
($item/itemno = $b/itemno and $u/userid = $b/userid)
|
8
|
+
return
|
9
|
+
$u/name
|
10
|
+
}
|
11
|
+
</frequent_bidder>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<result>
|
2
|
+
<user>
|
3
|
+
<name>Dee Linquent</name>
|
4
|
+
<bid_on_item>Motorcycle</bid_on_item>
|
5
|
+
<bid_on_item>Racing Bicycle</bid_on_item>
|
6
|
+
</user>
|
7
|
+
<user>
|
8
|
+
<name>Jack Sprat</name>
|
9
|
+
<bid_on_item>Old Bicycle</bid_on_item>
|
10
|
+
<bid_on_item>Racing Bicycle</bid_on_item>
|
11
|
+
</user>
|
12
|
+
<user>
|
13
|
+
<name>Mary Doe</name>
|
14
|
+
<bid_on_item>Motorcycle</bid_on_item>
|
15
|
+
<bid_on_item>Red Bicycle</bid_on_item>
|
16
|
+
</user>
|
17
|
+
<user>
|
18
|
+
<name>Rip Van Winkle</name>
|
19
|
+
</user>
|
20
|
+
<user>
|
21
|
+
<name>Roger Smith</name>
|
22
|
+
<bid_on_item>Motorcycle</bid_on_item>
|
23
|
+
<bid_on_item>Old Bicycle</bid_on_item>
|
24
|
+
<bid_on_item>Racing Bicycle</bid_on_item>
|
25
|
+
<bid_on_item>Red Bicycle</bid_on_item>
|
26
|
+
</user>
|
27
|
+
<user>
|
28
|
+
<name>Tom Jones</name>
|
29
|
+
<bid_on_item>Motorcycle</bid_on_item>
|
30
|
+
<bid_on_item>Tricycle</bid_on_item>
|
31
|
+
</user>
|
32
|
+
</result>
|
@@ -0,0 +1,40 @@
|
|
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
|
+
users = XML.load('users.xml').children(:user_tuple).sort_by{|i| i[:@name]}
|
24
|
+
items = XML.load('items.xml')
|
25
|
+
bids = XML.load('bids.xml')
|
26
|
+
|
27
|
+
XML.result! {
|
28
|
+
users.each{|u|
|
29
|
+
user! {
|
30
|
+
add! u.child(:name)
|
31
|
+
bids.find_all{|b|
|
32
|
+
b.is_a? XML and b[:@userid] == u[:@userid]
|
33
|
+
}.map{|b| b[:@itemno]}.uniq.map{|b|
|
34
|
+
items.find{|i| i.is_a? XML and i[:@itemno] == b}[:@description]
|
35
|
+
}.sort.each{|dsc|
|
36
|
+
bid_on_item! dsc
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $u in doc("users.xml")//user_tuple
|
4
|
+
order by $u/name
|
5
|
+
return
|
6
|
+
<user>
|
7
|
+
{ $u/name }
|
8
|
+
{
|
9
|
+
for $b in distinct-values(doc("bids.xml")//bid_tuple
|
10
|
+
[userid = $u/userid]/itemno)
|
11
|
+
for $i in doc("items.xml")//item_tuple[itemno = $b]
|
12
|
+
let $descr := $i/description/text()
|
13
|
+
order by $descr
|
14
|
+
return
|
15
|
+
<bid_on_item>{ $descr }</bid_on_item>
|
16
|
+
}
|
17
|
+
</user>
|
18
|
+
}
|
19
|
+
</result>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<result>
|
2
|
+
<item_tuple>
|
3
|
+
<itemno>1001</itemno>
|
4
|
+
<description>Red Bicycle</description>
|
5
|
+
<high_bid>55</high_bid>
|
6
|
+
</item_tuple>
|
7
|
+
<item_tuple>
|
8
|
+
<itemno>1003</itemno>
|
9
|
+
<description>Old Bicycle</description>
|
10
|
+
<high_bid>20</high_bid>
|
11
|
+
</item_tuple>
|
12
|
+
<item_tuple>
|
13
|
+
<itemno>1007</itemno>
|
14
|
+
<description>Racing Bicycle</description>
|
15
|
+
<high_bid>225</high_bid>
|
16
|
+
</item_tuple>
|
17
|
+
<item_tuple>
|
18
|
+
<itemno>1008</itemno>
|
19
|
+
<description>Broken Bicycle</description>
|
20
|
+
<high_bid></high_bid>
|
21
|
+
</item_tuple>
|
22
|
+
</result>
|
@@ -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
|
+
items = XML.load('items.xml').sort_by{|i| i[:@itemno].to_i}
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
XML.result! {
|
27
|
+
items.each({:@description => /Bicycle/}){|i|
|
28
|
+
item_tuple! {
|
29
|
+
add! i.children(:itemno)
|
30
|
+
add! i.children(:description)
|
31
|
+
|
32
|
+
item_bids = bids.find_all{|b| b.is_a? XML and b[:@itemno] == i[:@itemno] }
|
33
|
+
high_bid! item_bids.map{|b| b[:@bid].to_i}.max
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $i in doc("items.xml")//item_tuple
|
4
|
+
let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno]
|
5
|
+
where contains($i/description, "Bicycle")
|
6
|
+
order by $i/itemno
|
7
|
+
return
|
8
|
+
<item_tuple>
|
9
|
+
{ $i/itemno }
|
10
|
+
{ $i/description }
|
11
|
+
<high_bid>{ max($b/bid) }</high_bid>
|
12
|
+
</item_tuple>
|
13
|
+
}
|
14
|
+
</result>
|
@@ -0,0 +1,34 @@
|
|
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
|
+
items = XML.load('items.xml')
|
24
|
+
users = XML.load('users.xml')
|
25
|
+
|
26
|
+
XML.result! {
|
27
|
+
users.each(XML){|u|
|
28
|
+
next unless u[:@rating] > "C"
|
29
|
+
items.each(XML){|i|
|
30
|
+
next unless i[:@reserve_price].to_i > 1000
|
31
|
+
warning!(u.child(:name), u.child(:rating), i.child(:description), i.child(:reserve_price))
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $u in doc("users.xml")//user_tuple
|
4
|
+
for $i in doc("items.xml")//item_tuple
|
5
|
+
where $u/rating > "C"
|
6
|
+
and $i/reserve_price > 1000
|
7
|
+
and $i/offered_by = $u/userid
|
8
|
+
return
|
9
|
+
<warning>
|
10
|
+
{ $u/name }
|
11
|
+
{ $u/rating }
|
12
|
+
{ $i/description }
|
13
|
+
{ $i/reserve_price }
|
14
|
+
</warning>
|
15
|
+
}
|
16
|
+
</result>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<result>
|
2
|
+
<no_bid_item>
|
3
|
+
<itemno>1005</itemno>
|
4
|
+
<description>Tennis Racket</description>
|
5
|
+
</no_bid_item>
|
6
|
+
<no_bid_item>
|
7
|
+
<itemno>1006</itemno>
|
8
|
+
<description>Helicopter</description>
|
9
|
+
</no_bid_item>
|
10
|
+
<no_bid_item>
|
11
|
+
<itemno>1008</itemno>
|
12
|
+
<description>Broken Bicycle</description>
|
13
|
+
</no_bid_item>
|
14
|
+
</result>
|
@@ -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
|
+
items = XML.load('items.xml')
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
XML.result!{
|
27
|
+
items.each(XML){|i|
|
28
|
+
next if bids.any?{|b| b.is_a? XML and b[:@itemno] == i[:@itemno]}
|
29
|
+
no_bid_item!(i.child(:itemno), i.child(:description))
|
30
|
+
}
|
31
|
+
}
|