dreamcat4-libxml-bindings 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.rdoc +58 -20
  2. data/Rakefile +8 -3
  3. data/VERSION.yml +2 -2
  4. data/lib/libxml_bindings.rb +212 -71
  5. data/test/test_helper.rb +29 -0
  6. data/test/test_libxml_bindings.rb +38 -0
  7. data/test/test_xml_modifiers.rb +57 -0
  8. data/test/test_xml_outputters.rb +53 -0
  9. data/test/test_xml_readers.rb +59 -0
  10. data/test/xml/atom.xml +13 -0
  11. data/test/xml/books.xml +146 -0
  12. data/test/xml/breakfast_menu.xml +38 -0
  13. data/test/xml/document.xml +49 -0
  14. data/test/xml/merge_bug_data.xml +58 -0
  15. data/test/xml/namespaces.xml +22 -0
  16. data/test/xml/parts_system.xml +31 -0
  17. data/test/xml/plant_catalog.xml +336 -0
  18. data/test/xml/recipie.xml +18 -0
  19. data/test/xml/rss1.xml +58 -0
  20. data/test/xml/rss2.xml +56 -0
  21. data/test/xml/ruby_lang.xhtml +238 -0
  22. data/test/xml/rubynet.xml +79 -0
  23. data/test/xml/shiporder.xls +86 -0
  24. data/test/xml/shiporder.xml +23 -0
  25. data/test/xml/shiporder.xsd +31 -0
  26. data/test/xml/soap_create_path.xml +15 -0
  27. data/test/xml/soap_create_path_response.xml +16 -0
  28. data/test/xml/soap_create_reservation.xml +25 -0
  29. data/test/xml/soap_create_reservation_response.xml +64 -0
  30. data/test/xml/soap_get_price.xml +11 -0
  31. data/test/xml/soap_get_price_response.xml +11 -0
  32. data/test/xml/soap_manufacturer_names_response.xml +27 -0
  33. data/test/xml/soap_order_item.xml +17 -0
  34. data/test/xml/soap_order_item_response.xml +10 -0
  35. data/test/xml/soap_refresh_path.xml +15 -0
  36. data/test/xml/soap_refresh_path_response.xml +16 -0
  37. data/test/xml/soap_teardown_path.xml +15 -0
  38. data/test/xml/soap_teardown_path_response.xml +16 -0
  39. metadata +53 -9
  40. data/test/libxml_bindings_test.rb +0 -7
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+
3
+ class TestXmlReaders < Test::Unit::TestCase
4
+ context "A namespaced xml document" do
5
+ setup do
6
+ # choose xml file
7
+ # xml_file = "namespaces.xml"
8
+ # xml_file = "rss1.xml"
9
+ # xml_file = "rubynet.xml"
10
+ # xml_file = "shiporder.xml"
11
+ xml_file = "soap_manufacturer_names_response.xml"
12
+ # xml_file = "soap_create_reservation_response.xml"
13
+
14
+ # Load xml file
15
+ xml_file = File.join(File.dirname(__FILE__), "xml", xml_file)
16
+ assert ! xml_file.nil?
17
+
18
+ # doc_str = File.open( xml_file, "rb").read
19
+ # @doc = doc_str.to_xmldoc
20
+ @doc = XML::Document.file xml_file
21
+ assert ! @doc.nil?
22
+
23
+ @doc.strip! # Remove any namespaces
24
+
25
+ # path="/Envelope/Body"
26
+ # path="getManufacturerNamesResponse"
27
+ # path="IDAndNameList"
28
+ # path="IDAndName"
29
+ @paths=[
30
+ "/Envelope/Body/getManufacturerNamesResponse/IDAndNameList",
31
+ "/Envelope/Body/getManufacturerNamesResponse/IDAndNameList/IdAndName",
32
+ "/Envelope/Body/getManufacturerNamesResponse/IDAndNameList/IdAndName/name",
33
+ "/Envelope/Body/getManufacturerNamesResponse/IDAndNameList/IdAndName/name/id",
34
+ ]
35
+
36
+ @replacement_node = XML::Node.new("NameString","ContentString")
37
+ end
38
+
39
+ context "with any valid syntax xpath expression" do
40
+ should "return the first matching node" do
41
+ @paths.each do |path|
42
+ # node = @doc.node[path]
43
+ # puts "node=#{node}"
44
+ assert ! node.nil?
45
+ end
46
+ end
47
+ should "return an array of matching nodes" do
48
+ @paths.each do |path|
49
+ # nodes = @doc.nodes[path]
50
+ # puts "nodes=#{nodes}"
51
+ assert ! node.nil?
52
+ end
53
+ end
54
+ end
55
+
56
+ end
57
+ end
58
+
59
+
data/test/xml/atom.xml ADDED
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?xml-stylesheet type="text/xsl" href="my_stylesheet.xsl"?>
3
+ <feed xmlns="http://www.w3.org/2005/Atom">
4
+ <!-- Not a valid atom entry -->
5
+ <entry>
6
+ <title type="html"><![CDATA[<<strong>>]]></title>
7
+ <content type="xhtml">
8
+ <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
9
+ <xhtml:p>hi there</xhtml:p>
10
+ </xhtml:div>
11
+ </content>
12
+ </entry>
13
+ </feed>
@@ -0,0 +1,146 @@
1
+ <?xml version="1.0"?>
2
+ <!-- Sample xml file from Microsoft.
3
+ See http://msdn.microsoft.com/en-us/library/ms762271(VS.85).aspx -->
4
+ <catalog>
5
+ <book id="bk101">
6
+ <author>Gambardella, Matthew</author>
7
+ <title>XML Developer's Guide</title>
8
+ <genre>Computer</genre>
9
+ <price>44.95</price>
10
+ <publish_date>2000-10-01</publish_date>
11
+ <description>
12
+ An in-depth look at creating applications
13
+ with XML.
14
+ </description>
15
+ </book>
16
+ <book id="bk102">
17
+ <author>Ralls, Kim</author>
18
+ <title>Midnight Rain</title>
19
+ <genre>Fantasy</genre>
20
+ <price>5.95</price>
21
+ <publish_date>2000-12-16</publish_date>
22
+ <description>
23
+ A former architect battles corporate zombies,
24
+ an evil sorceress, and her own childhood to become queen
25
+ of the world.
26
+ </description>
27
+ </book>
28
+ <book id="bk103">
29
+ <author>Corets, Eva</author>
30
+ <title>Maeve Ascendant</title>
31
+ <genre>Fantasy</genre>
32
+ <price>5.95</price>
33
+ <publish_date>2000-11-17</publish_date>
34
+ <description>
35
+ After the collapse of a nanotechnology
36
+ society in England, the young survivors lay the
37
+ foundation for a new society.
38
+ </description>
39
+ </book>
40
+ <book id="bk104">
41
+ <author>Corets, Eva</author>
42
+ <title>Oberon's Legacy</title>
43
+ <genre>Fantasy</genre>
44
+ <price>5.95</price>
45
+ <publish_date>2001-03-10</publish_date>
46
+ <description>
47
+ In post-apocalypse England, the mysterious
48
+ agent known only as Oberon helps to create a new life
49
+ for the inhabitants of London. Sequel to Maeve
50
+ Ascendant.
51
+ </description>
52
+ </book>
53
+ <book id="bk105">
54
+ <author>Corets, Eva</author>
55
+ <title>The Sundered Grail</title>
56
+ <genre>Fantasy</genre>
57
+ <price>5.95</price>
58
+ <publish_date>2001-09-10</publish_date>
59
+ <description>
60
+ The two daughters of Maeve, half-sisters,
61
+ battle one another for control of England. Sequel to
62
+ Oberon's Legacy.
63
+ </description>
64
+ </book>
65
+ <book id="bk106">
66
+ <author>Randall, Cynthia</author>
67
+ <title>Lover Birds</title>
68
+ <genre>Romance</genre>
69
+ <price>4.95</price>
70
+ <publish_date>2000-09-02</publish_date>
71
+ <description>
72
+ When Carla meets Paul at an ornithology
73
+ conference, tempers fly as feathers get ruffled.
74
+ </description>
75
+ </book>
76
+ <book id="bk107">
77
+ <author>Thurman, Paula</author>
78
+ <title>Splish Splash</title>
79
+ <genre>Romance</genre>
80
+ <price>4.95</price>
81
+ <publish_date>2000-11-02</publish_date>
82
+ <description>
83
+ A deep sea diver finds true love twenty
84
+ thousand leagues beneath the sea.
85
+ </description>
86
+ </book>
87
+ <book id="bk108">
88
+ <author>Knorr, Stefan</author>
89
+ <title>Creepy Crawlies</title>
90
+ <genre>Horror</genre>
91
+ <price>4.95</price>
92
+ <publish_date>2000-12-06</publish_date>
93
+ <description>
94
+ An anthology of horror stories about roaches,
95
+ centipedes, scorpions and other insects.
96
+ </description>
97
+ </book>
98
+ <book id="bk109">
99
+ <author>Kress, Peter</author>
100
+ <title>Paradox Lost</title>
101
+ <genre>Science Fiction</genre>
102
+ <price>6.95</price>
103
+ <publish_date>2000-11-02</publish_date>
104
+ <description>
105
+ After an inadvertant trip through a Heisenberg
106
+ Uncertainty Device, James Salway discovers the problems
107
+ of being quantum.
108
+ </description>
109
+ </book>
110
+ <book id="bk110">
111
+ <author>O'Brien, Tim</author>
112
+ <title>Microsoft .NET: The Programming Bible</title>
113
+ <genre>Computer</genre>
114
+ <price>36.95</price>
115
+ <publish_date>2000-12-09</publish_date>
116
+ <description>
117
+ Microsoft's .NET initiative is explored in
118
+ detail in this deep programmer's reference.
119
+ </description>
120
+ </book>
121
+ <book id="bk111">
122
+ <author>O'Brien, Tim</author>
123
+ <title>MSXML3: A Comprehensive Guide</title>
124
+ <genre>Computer</genre>
125
+ <price>36.95</price>
126
+ <publish_date>2000-12-01</publish_date>
127
+ <description>
128
+ The Microsoft MSXML3 parser is covered in
129
+ detail, with attention to XML DOM interfaces, XSLT processing,
130
+ SAX and more.
131
+ </description>
132
+ </book>
133
+ <book id="bk112">
134
+ <author>Galos, Mike</author>
135
+ <title>Visual Studio 7: A Comprehensive Guide</title>
136
+ <genre>Computer</genre>
137
+ <price>49.95</price>
138
+ <publish_date>2001-04-16</publish_date>
139
+ <description>
140
+ Microsoft Visual Studio 7 is explored in depth,
141
+ looking at how Visual Basic, Visual C++, C#, and ASP+ are
142
+ integrated into a comprehensive development
143
+ environment.
144
+ </description>
145
+ </book>
146
+ </catalog>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <!-- http://www.w3schools.com/XML/xml_examples.asp -->
3
+ <breakfast_menu>
4
+ <food>
5
+ <name>Belgian Waffles</name>
6
+ <price>$5.95</price>
7
+ <description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
8
+ <calories>650</calories>
9
+
10
+ </food>
11
+ <food>
12
+ <name>Strawberry Belgian Waffles</name>
13
+ <price>$7.95</price>
14
+ <description>light Belgian waffles covered with strawberries and whipped cream</description>
15
+ <calories>900</calories>
16
+ </food>
17
+
18
+ <food>
19
+ <name>Berry-Berry Belgian Waffles</name>
20
+ <price>$8.95</price>
21
+ <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
22
+ <calories>900</calories>
23
+ </food>
24
+ <food>
25
+
26
+ <name>French Toast</name>
27
+ <price>$4.50</price>
28
+ <description>thick slices made from our homemade sourdough bread</description>
29
+ <calories>600</calories>
30
+ </food>
31
+ <food>
32
+ <name>Homestyle Breakfast</name>
33
+
34
+ <price>$6.95</price>
35
+ <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
36
+ <calories>950</calories>
37
+ </food>
38
+ </breakfast_menu>
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <!-- http://www.captain.at/howto-xml-xsl-example.php -->
3
+ <?xml-stylesheet type="text/xsl" href="test.xsl"?>
4
+ <document>
5
+ <menu>
6
+ <item>
7
+ <name>Captain</name>
8
+ <url>http://www.captain.at</url>
9
+ </item>
10
+ <item>
11
+ <name>Jupiter</name>
12
+ <url>http://www.jupiterradio.com</url>
13
+ </item>
14
+ <item>
15
+ <name>Plants</name>
16
+ <url>http://www.bryophyllum.com</url>
17
+ </item>
18
+ </menu>
19
+ <content>
20
+ <news>
21
+ <title>
22
+ test1
23
+ </title>
24
+ <news>
25
+ test 1 text
26
+ </news>
27
+ </news>
28
+ <news>
29
+ <title>
30
+ test2
31
+ </title>
32
+ <news>
33
+ <font face="courier">
34
+ <strong>test 2 text &#8801;</strong>
35
+ </font>
36
+ </news>
37
+ <include>
38
+ <data>
39
+ <item>
40
+ include-text1
41
+ </item>
42
+ <item>
43
+ include-text2
44
+ </item>
45
+ </data>
46
+ </include>
47
+ </news>
48
+ </content>
49
+ </document>
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <template>
3
+ <body>
4
+ <section>
5
+ <txt>Some Preset Data Here</txt>
6
+ <txt>Some Preset Data Here</txt>
7
+ <txt>name: quack!</txt>
8
+ <txt>Some Preset Data Here</txt>
9
+ <txt>Some Preset Data Here</txt>
10
+ <txt>Some Preset Data Here</txt>
11
+ <txt>Some Preset Data Here</txt>
12
+ <txt>city: quack!</txt>
13
+ <txt>Some Preset Data Here</txt>
14
+ <txt>Some Preset Data Here</txt>
15
+ <txt>Some Preset Data Here</txt>
16
+ <txt>Some Preset Data Here</txt>
17
+ <txt>state: quack!</txt>
18
+ <txt>Some Preset Data Here</txt>
19
+ <txt>Some Preset Data Here</txt>
20
+ <txt>Some Preset Data Here</txt>
21
+ <txt>Some Preset Data Here</txt>
22
+ <row>
23
+ <txt>year: Vroom!</txt>
24
+ <txt>make: Vroom!</txt>
25
+ <txt>model: Vroom!</txt>
26
+ </row>
27
+ <row>
28
+ <txt>year: Vroom!</txt>
29
+ <txt>make: Vroom!</txt>
30
+ <txt>model: Vroom!</txt>
31
+ </row>
32
+ <row>
33
+ <txt>year: Vroom!</txt>
34
+ <txt>make: Vroom!</txt>
35
+ <txt>model: Vroom!</txt>
36
+ </row>
37
+ <txt>Some Preset Data Here</txt>
38
+ <txt>Some Preset Data Here</txt>
39
+ <row>
40
+ <txt>year: Vroom!</txt>
41
+ <txt>make: Vroom!</txt>
42
+ <txt>model: Vroom!</txt>
43
+ </row>
44
+ <row>
45
+ <txt>year: Vroom!</txt>
46
+ <txt>make: Vroom!</txt>
47
+ <txt>model: Vroom!</txt>
48
+ </row>
49
+ <row>
50
+ <txt>year: Vroom!</txt>
51
+ <txt>make: Vroom!</txt>
52
+ <txt>model: Vroom!</txt>
53
+ </row>
54
+ <txt>Some Preset Data Here</txt>
55
+ <txt>Some Preset Data Here</txt>
56
+ </section>
57
+ </body>
58
+ </template>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <!-- http://www.xml.com/pub/a/1999/01/namespaces.html -->
3
+ <h:html xmlns:xdc="http://www.xml.com/books"
4
+ xmlns:h="http://www.w3.org/HTML/1998/html4">
5
+ <h:head><h:title>Book Review</h:title></h:head>
6
+ <h:body>
7
+ <xdc:bookreview>
8
+ <xdc:title>XML: A Primer</xdc:title>
9
+ <h:table>
10
+ <h:tr align="center">
11
+ <h:td>Author</h:td><h:td>Price</h:td>
12
+ <h:td>Pages</h:td><h:td>Date</h:td></h:tr>
13
+ <h:tr align="left">
14
+ <h:td><xdc:author>Simon St. Laurent</xdc:author></h:td>
15
+ <h:td><xdc:price>31.98</xdc:price></h:td>
16
+ <h:td><xdc:pages>352</xdc:pages></h:td>
17
+ <h:td><xdc:date>1998/01</xdc:date></h:td>
18
+ </h:tr>
19
+ </h:table>
20
+ </xdc:bookreview>
21
+ </h:body>
22
+ </h:html>
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0"?>
2
+ <!-- http://www.comptechdoc.org/independent/web/xml/guide/xmlexample.html -->
3
+ <!DOCTYPE PARTS SYSTEM "parts.dtd">
4
+ <?xml-stylesheet type="text/css" href="xmlpartsstyle.css"?>
5
+ <PARTS>
6
+ <TITLE>Computer Parts</TITLE>
7
+ <PART>
8
+ <ITEM>Motherboard</ITEM>
9
+ <MANUFACTURER>ASUS</MANUFACTURER>
10
+ <MODEL>P3B-F</MODEL>
11
+ <COST> 123.00</COST>
12
+ </PART>
13
+ <PART>
14
+ <ITEM>Video Card</ITEM>
15
+ <MANUFACTURER>ATI</MANUFACTURER>
16
+ <MODEL>All-in-Wonder Pro</MODEL>
17
+ <COST> 160.00</COST>
18
+ </PART>
19
+ <PART>
20
+ <ITEM>Sound Card</ITEM>
21
+ <MANUFACTURER>Creative Labs</MANUFACTURER>
22
+ <MODEL>Sound Blaster Live</MODEL>
23
+ <COST> 80.00</COST>
24
+ </PART>
25
+ <PART>
26
+ <ITEMᡋ inch Monitor</ITEM>
27
+ <MANUFACTURER>LG Electronics</MANUFACTURER>
28
+ <MODEL> 995E</MODEL>
29
+ <COST> 290.00</COST>
30
+ </PART>
31
+ </PARTS>