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,46 @@
|
|
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
|
+
users = XML.load('users.xml')
|
25
|
+
bids = XML.load('bids.xml')
|
26
|
+
|
27
|
+
# Use pseudoattribute selectors for selects.
|
28
|
+
XML.result! {
|
29
|
+
users.each({:@name => "Tom Jones"}) {|seller|
|
30
|
+
items.each({:@offered_by => seller[:@userid], :@description => /Bicycle/}) {|item|
|
31
|
+
bids.each({:@itemno => item[:@itemno]}) {|highbid|
|
32
|
+
users.each({:@userid => highbid[:@userid]}) {|buyer|
|
33
|
+
best_bid = bids.find_all{|b| b.is_a? XML and b[:@itemno] == item[:@itemno]}.map{|b| b[:@bid].to_i}.max
|
34
|
+
next unless highbid[:@bid].to_i == best_bid
|
35
|
+
|
36
|
+
jones_bike! {
|
37
|
+
add! item.child(:itemno)
|
38
|
+
add! item.child(:description)
|
39
|
+
high_bid! highbid.child(:bid)
|
40
|
+
high_bidder! buyer.child(:name)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $seller in doc("users.xml")//user_tuple,
|
4
|
+
$buyer in doc("users.xml")//user_tuple,
|
5
|
+
$item in doc("items.xml")//item_tuple,
|
6
|
+
$highbid in doc("bids.xml")//bid_tuple
|
7
|
+
where $seller/name = "Tom Jones"
|
8
|
+
and $seller/userid = $item/offered_by
|
9
|
+
and contains($item/description , "Bicycle")
|
10
|
+
and $item/itemno = $highbid/itemno
|
11
|
+
and $highbid/userid = $buyer/userid
|
12
|
+
and $highbid/bid = max(
|
13
|
+
doc("bids.xml")//bid_tuple
|
14
|
+
[itemno = $item/itemno]/bid
|
15
|
+
)
|
16
|
+
order by ($item/itemno)
|
17
|
+
return
|
18
|
+
<jones_bike>
|
19
|
+
{ $item/itemno }
|
20
|
+
{ $item/description }
|
21
|
+
<high_bid>{ $highbid/bid }</high_bid>
|
22
|
+
<high_bidder>{ $buyer/name }</high_bidder>
|
23
|
+
</jones_bike>
|
24
|
+
}
|
25
|
+
</result>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<result>
|
2
|
+
<successful_item>
|
3
|
+
<itemno>1002</itemno>
|
4
|
+
<description>Motorcycle</description>
|
5
|
+
<reserve_price>500</reserve_price>
|
6
|
+
<high_bid>1200</high_bid>
|
7
|
+
</successful_item>
|
8
|
+
<successful_item>
|
9
|
+
<itemno>1004</itemno>
|
10
|
+
<description>Tricycle</description>
|
11
|
+
<reserve_price>15</reserve_price>
|
12
|
+
<high_bid>40</high_bid>
|
13
|
+
</successful_item>
|
14
|
+
</result>
|
@@ -0,0 +1,38 @@
|
|
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){|item|
|
28
|
+
# z can be nil if there are no bids
|
29
|
+
z = bids.find_all{|b| b.is_a? XML and b[:@itemno] == item[:@itemno]}.map{|b| b[:@bid].to_i}.max
|
30
|
+
next unless z and item[:@reserve_price].to_i * 2 < z
|
31
|
+
successful_item! {
|
32
|
+
add! item.child(:itemno)
|
33
|
+
add! item.child(:description)
|
34
|
+
add! item.child(:reserve_price)
|
35
|
+
high_bid! z
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
for $item in doc("items.xml")//item_tuple
|
4
|
+
let $b := doc("bids.xml")//bid_tuple[itemno = $item/itemno]
|
5
|
+
let $z := max($b/bid)
|
6
|
+
where $item/reserve_price * 2 < $z
|
7
|
+
return
|
8
|
+
<successful_item>
|
9
|
+
{ $item/itemno }
|
10
|
+
{ $item/description }
|
11
|
+
{ $item/reserve_price }
|
12
|
+
<high_bid>{$z }</high_bid>
|
13
|
+
</successful_item>
|
14
|
+
}
|
15
|
+
</result>
|
@@ -0,0 +1 @@
|
|
1
|
+
<high_bid>225</high_bid>
|
@@ -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
|
+
items = XML.load('items.xml')
|
24
|
+
bids = XML.load('bids.xml')
|
25
|
+
|
26
|
+
allbikes = items.children({:@description => /Bicycle|Tricycle/}).map{|item| item[:@itemno]}
|
27
|
+
|
28
|
+
XML.high_bid! {
|
29
|
+
add! bids.find_all{|b| b.is_a? XML and allbikes.include? b[:@itemno]}.map{|b| b[:@bid].to_i}.max
|
30
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<item_count>3</item_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.item_count! XML.load('items.xml').find_all{|item| item.is_a? XML and item[:@end_day] =~ /^1999-03/}.size
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<result>
|
2
|
+
<monthly_result>
|
3
|
+
<month>1</month>
|
4
|
+
<item_count>1</item_count>
|
5
|
+
</monthly_result>
|
6
|
+
<monthly_result>
|
7
|
+
<month>2</month>
|
8
|
+
<item_count>2</item_count>
|
9
|
+
</monthly_result>
|
10
|
+
<monthly_result>
|
11
|
+
<month>3</month>
|
12
|
+
<item_count>3</item_count>
|
13
|
+
</monthly_result>
|
14
|
+
<monthly_result>
|
15
|
+
<month>4</month>
|
16
|
+
<item_count>1</item_count>
|
17
|
+
</monthly_result>
|
18
|
+
<monthly_result>
|
19
|
+
<month>5</month>
|
20
|
+
<item_count>1</item_count>
|
21
|
+
</monthly_result>
|
22
|
+
</result>
|
@@ -0,0 +1,32 @@
|
|
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').children(:item_tuple)
|
24
|
+
|
25
|
+
XML.result! {
|
26
|
+
items.map{|item| item[:@end_day] =~ /^1999-(\d+)/; $1.to_i}.sort.uniq.each{|m|
|
27
|
+
monthly_result! {
|
28
|
+
month! m
|
29
|
+
item_count!(items.find_all{|item| item[:@end_day] =~ /1999-(\d+)/; $1.to_i==m}.size)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<result>
|
2
|
+
{
|
3
|
+
let $end_dates := doc("items.xml")//item_tuple/end_date
|
4
|
+
for $m in distinct-values(for $e in $end_dates
|
5
|
+
return month-from-date($e))
|
6
|
+
let $item := doc("items.xml")
|
7
|
+
//item_tuple[year-from-date(end_date) = 1999
|
8
|
+
and month-from-date(end_date) = $m]
|
9
|
+
order by $m
|
10
|
+
return
|
11
|
+
<monthly_result>
|
12
|
+
<month>{ $m }</month>
|
13
|
+
<item_count>{ count($item) }</item_count>
|
14
|
+
</monthly_result>
|
15
|
+
}
|
16
|
+
</result>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<users>
|
2
|
+
<user_tuple>
|
3
|
+
<userid>U01</userid>
|
4
|
+
<name>Tom Jones</name>
|
5
|
+
<rating>B</rating></user_tuple>
|
6
|
+
<user_tuple>
|
7
|
+
<userid>U02</userid>
|
8
|
+
<name>Mary Doe</name>
|
9
|
+
<rating>A</rating></user_tuple>
|
10
|
+
<user_tuple>
|
11
|
+
<userid>U03</userid>
|
12
|
+
<name>Dee Linquent</name>
|
13
|
+
<rating>D</rating></user_tuple>
|
14
|
+
<user_tuple>
|
15
|
+
<userid>U04</userid>
|
16
|
+
<name>Roger Smith</name>
|
17
|
+
<rating>C</rating></user_tuple>
|
18
|
+
<user_tuple>
|
19
|
+
<userid>U05</userid>
|
20
|
+
<name>Jack Sprat</name>
|
21
|
+
<rating>B</rating></user_tuple>
|
22
|
+
<user_tuple>
|
23
|
+
<userid>U06</userid>
|
24
|
+
<name>Rip Van Winkle</name>
|
25
|
+
<rating>B</rating></user_tuple></users>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Use Case "SEQ" - Queries based on Sequence
|
2
|
+
from XML Query Use Cases.
|
3
|
+
|
4
|
+
Source: http://www.w3.org/TR/xquery-use-cases/#seq
|
5
|
+
|
6
|
+
Q1 - In the Procedure section of Report1, what Instruments were used in the second Incision?
|
7
|
+
Q2 - In the Procedure section of Report1, what are the first two Instruments to be used?
|
8
|
+
Q3 - In Report1, what Instruments were used in the first two Actions after the second Incision?
|
9
|
+
Q4 - In Report1, find "Procedure" sections where no Anesthesia element occurs before the first Incision
|
10
|
+
Q5 - In Report1, what happened between the first Incision and the second Incision?
|
11
|
+
|
12
|
+
Warning: Result of Q5 is weird.
|
@@ -0,0 +1 @@
|
|
1
|
+
<instrument>electrocautery</instrument>
|
@@ -0,0 +1,25 @@
|
|
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.load('report1.xml').descendants(:section) {|s|
|
24
|
+
print s.descendants(:incision)[1].child(:instrument) if s[:"@section.title"] == "Procedure"
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
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.load('report1.xml').descendants(:section) {|s|
|
24
|
+
print s.descendants(:instrument)[0,2] if s[:"@section.title"] == "Procedure"
|
25
|
+
}
|
@@ -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('report1.xml')
|
24
|
+
i2 = doc.descendants(:incision)[1]
|
25
|
+
|
26
|
+
print doc.range(i2,nil).descendants(:action)[0,2].children(:instrument)
|
File without changes
|
@@ -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.load('report1.xml').descendants(:section) {|p|
|
24
|
+
next unless p[:"@section.title"] == "Procedure"
|
25
|
+
i1 = p.descendants(:incision)[0]
|
26
|
+
print p if p.range(nil,i1).descendants(:anesthesia).size == 0
|
27
|
+
}
|
@@ -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.critical_sequence! {
|
24
|
+
p = XML.load('report1.xml').descendants(:section).find {|p| p[:"@section.title"] == "Procedure"}
|
25
|
+
i1,i2, = *p.descendants(:incision)
|
26
|
+
# Naive add! proc.subsequence(i1,i2) would do the right thing
|
27
|
+
# Do the wrong and complex thing for compatibility with XQuery solution
|
28
|
+
add! p.subsequence(i1,i2).map{|p| [p] + [p].descendants}
|
29
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<critical_sequence>
|
2
|
+
{
|
3
|
+
let $proc := doc("report1.xml")//section[section.title="Procedure"][1],
|
4
|
+
$i1 := ($proc//incision)[1],
|
5
|
+
$i2 := ($proc//incision)[2]
|
6
|
+
for $n in $proc//node() except $i1//node()
|
7
|
+
where $n >> $i1 and $n << $i2
|
8
|
+
return $n
|
9
|
+
}
|
10
|
+
</critical_sequence>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<report>
|
2
|
+
<section>
|
3
|
+
<section.title>Procedure</section.title>
|
4
|
+
<section.content>
|
5
|
+
The patient was taken to the operating room where she was placed
|
6
|
+
in supine position and
|
7
|
+
<anesthesia>induced under general anesthesia.</anesthesia>
|
8
|
+
<prep>
|
9
|
+
<action>A Foley catheter was placed to decompress the bladder</action>
|
10
|
+
and the abdomen was then prepped and draped in sterile fashion.
|
11
|
+
</prep>
|
12
|
+
<incision>
|
13
|
+
A curvilinear incision was made
|
14
|
+
<geography>in the midline immediately infraumbilical</geography>
|
15
|
+
and the subcutaneous tissue was divided
|
16
|
+
<instrument>using electrocautery.</instrument>
|
17
|
+
</incision>
|
18
|
+
The fascia was identified and
|
19
|
+
<action>#2 0 Maxon stay sutures were placed on each side of the midline.
|
20
|
+
</action>
|
21
|
+
<incision>
|
22
|
+
The fascia was divided using
|
23
|
+
<instrument>electrocautery</instrument>
|
24
|
+
and the peritoneum was entered.
|
25
|
+
</incision>
|
26
|
+
<observation>The small bowel was identified.</observation>
|
27
|
+
and
|
28
|
+
<action>
|
29
|
+
the
|
30
|
+
<instrument>Hasson trocar</instrument>
|
31
|
+
was placed under direct visualization.
|
32
|
+
</action>
|
33
|
+
<action>
|
34
|
+
The
|
35
|
+
<instrument>trocar</instrument>
|
36
|
+
was secured to the fascia using the stay sutures.
|
37
|
+
</action>
|
38
|
+
</section.content>
|
39
|
+
</section>
|
40
|
+
</report>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Use Case "SGML": Standard Generalized Markup Language
|
2
|
+
from XML Query Use Cases.
|
3
|
+
|
4
|
+
Source: http://www.w3.org/TR/xquery-use-cases/#sgml
|
5
|
+
|
6
|
+
Q1 - Locate all paragraphs in the report (all "para"
|
7
|
+
elements occurring anywhere within the "report" element).
|
8
|
+
Q2 - Locate all paragraph elements in an introduction
|
9
|
+
(all "para" elements directly contained within
|
10
|
+
an "intro" element).
|
11
|
+
Q3 - Locate all paragraphs in the introduction of a
|
12
|
+
section that is in a chapter that has no
|
13
|
+
introduction (all "para" elements directly
|
14
|
+
contained within an "intro" element directly
|
15
|
+
contained in a "section" element directly
|
16
|
+
contained in a "chapter" element.
|
17
|
+
The "chapter" element must not directly
|
18
|
+
contain an "intro" element).
|
19
|
+
Q4 - Locate the second paragraph in the third section
|
20
|
+
in the second chapter (the second "para" element
|
21
|
+
occurring in the third "section" element occurring
|
22
|
+
in the second "chapter" element occurring in
|
23
|
+
the "report").
|
24
|
+
Q5 - Locate all classified paragraphs (all "para"
|
25
|
+
elements whose "security" attribute has the
|
26
|
+
value "c").
|
27
|
+
Q6 - List the short titles of all sections (the
|
28
|
+
values of the "shorttitle" attributes of
|
29
|
+
all "section" elements, expressing each
|
30
|
+
short title as the value of a new element.)
|
31
|
+
Q7 - Locate the initial letter of the initial
|
32
|
+
paragraph of all introductions (the first
|
33
|
+
character in the content [character content
|
34
|
+
as well as element content] of the first
|
35
|
+
"para" element contained in an "intro" element).
|
36
|
+
Q8a - Locate all sections with a title that has
|
37
|
+
"is SGML" in it. The string may occur anywhere
|
38
|
+
in the descendants of the title element,
|
39
|
+
and markup boundaries are ignored.
|
40
|
+
Q8b - Same as (Q8a), but the string "is SGML" cannot
|
41
|
+
be interrupted by sub-elements, and must
|
42
|
+
appear in a single text node.
|
43
|
+
Q9 - Locate all the topics referenced by a
|
44
|
+
cross-reference anywhere in the report
|
45
|
+
(all the "topic" elements whose "topicid"
|
46
|
+
attribute value is the same as an "xrefid"
|
47
|
+
attribute value of any "xref" element).
|
48
|
+
Q10 - Locate the closest title preceding the
|
49
|
+
cross-reference ("xref") element whose
|
50
|
+
"xrefid" attribute is "top4" (the "title"
|
51
|
+
element that would be touched last before
|
52
|
+
this "xref" element when touching each
|
53
|
+
element in document order).
|