magic_xml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (287) hide show
  1. data/README +22 -0
  2. data/Rakefile +52 -0
  3. data/VERSION +1 -0
  4. data/doc/classes/Array.html +148 -0
  5. data/doc/classes/File.html +113 -0
  6. data/doc/classes/Hash.html +117 -0
  7. data/doc/classes/Patterns_all.html +145 -0
  8. data/doc/classes/Patterns_any.html +145 -0
  9. data/doc/classes/String.html +470 -0
  10. data/doc/classes/Symbol.html +145 -0
  11. data/doc/classes/XML.html +1881 -0
  12. data/doc/classes/XML_Comment.html +148 -0
  13. data/doc/classes/XML_PI.html +145 -0
  14. data/doc/classes/XML_Tests.html +1727 -0
  15. data/doc/files/magic_xml_rb.html +186 -0
  16. data/doc/files/simple_examples/xml_hello_f_rb.html +88 -0
  17. data/doc/files/simple_examples/xml_hello_m_rb.html +88 -0
  18. data/doc/files/simple_examples/xml_list_f_rb.html +88 -0
  19. data/doc/files/simple_examples/xml_list_m_rb.html +88 -0
  20. data/doc/files/tests_rb.html +94 -0
  21. data/doc/files/xquery_use_cases/parts/q1_rb.html +117 -0
  22. data/doc/files/xquery_use_cases/rdb/q10_rb.html +88 -0
  23. data/doc/files/xquery_use_cases/rdb/q11_rb.html +88 -0
  24. data/doc/files/xquery_use_cases/rdb/q12_rb.html +88 -0
  25. data/doc/files/xquery_use_cases/rdb/q13_rb.html +88 -0
  26. data/doc/files/xquery_use_cases/rdb/q14_rb.html +88 -0
  27. data/doc/files/xquery_use_cases/rdb/q15_rb.html +88 -0
  28. data/doc/files/xquery_use_cases/rdb/q16_rb.html +88 -0
  29. data/doc/files/xquery_use_cases/rdb/q17_rb.html +88 -0
  30. data/doc/files/xquery_use_cases/rdb/q18_rb.html +88 -0
  31. data/doc/files/xquery_use_cases/rdb/q1_rb.html +88 -0
  32. data/doc/files/xquery_use_cases/rdb/q2_rb.html +88 -0
  33. data/doc/files/xquery_use_cases/rdb/q3_rb.html +88 -0
  34. data/doc/files/xquery_use_cases/rdb/q4_rb.html +88 -0
  35. data/doc/files/xquery_use_cases/rdb/q5_rb.html +88 -0
  36. data/doc/files/xquery_use_cases/rdb/q6_rb.html +88 -0
  37. data/doc/files/xquery_use_cases/rdb/q7_rb.html +88 -0
  38. data/doc/files/xquery_use_cases/rdb/q8_rb.html +88 -0
  39. data/doc/files/xquery_use_cases/rdb/q9_rb.html +88 -0
  40. data/doc/files/xquery_use_cases/seq/q1_rb.html +88 -0
  41. data/doc/files/xquery_use_cases/seq/q2_rb.html +88 -0
  42. data/doc/files/xquery_use_cases/seq/q3_rb.html +88 -0
  43. data/doc/files/xquery_use_cases/seq/q4_rb.html +88 -0
  44. data/doc/files/xquery_use_cases/seq/q5_rb.html +88 -0
  45. data/doc/files/xquery_use_cases/sgml/q10_rb.html +88 -0
  46. data/doc/files/xquery_use_cases/sgml/q1_rb.html +88 -0
  47. data/doc/files/xquery_use_cases/sgml/q2_rb.html +88 -0
  48. data/doc/files/xquery_use_cases/sgml/q3_rb.html +88 -0
  49. data/doc/files/xquery_use_cases/sgml/q4_rb.html +88 -0
  50. data/doc/files/xquery_use_cases/sgml/q5_rb.html +88 -0
  51. data/doc/files/xquery_use_cases/sgml/q6_rb.html +88 -0
  52. data/doc/files/xquery_use_cases/sgml/q7_rb.html +88 -0
  53. data/doc/files/xquery_use_cases/sgml/q8a_rb.html +88 -0
  54. data/doc/files/xquery_use_cases/sgml/q8b_rb.html +88 -0
  55. data/doc/files/xquery_use_cases/sgml/q9_rb.html +88 -0
  56. data/doc/files/xquery_use_cases/solution_sizes_rb.html +88 -0
  57. data/doc/files/xquery_use_cases/string/q1_rb.html +88 -0
  58. data/doc/files/xquery_use_cases/string/q2_rb.html +93 -0
  59. data/doc/files/xquery_use_cases/string/q4_rb.html +88 -0
  60. data/doc/files/xquery_use_cases/string/q5_rb.html +88 -0
  61. data/doc/files/xquery_use_cases/test_driver_rb.html +92 -0
  62. data/doc/files/xquery_use_cases/tree/q1_rb.html +111 -0
  63. data/doc/files/xquery_use_cases/tree/q2_rb.html +88 -0
  64. data/doc/files/xquery_use_cases/tree/q3_rb.html +88 -0
  65. data/doc/files/xquery_use_cases/tree/q4_rb.html +88 -0
  66. data/doc/files/xquery_use_cases/tree/q5_rb.html +88 -0
  67. data/doc/files/xquery_use_cases/tree/q6_rb.html +113 -0
  68. data/doc/files/xquery_use_cases/xmp/q10_rb.html +88 -0
  69. data/doc/files/xquery_use_cases/xmp/q11_rb.html +88 -0
  70. data/doc/files/xquery_use_cases/xmp/q12_rb.html +88 -0
  71. data/doc/files/xquery_use_cases/xmp/q1_rb.html +88 -0
  72. data/doc/files/xquery_use_cases/xmp/q2_rb.html +88 -0
  73. data/doc/files/xquery_use_cases/xmp/q3_rb.html +88 -0
  74. data/doc/files/xquery_use_cases/xmp/q4_rb.html +88 -0
  75. data/doc/files/xquery_use_cases/xmp/q5_rb.html +92 -0
  76. data/doc/files/xquery_use_cases/xmp/q6_rb.html +88 -0
  77. data/doc/files/xquery_use_cases/xmp/q7_rb.html +88 -0
  78. data/doc/files/xquery_use_cases/xmp/q8_rb.html +88 -0
  79. data/doc/files/xquery_use_cases/xmp/q9_rb.html +88 -0
  80. data/doc/fr_class_index.html +56 -0
  81. data/doc/fr_file_index.html +110 -0
  82. data/doc/fr_method_index.html +159 -0
  83. data/doc/index.html +26 -0
  84. data/doc/rdoc-style.css +175 -0
  85. data/lib/magic_xml.rb +1400 -0
  86. data/simple_examples/README +14 -0
  87. data/simple_examples/xml_hello_f.rb +32 -0
  88. data/simple_examples/xml_hello_m.rb +32 -0
  89. data/simple_examples/xml_list_f.rb +36 -0
  90. data/simple_examples/xml_list_m.rb +36 -0
  91. data/test/helper.rb +9 -0
  92. data/test/test_magic_xml.rb +855 -0
  93. data/xquery_use_cases/README +17 -0
  94. data/xquery_use_cases/parts/README +12 -0
  95. data/xquery_use_cases/parts/partlist.xml +13 -0
  96. data/xquery_use_cases/parts/q1.out +16 -0
  97. data/xquery_use_cases/parts/q1.rb +38 -0
  98. data/xquery_use_cases/parts/q1.xquery +18 -0
  99. data/xquery_use_cases/rdb/README +50 -0
  100. data/xquery_use_cases/rdb/bids.xml +81 -0
  101. data/xquery_use_cases/rdb/items.xml +57 -0
  102. data/xquery_use_cases/rdb/q1.out +10 -0
  103. data/xquery_use_cases/rdb/q1.rb +31 -0
  104. data/xquery_use_cases/rdb/q1.xquery +14 -0
  105. data/xquery_use_cases/rdb/q10.out +27 -0
  106. data/xquery_use_cases/rdb/q10.rb +37 -0
  107. data/xquery_use_cases/rdb/q10.xquery +15 -0
  108. data/xquery_use_cases/rdb/q11.out +7 -0
  109. data/xquery_use_cases/rdb/q11.rb +38 -0
  110. data/xquery_use_cases/rdb/q11.xquery +15 -0
  111. data/xquery_use_cases/rdb/q12.out +12 -0
  112. data/xquery_use_cases/rdb/q12.rb +42 -0
  113. data/xquery_use_cases/rdb/q12.xquery +28 -0
  114. data/xquery_use_cases/rdb/q13.out +32 -0
  115. data/xquery_use_cases/rdb/q13.rb +45 -0
  116. data/xquery_use_cases/rdb/q13.xquery +15 -0
  117. data/xquery_use_cases/rdb/q14.out +14 -0
  118. data/xquery_use_cases/rdb/q14.rb +42 -0
  119. data/xquery_use_cases/rdb/q14.xquery +14 -0
  120. data/xquery_use_cases/rdb/q15.out +5 -0
  121. data/xquery_use_cases/rdb/q15.rb +31 -0
  122. data/xquery_use_cases/rdb/q15.xquery +9 -0
  123. data/xquery_use_cases/rdb/q16.out +35 -0
  124. data/xquery_use_cases/rdb/q16.rb +35 -0
  125. data/xquery_use_cases/rdb/q16.xquery +17 -0
  126. data/xquery_use_cases/rdb/q17.out +1 -0
  127. data/xquery_use_cases/rdb/q17.rb +35 -0
  128. data/xquery_use_cases/rdb/q17.xquery +11 -0
  129. data/xquery_use_cases/rdb/q18.out +32 -0
  130. data/xquery_use_cases/rdb/q18.rb +40 -0
  131. data/xquery_use_cases/rdb/q18.xquery +19 -0
  132. data/xquery_use_cases/rdb/q2.out +22 -0
  133. data/xquery_use_cases/rdb/q2.rb +36 -0
  134. data/xquery_use_cases/rdb/q2.xquery +14 -0
  135. data/xquery_use_cases/rdb/q3.out +8 -0
  136. data/xquery_use_cases/rdb/q3.rb +34 -0
  137. data/xquery_use_cases/rdb/q3.xquery +16 -0
  138. data/xquery_use_cases/rdb/q4.out +14 -0
  139. data/xquery_use_cases/rdb/q4.rb +31 -0
  140. data/xquery_use_cases/rdb/q4.xquery +11 -0
  141. data/xquery_use_cases/rdb/q5.out +12 -0
  142. data/xquery_use_cases/rdb/q5.rb +46 -0
  143. data/xquery_use_cases/rdb/q5.xquery +25 -0
  144. data/xquery_use_cases/rdb/q6.out +14 -0
  145. data/xquery_use_cases/rdb/q6.rb +38 -0
  146. data/xquery_use_cases/rdb/q6.xquery +15 -0
  147. data/xquery_use_cases/rdb/q7.out +1 -0
  148. data/xquery_use_cases/rdb/q7.rb +30 -0
  149. data/xquery_use_cases/rdb/q7.xquery +10 -0
  150. data/xquery_use_cases/rdb/q8.out +1 -0
  151. data/xquery_use_cases/rdb/q8.rb +23 -0
  152. data/xquery_use_cases/rdb/q8.xquery +8 -0
  153. data/xquery_use_cases/rdb/q9.out +22 -0
  154. data/xquery_use_cases/rdb/q9.rb +32 -0
  155. data/xquery_use_cases/rdb/q9.xquery +16 -0
  156. data/xquery_use_cases/rdb/users.xml +25 -0
  157. data/xquery_use_cases/seq/README +12 -0
  158. data/xquery_use_cases/seq/q1.out +1 -0
  159. data/xquery_use_cases/seq/q1.rb +25 -0
  160. data/xquery_use_cases/seq/q1.xquery +2 -0
  161. data/xquery_use_cases/seq/q2.out +2 -0
  162. data/xquery_use_cases/seq/q2.rb +25 -0
  163. data/xquery_use_cases/seq/q2.xquery +2 -0
  164. data/xquery_use_cases/seq/q3.out +2 -0
  165. data/xquery_use_cases/seq/q3.rb +26 -0
  166. data/xquery_use_cases/seq/q3.xquery +3 -0
  167. data/xquery_use_cases/seq/q4.out +0 -0
  168. data/xquery_use_cases/seq/q4.rb +27 -0
  169. data/xquery_use_cases/seq/q4.xquery +4 -0
  170. data/xquery_use_cases/seq/q5.out +5 -0
  171. data/xquery_use_cases/seq/q5.rb +29 -0
  172. data/xquery_use_cases/seq/q5.xquery +10 -0
  173. data/xquery_use_cases/seq/report1.xml +40 -0
  174. data/xquery_use_cases/sgml/README +53 -0
  175. data/xquery_use_cases/sgml/q1.out +44 -0
  176. data/xquery_use_cases/sgml/q1.rb +23 -0
  177. data/xquery_use_cases/sgml/q1.xquery +5 -0
  178. data/xquery_use_cases/sgml/q10.out +1 -0
  179. data/xquery_use_cases/sgml/q10.rb +28 -0
  180. data/xquery_use_cases/sgml/q10.xquery +7 -0
  181. data/xquery_use_cases/sgml/q2.out +26 -0
  182. data/xquery_use_cases/sgml/q2.rb +23 -0
  183. data/xquery_use_cases/sgml/q2.xquery +5 -0
  184. data/xquery_use_cases/sgml/q3.out +6 -0
  185. data/xquery_use_cases/sgml/q3.rb +28 -0
  186. data/xquery_use_cases/sgml/q3.xquery +7 -0
  187. data/xquery_use_cases/sgml/q4.out +4 -0
  188. data/xquery_use_cases/sgml/q4.rb +25 -0
  189. data/xquery_use_cases/sgml/q4.xquery +5 -0
  190. data/xquery_use_cases/sgml/q5.out +3 -0
  191. data/xquery_use_cases/sgml/q5.rb +23 -0
  192. data/xquery_use_cases/sgml/q5.xquery +5 -0
  193. data/xquery_use_cases/sgml/q6.out +1 -0
  194. data/xquery_use_cases/sgml/q6.rb +27 -0
  195. data/xquery_use_cases/sgml/q6.xquery +6 -0
  196. data/xquery_use_cases/sgml/q7.out +1 -0
  197. data/xquery_use_cases/sgml/q7.rb +27 -0
  198. data/xquery_use_cases/sgml/q7.xquery +7 -0
  199. data/xquery_use_cases/sgml/q8a.out +34 -0
  200. data/xquery_use_cases/sgml/q8a.rb +27 -0
  201. data/xquery_use_cases/sgml/q8a.xquery +5 -0
  202. data/xquery_use_cases/sgml/q8b.out +26 -0
  203. data/xquery_use_cases/sgml/q8b.rb +32 -0
  204. data/xquery_use_cases/sgml/q8b.xquery +5 -0
  205. data/xquery_use_cases/sgml/q9.out +9 -0
  206. data/xquery_use_cases/sgml/q9.rb +29 -0
  207. data/xquery_use_cases/sgml/q9.xquery +6 -0
  208. data/xquery_use_cases/sgml/sgml.xml +101 -0
  209. data/xquery_use_cases/solution_sizes.rb +48 -0
  210. data/xquery_use_cases/string/README +29 -0
  211. data/xquery_use_cases/string/company-data.xml +20 -0
  212. data/xquery_use_cases/string/q1.out +4 -0
  213. data/xquery_use_cases/string/q1.rb +25 -0
  214. data/xquery_use_cases/string/q1.xquery +1 -0
  215. data/xquery_use_cases/string/q2.out +13 -0
  216. data/xquery_use_cases/string/q2.rb +32 -0
  217. data/xquery_use_cases/string/q2.xquery +23 -0
  218. data/xquery_use_cases/string/q4.out +50 -0
  219. data/xquery_use_cases/string/q4.rb +34 -0
  220. data/xquery_use_cases/string/q4.xquery +14 -0
  221. data/xquery_use_cases/string/q5.out +12 -0
  222. data/xquery_use_cases/string/q5.rb +33 -0
  223. data/xquery_use_cases/string/q5.xquery +8 -0
  224. data/xquery_use_cases/string/string.xml +82 -0
  225. data/xquery_use_cases/test_driver.rb +60 -0
  226. data/xquery_use_cases/tree/README +23 -0
  227. data/xquery_use_cases/tree/book.xml +50 -0
  228. data/xquery_use_cases/tree/q1.out +23 -0
  229. data/xquery_use_cases/tree/q1.rb +31 -0
  230. data/xquery_use_cases/tree/q1.xquery +14 -0
  231. data/xquery_use_cases/tree/q2.out +11 -0
  232. data/xquery_use_cases/tree/q2.rb +27 -0
  233. data/xquery_use_cases/tree/q2.xquery +10 -0
  234. data/xquery_use_cases/tree/q3.out +2 -0
  235. data/xquery_use_cases/tree/q3.rb +26 -0
  236. data/xquery_use_cases/tree/q3.xquery +2 -0
  237. data/xquery_use_cases/tree/q4.out +1 -0
  238. data/xquery_use_cases/tree/q4.rb +23 -0
  239. data/xquery_use_cases/tree/q4.xquery +5 -0
  240. data/xquery_use_cases/tree/q5.out +9 -0
  241. data/xquery_use_cases/tree/q5.rb +30 -0
  242. data/xquery_use_cases/tree/q5.xquery +8 -0
  243. data/xquery_use_cases/tree/q6.out +30 -0
  244. data/xquery_use_cases/tree/q6.rb +35 -0
  245. data/xquery_use_cases/tree/q6.xquery +21 -0
  246. data/xquery_use_cases/xmp/README +41 -0
  247. data/xquery_use_cases/xmp/bib.xml +35 -0
  248. data/xquery_use_cases/xmp/books.xml +15 -0
  249. data/xquery_use_cases/xmp/prices.xml +32 -0
  250. data/xquery_use_cases/xmp/q1.out +8 -0
  251. data/xquery_use_cases/xmp/q1.rb +29 -0
  252. data/xquery_use_cases/xmp/q1.xquery +10 -0
  253. data/xquery_use_cases/xmp/q10.out +11 -0
  254. data/xquery_use_cases/xmp/q10.rb +36 -0
  255. data/xquery_use_cases/xmp/q10.xquery +11 -0
  256. data/xquery_use_cases/xmp/q11.out +35 -0
  257. data/xquery_use_cases/xmp/q11.rb +37 -0
  258. data/xquery_use_cases/xmp/q11.xquery +18 -0
  259. data/xquery_use_cases/xmp/q12.out +6 -0
  260. data/xquery_use_cases/xmp/q12.rb +35 -0
  261. data/xquery_use_cases/xmp/q12.xquery +20 -0
  262. data/xquery_use_cases/xmp/q2.out +37 -0
  263. data/xquery_use_cases/xmp/q2.rb +30 -0
  264. data/xquery_use_cases/xmp/q2.xquery +12 -0
  265. data/xquery_use_cases/xmp/q3.out +34 -0
  266. data/xquery_use_cases/xmp/q3.rb +27 -0
  267. data/xquery_use_cases/xmp/q3.xquery +10 -0
  268. data/xquery_use_cases/xmp/q4.out +31 -0
  269. data/xquery_use_cases/xmp/q4.rb +44 -0
  270. data/xquery_use_cases/xmp/q4.xquery +21 -0
  271. data/xquery_use_cases/xmp/q5.out +17 -0
  272. data/xquery_use_cases/xmp/q5.rb +38 -0
  273. data/xquery_use_cases/xmp/q5.xquery +13 -0
  274. data/xquery_use_cases/xmp/q6.out +28 -0
  275. data/xquery_use_cases/xmp/q6.rb +33 -0
  276. data/xquery_use_cases/xmp/q6.xquery +19 -0
  277. data/xquery_use_cases/xmp/q7.out +8 -0
  278. data/xquery_use_cases/xmp/q7.rb +30 -0
  279. data/xquery_use_cases/xmp/q7.xquery +12 -0
  280. data/xquery_use_cases/xmp/q8.out +7 -0
  281. data/xquery_use_cases/xmp/q8.rb +29 -0
  282. data/xquery_use_cases/xmp/q8.xquery +9 -0
  283. data/xquery_use_cases/xmp/q9.out +4 -0
  284. data/xquery_use_cases/xmp/q9.rb +29 -0
  285. data/xquery_use_cases/xmp/q9.xquery +7 -0
  286. data/xquery_use_cases/xmp/reviews.xml +24 -0
  287. metadata +342 -0
@@ -0,0 +1,101 @@
1
+ <!DOCTYPE report SYSTEM "report.dtd">
2
+ <report>
3
+ <title>Getting started with SGML</title>
4
+ <chapter>
5
+ <title>The business challenge</title>
6
+ <intro>
7
+ <para>With the ever-changing and growing global market, companies and
8
+ large organizations are searching for ways to become more viable and
9
+ competitive. Downsizing and other cost-cutting measures demand more
10
+ efficient use of corporate resources. One very important resource is
11
+ an organization's information.</para>
12
+ <para>As part of the move toward integrated information management,
13
+ whole industries are developing and implementing standards for
14
+ exchanging technical information. This report describes how one such
15
+ standard, the Standard Generalized Markup Language (SGML), works as
16
+ part of an overall information management strategy.</para>
17
+ <graphic graphname="infoflow"/></intro></chapter>
18
+ <chapter>
19
+ <title>Getting to know SGML</title>
20
+ <intro>
21
+ <para>While SGML is a fairly recent technology, the use of
22
+ <emph>markup</emph> in computer-generated documents has existed for a
23
+ while.</para></intro>
24
+ <section shorttitle="What is markup?">
25
+ <title>What is markup, or everything you always wanted to know about
26
+ document preparation but were afraid to ask?</title>
27
+ <intro>
28
+ <para>Markup is everything in a document that is not content. The
29
+ traditional meaning of markup is the manual <emph>marking</emph> up
30
+ of typewritten text to give instructions for a typesetter or
31
+ compositor about how to fit the text on a page and what typefaces to
32
+ use. This kind of markup is known as <emph>procedural markup</emph>.</para></intro>
33
+ <topic topicid="top1">
34
+ <title>Procedural markup</title>
35
+ <para>Most electronic publishing systems today use some form of
36
+ procedural markup. Procedural markup codes are good for one
37
+ presentation of the information.</para></topic>
38
+ <topic topicid="top2">
39
+ <title>Generic markup</title>
40
+ <para>Generic markup (also known as descriptive markup) describes the
41
+ <emph>purpose</emph> of the text in a document. A basic concept of
42
+ generic markup is that the content of a document must be separate from
43
+ the style. Generic markup allows for multiple presentations of the
44
+ information.</para></topic>
45
+ <topic topicid="top3">
46
+ <title>Drawbacks of procedural markup</title>
47
+ <para>Industries involved in technical documentation increasingly
48
+ prefer generic over procedural markup schemes. When a company changes
49
+ software or hardware systems, enormous data translation tasks arise,
50
+ often resulting in errors.</para></topic></section>
51
+ <section shorttitle="What is SGML?">
52
+ <title>What <emph>is</emph> SGML in the grand scheme of the universe, anyway?</title>
53
+ <intro>
54
+ <para>SGML defines a strict markup scheme with a syntax for defining
55
+ document data elements and an overall framework for marking up
56
+ documents.</para>
57
+ <para>SGML can describe and create documents that are not dependent on
58
+ any hardware, software, formatter, or operating system. Since SGML documents
59
+ conform to an international standard, they are portable.</para></intro></section>
60
+ <section shorttitle="How does SGML work?">
61
+ <title>How is SGML and would you recommend it to your grandmother?</title>
62
+ <intro>
63
+ <para>You can break a typical document into three layers: structure,
64
+ content, and style. SGML works by separating these three aspects and
65
+ deals mainly with the relationship between structure and content.</para></intro>
66
+ <topic topicid="top4">
67
+ <title>Structure</title>
68
+ <para>At the heart of an SGML application is a file called the DTD, or
69
+ Document Type Definition. The DTD sets up the structure of a document,
70
+ much like a database schema describes the types of information it
71
+ handles.</para>
72
+ <para>A database schema also defines the relationships between the
73
+ various types of data. Similarly, a DTD specifies <emph>rules</emph>
74
+ to help ensure documents have a consistent, logical structure.</para></topic>
75
+ <topic topicid="top5">
76
+ <title>Content</title>
77
+ <para>Content is the information itself. The method for identifying
78
+ the information and its meaning within this framework is called
79
+ <emph>tagging</emph>. Tagging must
80
+ conform to the rules established in the DTD (see <xref xrefid="top4"/>).</para>
81
+ <graphic graphname="tagexamp"/></topic>
82
+ <topic topicid="top6">
83
+ <title>Style</title>
84
+ <para>SGML does not standardize style or other processing methods for
85
+ information stored in SGML.</para></topic></section></chapter>
86
+ <chapter>
87
+ <title>Resources</title>
88
+ <section>
89
+ <title>Conferences, tutorials, and training</title>
90
+ <intro>
91
+ <para>The Graphic Communications Association has been
92
+ instrumental in the development of SGML. GCA provides conferences,
93
+ tutorials, newsletters, and publication sales for both members and
94
+ non-members.</para>
95
+ <para security="c">Exiled members of the former Soviet Union's secret
96
+ police, the KGB, have infiltrated the upper ranks of the GCA and are
97
+ planning the Final Revolution as soon as DSSSL is completed.</para>
98
+ </intro>
99
+ </section>
100
+ </chapter>
101
+ </report>
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
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
+ $percentages = []
24
+ $ruby_size_total = 0
25
+ $xquery_size_total = 0
26
+
27
+ Dir.glob("*/q*.rb").sort.each{|ruby_solution|
28
+ ruby_solution =~ /^(.*)\/q(.*)\.rb$/
29
+ dir, name = $1, $2
30
+ xquery_solution = "#{dir}/q#{name}.xquery"
31
+
32
+ # Remove #!-line from Ruby solutions
33
+ # Remove #-comments from Ruby solutions
34
+ # (only those that take whole lines, otherwise we'd need a Ruby parser)
35
+ # Change URL-access to document-access in XQuery solutions
36
+ # Merge all whitespace into a single " "
37
+ ruby_size = File.read(ruby_solution).sub(/^#!.*?\n/,"").gsub(/^#.*?\n/,"").gsub(/\s+/, " ").size
38
+ xquery_size = File.read(xquery_solution).gsub(/http:\/\/bstore[12].example.com\//,"").gsub(/\s+/, " ").size
39
+ perc = sprintf "%.0f%%", (100.0 * ruby_size / xquery_size)
40
+ print "Problem #{dir.upcase} Q#{name}: Ruby #{ruby_size} (#{perc}), XQuery: #{xquery_size}\n"
41
+ $percentages.push(100.0 * ruby_size / xquery_size)
42
+ $ruby_size_total += ruby_size
43
+ $xquery_size_total += xquery_size
44
+ }
45
+
46
+ perc = sprintf "%.0f%%", (100.0 * $ruby_size_total / $xquery_size_total)
47
+ print "Total: Ruby #{$ruby_size_total} (#{perc}), XQuery: #{$xquery_size_total}\n"
48
+ printf "Median ratio: %.0f%%\n", $percentages.sort[$percentages.size/2]
@@ -0,0 +1,29 @@
1
+ Use Case "STRING": String Search
2
+ from XML Query Use Cases.
3
+
4
+ Source: http://www.w3.org/TR/xquery-use-cases/#text
5
+
6
+ Q1 - Find the titles of all news items where
7
+ the string "Foobar Corporation" appears
8
+ in the title.
9
+ Q2 - Find news items where the Foobar Corporation
10
+ and one or more of its partners are mentioned
11
+ in the same paragraph and/or title.
12
+ List each news item by its title and date.
13
+ Q4 - Find news items where a company and one
14
+ of its partners is mentioned in the same
15
+ news item and the news item is not authored
16
+ by the company itself.
17
+ Q5 - For each news item that is relevant to the
18
+ Gorilla Corporation, create an "item summary"
19
+ element. The content of the item summary is
20
+ the content of the title, date, and first
21
+ paragraph of the news item, separated by
22
+ periods. A news item is relevant if the name
23
+ of the company is mentioned anywhere within
24
+ the content of the news item.
25
+
26
+ Note: Query Q3 has been withdrawn from the use cases document.
27
+
28
+ Note: Q5 result has "whitespace reformatted for readability"
29
+ (test_driver is dealing with this one)
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <!DOCTYPE company SYSTEM "company.dtd">
3
+ <company>
4
+ <name>Foobar Corporation</name>
5
+ <ticker_symbol>FOO</ticker_symbol>
6
+
7
+ <description>Foobar Corporation is a maker of Foo(TM) and
8
+ Foobar(TM) products and a leading software company with a 300
9
+ Billion dollar revenue in 1999. It is located in Alaska.
10
+ </description>
11
+
12
+ <business_code>Software</business_code>
13
+ <partners>
14
+ <partner>YouNameItWeIntegrateIt.com</partner>
15
+ <partner>TheAppCompany Inc.</partner>
16
+ </partners>
17
+ <competitors>
18
+ <competitor>Gorilla Corporation</competitor>
19
+ </competitors>
20
+ </company>
@@ -0,0 +1,4 @@
1
+ <title>Foobar Corporation releases its new line of Foo
2
+ products today</title>
3
+ <title>Foobar Corporation is suing Gorilla Corporation for patent
4
+ infringement </title>
@@ -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('string.xml').descendants(:news_item, :title).each{|t|
24
+ print t if t =~ /Foobar Corporation/
25
+ }
@@ -0,0 +1 @@
1
+ doc("string.xml")//news_item/title[contains(., "Foobar Corporation")]
@@ -0,0 +1,13 @@
1
+ <news_item>
2
+ <title> Gorilla Corporation acquires YouNameItWeIntegrateIt.com </title>
3
+ <date>1-20-2000</date>
4
+ </news_item>
5
+ <news_item>
6
+ <title>Foobar Corporation releases its new line of Foo products today</title>
7
+ <date>1-20-2000</date>
8
+ </news_item>
9
+ <news_item>
10
+ <title>Foobar Corporation is suing Gorilla Corporation for patent
11
+ infringement </title>
12
+ <date>1-20-2000</date>
13
+ </news_item>
@@ -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
+ # Root of company-data is company already,
24
+ # so there is no point in searching for a particular company there.
25
+ partners = XML.load('company-data.xml').descendants(:partner).map{|p| p.text}
26
+
27
+ XML.load('string.xml').descendants(:news_item) {|item|
28
+ next unless (item.descendants(:title) + item.descendants(:par)).any?{|t|
29
+ t.text.include? "Foobar Corporation" and partners.any?{|p| t.text.include? p}
30
+ }
31
+ XML.news_item!(item.child(:title), item.child(:date))
32
+ }
@@ -0,0 +1,23 @@
1
+ declare function local:partners($company as xs:string) as element()*
2
+ {
3
+ let $c := doc("company-data.xml")//company[name = $company]
4
+ return $c//partner
5
+ };
6
+
7
+ let $foobar_partners := local:partners("Foobar Corporation")
8
+
9
+ for $item in doc("string.xml")//news_item
10
+ where
11
+ some $t in $item//title satisfies
12
+ (contains($t/text(), "Foobar Corporation")
13
+ and (some $partner in $foobar_partners satisfies
14
+ contains($t/text(), $partner/text())))
15
+ or (some $par in $item//par satisfies
16
+ (contains(string($par), "Foobar Corporation")
17
+ and (some $partner in $foobar_partners satisfies
18
+ contains(string($par), $partner/text()))))
19
+ return
20
+ <news_item>
21
+ { $item/title }
22
+ { $item/date }
23
+ </news_item>
@@ -0,0 +1,50 @@
1
+ <news_item>
2
+ <title> Gorilla Corporation acquires YouNameItWeIntegrateIt.com </title>
3
+ <content>
4
+ <par> Today, Gorilla Corporation announced that it will purchase
5
+ YouNameItWeIntegrateIt.com. The shares of
6
+ YouNameItWeIntegrateIt.com dropped $3.00 as a result of this
7
+ announcement.
8
+ </par>
9
+
10
+ <par> As a result of this acquisition, the CEO of
11
+ YouNameItWeIntegrateIt.com Bill Smarts resigned. He did not
12
+ announce what he will do next. Sources close to
13
+ YouNameItWeIntegrateIt.com hint that Bill Smarts might be
14
+ taking a position in Foobar Corporation.
15
+ </par>
16
+
17
+ <par>YouNameItWeIntegrateIt.com is a leading systems integrator
18
+ that enables <quote>brick and mortar</quote> companies to
19
+ have a presence on the web.
20
+ </par>
21
+
22
+ </content>
23
+ <date>1-20-2000</date>
24
+ <author>Mark Davis</author>
25
+ <news_agent>News Online</news_agent>
26
+ </news_item>
27
+ <news_item> <title>Foobar Corporation is suing Gorilla Corporation for
28
+ patent infringement </title>
29
+ <content>
30
+ <par> In surprising developments today, Foobar Corporation
31
+ announced that it is suing Gorilla Corporation for patent
32
+ infringement. The patents that were mentioned as part of the
33
+ lawsuit are considered to be the basis of Foobar
34
+ Corporation's <quote>Wireless Foo</quote> line of products.
35
+ </par>
36
+ <par>The tension between Foobar and Gorilla Corporations has
37
+ been increasing ever since the Gorilla Corporation acquired
38
+ more than 40 engineers who have left Foobar Corporation,
39
+ TheAppCompany Inc. and YouNameItWeIntegrateIt.com over the
40
+ past 3 months. The engineers who have left the Foobar
41
+ corporation and its partners were rumored to be working on
42
+ the next generation of server products and applications which
43
+ will directly compete with Foobar's Foo 20.9 servers. Most of
44
+ the engineers have relocated to Hawaii where the Gorilla
45
+ Corporation's server development is located.
46
+ </par>
47
+ </content>
48
+ <date>1-20-2000</date>
49
+ <news_agent>Reliable News Corporation</news_agent>
50
+ </news_item>
@@ -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
+ company_data = XML.load('company-data.xml')
24
+ # Root of company-data is company already,
25
+ # so there is no point in searching for a particular company there.
26
+ partners = company_data.descendants(:partner).map{|p| p.text}
27
+ c = company_data[:@name]
28
+
29
+ XML.load('string.xml').descendants(:news_item) {|item|
30
+ next unless item.text.include? c
31
+ next unless partners.any?{|p| item.text.include? p}
32
+ next if item[:@news_agent] == c
33
+ print item
34
+ }
@@ -0,0 +1,14 @@
1
+ declare function local:partners($company as xs:string) as element()*
2
+ {
3
+ let $c := doc("company-data.xml")//company[name = $company]
4
+ return $c//partner
5
+ };
6
+
7
+ for $item in doc("string.xml")//news_item,
8
+ $c in doc("company-data.xml")//company
9
+ let $partners := local:partners($c/name)
10
+ where contains(string($item), $c/name)
11
+ and (some $p in $partners satisfies
12
+ contains(string($item), $p) and $item/news_agent != $c/name)
13
+ return
14
+ $item
@@ -0,0 +1,12 @@
1
+ <item_summary>Gorilla Corporation acquires
2
+ YouNameItWeIntegrateIt.com. 1-20-2000. Today, Gorilla Corporation
3
+ announced that it will purchase YouNameItWeIntegrateIt.com. The shares
4
+ of YouNameItWeIntegrateIt.com dropped $3.00 as a result of this
5
+ announcement.</item_summary>
6
+
7
+ <item_summary>Foobar Corporation is suing Gorilla Corporation for
8
+ patent infringement. 1-20-2000. In surprising developments today,
9
+ Foobar Corporation announced that it is suing Gorilla Corporation for
10
+ patent infringement. The patents that were mentioned as part of the
11
+ lawsuit are considered to be the basis of Foobar Corporation's
12
+ Wireless Foo line of products.</item_summary>
@@ -0,0 +1,33 @@
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('string.xml').descendants(:news_item) {|item|
24
+ next unless item =~ /Gorilla Corporation/
25
+ XML.item_summary! {
26
+ # Whitespace is wrong without .strip
27
+ add! item[:@title].strip
28
+ add! ". "
29
+ add! item[:@date]
30
+ add! ". "
31
+ add! item.descendants(:par)[0].text
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ for $item in doc("string.xml")//news_item
2
+ where contains(string($item/content), "Gorilla Corporation")
3
+ return
4
+ <item_summary>
5
+ { concat($item/title,". ") }
6
+ { concat($item/date,". ") }
7
+ { string(($item//par)[1]) }
8
+ </item_summary>
@@ -0,0 +1,82 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <news>
3
+ <news_item>
4
+ <title> Gorilla Corporation acquires YouNameItWeIntegrateIt.com </title>
5
+ <content>
6
+ <par> Today, Gorilla Corporation announced that it will purchase
7
+ YouNameItWeIntegrateIt.com. The shares of
8
+ YouNameItWeIntegrateIt.com dropped $3.00 as a result of this
9
+ announcement.
10
+ </par>
11
+
12
+ <par> As a result of this acquisition, the CEO of
13
+ YouNameItWeIntegrateIt.com Bill Smarts resigned. He did not
14
+ announce what he will do next. Sources close to
15
+ YouNameItWeIntegrateIt.com hint that Bill Smarts might be
16
+ taking a position in Foobar Corporation.
17
+ </par>
18
+
19
+ <par>YouNameItWeIntegrateIt.com is a leading systems integrator
20
+ that enables <quote>brick and mortar</quote> companies to
21
+ have a presence on the web.
22
+ </par>
23
+
24
+ </content>
25
+ <date>1-20-2000</date>
26
+ <author>Mark Davis</author>
27
+ <news_agent>News Online</news_agent>
28
+ </news_item>
29
+
30
+ <news_item>
31
+ <title>Foobar Corporation releases its new line of Foo products
32
+ today</title>
33
+ <content>
34
+ <par> Foobar Corporation releases the 20.9 version of its Foo
35
+ products. The new version of Foo products solve known
36
+ performance problems which existed in 20.8 line and
37
+ increases the speed of Foo based products tenfold. It also
38
+ allows wireless clients to be connected to the Foobar
39
+ servers.
40
+ </par>
41
+ <par> The President of Foobar Corporation announced that they
42
+ were proud to release 20.9 version of Foo products and
43
+ they will upgrade existing customers <footnote>where
44
+ service agreements exist</footnote>
45
+ promptly. TheAppCompany Inc. immediately announced that it
46
+ will release the new version of its products to utilize
47
+ the 20.9 architecture within the next three months.
48
+ </par>
49
+ <figure>
50
+ <title>Presidents of Foobar Corporation and TheAppCompany
51
+ Inc. Shake Hands</title> <image source="handshake.jpg"/>
52
+ </figure>
53
+ </content>
54
+ <date>1-20-2000</date>
55
+ <news_agent>Foobar Corporation</news_agent>
56
+ </news_item>
57
+
58
+ <news_item> <title>Foobar Corporation is suing Gorilla Corporation for
59
+ patent infringement </title>
60
+ <content>
61
+ <par> In surprising developments today, Foobar Corporation
62
+ announced that it is suing Gorilla Corporation for patent
63
+ infringement. The patents that were mentioned as part of the
64
+ lawsuit are considered to be the basis of Foobar
65
+ Corporation's <quote>Wireless Foo</quote> line of products.
66
+ </par>
67
+ <par>The tension between Foobar and Gorilla Corporations has
68
+ been increasing ever since the Gorilla Corporation acquired
69
+ more than 40 engineers who have left Foobar Corporation,
70
+ TheAppCompany Inc. and YouNameItWeIntegrateIt.com over the
71
+ past 3 months. The engineers who have left the Foobar
72
+ corporation and its partners were rumored to be working on
73
+ the next generation of server products and applications which
74
+ will directly compete with Foobar's Foo 20.9 servers. Most of
75
+ the engineers have relocated to Hawaii where the Gorilla
76
+ Corporation's server development is located.
77
+ </par>
78
+ </content>
79
+ <date>1-20-2000</date>
80
+ <news_agent>Reliable News Corporation</news_agent>
81
+ </news_item>
82
+ </news>
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/ruby -I..
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
+ require 'magic_xml'
24
+
25
+ tests = 0
26
+ oks = 0
27
+
28
+ ruby_bin = ARGV.shift || "ruby"
29
+
30
+ Dir.glob("*/q*.rb").sort.each{|ruby_solution|
31
+ ruby_solution =~ /^(.*)\/q(.*)\.rb$/
32
+ dir, name = $1, $2
33
+
34
+ expected = File.read("#{dir}/q#{name}.out")
35
+ got = Dir.chdir(dir) { `#{ruby_bin} q#{name}.rb` }
36
+
37
+ # Now, expected_out contains a lot of cruft, strip!
38
+ expected.gsub!(/>\s+/, ">")
39
+ expected.gsub!(/\s+</, "<")
40
+ expected.gsub!(/\s+/, " ")
41
+ # A bit more renormalization
42
+ expected = XML.renormalize_sequence(expected)
43
+
44
+ # Do the same to got, or SEQ Q5 won't match
45
+ got.gsub!(/>\s+/, ">")
46
+ got.gsub!(/\s+</, "<")
47
+ got.gsub!(/\s+/, " ")
48
+
49
+ if expected == got
50
+ oks += 1
51
+ print "Test #{dir.upcase} Q#{name}: match\n"
52
+ else
53
+ print "Test #{dir.upcase} Q#{name}:\n"
54
+ print "Expected:\n#{expected}\n";
55
+ print "Got:\n#{got}\n";
56
+ print "They do not match\n\n"
57
+ end
58
+ tests += 1
59
+ }
60
+ print "Of #{tests} tests, #{oks} passed.\n"
@@ -0,0 +1,23 @@
1
+ Use Case "TREE": Queries that preserve hierarchy
2
+ from XML Query Use Cases.
3
+
4
+ Source: http://www.w3.org/TR/xquery-use-cases/#tree
5
+
6
+ Q1 - Prepare a (nested) table of contents for Book1,
7
+ listing all the sections and their titles.
8
+ Preserve the original attributes of each <section> element, if any.
9
+ Q2 - Prepare a (flat) figure list for Book1,
10
+ listing all the figures and their titles.
11
+ Preserve the original attributes of each <figure> element, if any.
12
+ Q3 - How many sections are in Book1, and how many figures?
13
+ Q4 - How many top-level sections are in Book1?
14
+ Q5 - Make a flat list of the section elements in Book1.
15
+ In place of its original attributes, each section
16
+ element should have two attributes, containing the
17
+ title of the section and the number of figures
18
+ immediately contained in the section.
19
+ Q6 - Make a nested list of the section elements in Book1,
20
+ preserving their original attributes and hierarchy.
21
+ Inside each section element, include the title of the
22
+ section and an element that includes the number of
23
+ figures immediately contained in the section.