libxml-ruby 2.0.0-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. data/HISTORY +516 -0
  2. data/LICENSE +23 -0
  3. data/MANIFEST +165 -0
  4. data/README.rdoc +161 -0
  5. data/Rakefile +82 -0
  6. data/ext/libxml/extconf.rb +122 -0
  7. data/ext/libxml/libxml.c +93 -0
  8. data/ext/libxml/ruby_libxml.h +101 -0
  9. data/ext/libxml/ruby_xml.c +893 -0
  10. data/ext/libxml/ruby_xml.h +10 -0
  11. data/ext/libxml/ruby_xml_attr.c +352 -0
  12. data/ext/libxml/ruby_xml_attr.h +14 -0
  13. data/ext/libxml/ruby_xml_attr_decl.c +171 -0
  14. data/ext/libxml/ruby_xml_attr_decl.h +13 -0
  15. data/ext/libxml/ruby_xml_attributes.c +277 -0
  16. data/ext/libxml/ruby_xml_attributes.h +17 -0
  17. data/ext/libxml/ruby_xml_cbg.c +85 -0
  18. data/ext/libxml/ruby_xml_document.c +958 -0
  19. data/ext/libxml/ruby_xml_document.h +17 -0
  20. data/ext/libxml/ruby_xml_dtd.c +257 -0
  21. data/ext/libxml/ruby_xml_dtd.h +9 -0
  22. data/ext/libxml/ruby_xml_encoding.c +221 -0
  23. data/ext/libxml/ruby_xml_encoding.h +16 -0
  24. data/ext/libxml/ruby_xml_error.c +1004 -0
  25. data/ext/libxml/ruby_xml_error.h +14 -0
  26. data/ext/libxml/ruby_xml_html_parser.c +92 -0
  27. data/ext/libxml/ruby_xml_html_parser.h +12 -0
  28. data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
  29. data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
  30. data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
  31. data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
  32. data/ext/libxml/ruby_xml_input_cbg.c +191 -0
  33. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  34. data/ext/libxml/ruby_xml_io.c +30 -0
  35. data/ext/libxml/ruby_xml_io.h +9 -0
  36. data/ext/libxml/ruby_xml_namespace.c +170 -0
  37. data/ext/libxml/ruby_xml_namespace.h +12 -0
  38. data/ext/libxml/ruby_xml_namespaces.c +295 -0
  39. data/ext/libxml/ruby_xml_namespaces.h +11 -0
  40. data/ext/libxml/ruby_xml_node.c +1386 -0
  41. data/ext/libxml/ruby_xml_node.h +13 -0
  42. data/ext/libxml/ruby_xml_parser.c +94 -0
  43. data/ext/libxml/ruby_xml_parser.h +14 -0
  44. data/ext/libxml/ruby_xml_parser_context.c +982 -0
  45. data/ext/libxml/ruby_xml_parser_context.h +12 -0
  46. data/ext/libxml/ruby_xml_parser_options.c +68 -0
  47. data/ext/libxml/ruby_xml_parser_options.h +14 -0
  48. data/ext/libxml/ruby_xml_reader.c +1057 -0
  49. data/ext/libxml/ruby_xml_reader.h +14 -0
  50. data/ext/libxml/ruby_xml_relaxng.c +111 -0
  51. data/ext/libxml/ruby_xml_relaxng.h +10 -0
  52. data/ext/libxml/ruby_xml_sax2_handler.c +334 -0
  53. data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
  54. data/ext/libxml/ruby_xml_sax_parser.c +136 -0
  55. data/ext/libxml/ruby_xml_sax_parser.h +12 -0
  56. data/ext/libxml/ruby_xml_schema.c +159 -0
  57. data/ext/libxml/ruby_xml_schema.h +11 -0
  58. data/ext/libxml/ruby_xml_version.h +9 -0
  59. data/ext/libxml/ruby_xml_xinclude.c +18 -0
  60. data/ext/libxml/ruby_xml_xinclude.h +13 -0
  61. data/ext/libxml/ruby_xml_xpath.c +107 -0
  62. data/ext/libxml/ruby_xml_xpath.h +12 -0
  63. data/ext/libxml/ruby_xml_xpath_context.c +390 -0
  64. data/ext/libxml/ruby_xml_xpath_context.h +11 -0
  65. data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
  66. data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
  67. data/ext/libxml/ruby_xml_xpath_object.c +336 -0
  68. data/ext/libxml/ruby_xml_xpath_object.h +19 -0
  69. data/ext/libxml/ruby_xml_xpointer.c +101 -0
  70. data/ext/libxml/ruby_xml_xpointer.h +13 -0
  71. data/ext/mingw/Rakefile +34 -0
  72. data/ext/mingw/build.rake +41 -0
  73. data/ext/vc/libxml_ruby.sln +26 -0
  74. data/lib/1.8/libxml_ruby.so +0 -0
  75. data/lib/1.9/libxml_ruby.so +0 -0
  76. data/lib/libxml.rb +30 -0
  77. data/lib/libxml/attr.rb +113 -0
  78. data/lib/libxml/attr_decl.rb +80 -0
  79. data/lib/libxml/attributes.rb +14 -0
  80. data/lib/libxml/document.rb +192 -0
  81. data/lib/libxml/error.rb +90 -0
  82. data/lib/libxml/hpricot.rb +78 -0
  83. data/lib/libxml/html_parser.rb +96 -0
  84. data/lib/libxml/namespace.rb +62 -0
  85. data/lib/libxml/namespaces.rb +38 -0
  86. data/lib/libxml/node.rb +399 -0
  87. data/lib/libxml/ns.rb +22 -0
  88. data/lib/libxml/parser.rb +367 -0
  89. data/lib/libxml/properties.rb +23 -0
  90. data/lib/libxml/reader.rb +29 -0
  91. data/lib/libxml/sax_callbacks.rb +180 -0
  92. data/lib/libxml/sax_parser.rb +58 -0
  93. data/lib/libxml/tree.rb +29 -0
  94. data/lib/libxml/xpath_object.rb +16 -0
  95. data/lib/xml.rb +16 -0
  96. data/lib/xml/libxml.rb +10 -0
  97. data/libxml-ruby.gemspec +50 -0
  98. data/script/benchmark/depixelate +634 -0
  99. data/script/benchmark/hamlet.xml +9055 -0
  100. data/script/benchmark/parsecount +170 -0
  101. data/script/benchmark/sock_entries.xml +507 -0
  102. data/script/benchmark/throughput +41 -0
  103. data/script/test +6 -0
  104. data/setup.rb +1585 -0
  105. data/test/etc_doc_to_s.rb +21 -0
  106. data/test/ets_doc_file.rb +17 -0
  107. data/test/ets_doc_to_s.rb +23 -0
  108. data/test/ets_gpx.rb +28 -0
  109. data/test/ets_node_gc.rb +23 -0
  110. data/test/ets_test.xml +2 -0
  111. data/test/ets_tsr.rb +11 -0
  112. data/test/model/atom.xml +13 -0
  113. data/test/model/bands.iso-8859-1.xml +5 -0
  114. data/test/model/bands.utf-8.xml +5 -0
  115. data/test/model/bands.xml +5 -0
  116. data/test/model/books.xml +146 -0
  117. data/test/model/merge_bug_data.xml +58 -0
  118. data/test/model/ruby-lang.html +238 -0
  119. data/test/model/rubynet.xml +79 -0
  120. data/test/model/rubynet_project +1 -0
  121. data/test/model/shiporder.rnc +28 -0
  122. data/test/model/shiporder.rng +86 -0
  123. data/test/model/shiporder.xml +23 -0
  124. data/test/model/shiporder.xsd +31 -0
  125. data/test/model/soap.xml +27 -0
  126. data/test/model/xinclude.xml +5 -0
  127. data/test/rb-magic-comment.rb +33 -0
  128. data/test/tc_attr.rb +181 -0
  129. data/test/tc_attr_decl.rb +133 -0
  130. data/test/tc_attributes.rb +135 -0
  131. data/test/tc_deprecated_require.rb +13 -0
  132. data/test/tc_document.rb +119 -0
  133. data/test/tc_document_write.rb +187 -0
  134. data/test/tc_dtd.rb +125 -0
  135. data/test/tc_error.rb +138 -0
  136. data/test/tc_html_parser.rb +140 -0
  137. data/test/tc_namespace.rb +62 -0
  138. data/test/tc_namespaces.rb +177 -0
  139. data/test/tc_node.rb +258 -0
  140. data/test/tc_node_cdata.rb +51 -0
  141. data/test/tc_node_comment.rb +33 -0
  142. data/test/tc_node_copy.rb +42 -0
  143. data/test/tc_node_edit.rb +160 -0
  144. data/test/tc_node_text.rb +71 -0
  145. data/test/tc_node_write.rb +108 -0
  146. data/test/tc_node_xlink.rb +29 -0
  147. data/test/tc_parser.rb +336 -0
  148. data/test/tc_parser_context.rb +189 -0
  149. data/test/tc_properties.rb +39 -0
  150. data/test/tc_reader.rb +298 -0
  151. data/test/tc_relaxng.rb +54 -0
  152. data/test/tc_sax_parser.rb +276 -0
  153. data/test/tc_schema.rb +53 -0
  154. data/test/tc_traversal.rb +222 -0
  155. data/test/tc_xinclude.rb +21 -0
  156. data/test/tc_xml.rb +226 -0
  157. data/test/tc_xpath.rb +195 -0
  158. data/test/tc_xpath_context.rb +80 -0
  159. data/test/tc_xpath_expression.rb +38 -0
  160. data/test/tc_xpointer.rb +74 -0
  161. data/test/test_helper.rb +14 -0
  162. data/test/test_suite.rb +39 -0
  163. metadata +254 -0
@@ -0,0 +1,79 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <rubynet xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <pkg version="1.0">
4
+ <meta>
5
+ <pkgname>REXML</pkgname>
6
+ <authors>
7
+ <author>
8
+ <name>Aaron Malone</name>
9
+ <email>aaron@munge.net</email>
10
+ <irc_network>irc.opentprojects.org</irc_network>
11
+ <irc_channel>#ruby-lang</irc_channel>
12
+ <irc_handle>AAmalone</irc_handle>
13
+ </author>
14
+ </authors>
15
+ <maintainers>
16
+ <maintainer>
17
+ <name>Tools Team</name>
18
+ <email>tools@gentoo.org</email>
19
+ <irc_network>irc.opentprojects.org</irc_network>
20
+ <irc_channel>#ruby-lang</irc_channel>
21
+ <irc_handle>TinyT</irc_handle>
22
+ </maintainer>
23
+ </maintainers>
24
+ <categories>
25
+
26
+ <!-- For pieces of data that are repeated constnatly, could we
27
+ use XLink to centralize some of these definitions? If we move
28
+ stuff around on rubynet.org, we don't want to have to do a
29
+ search/replace: just update the entity, IMHO. -->
30
+
31
+ <major_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/xml/">XML</major_category>
32
+ <minor_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/text%20processing/">Text Processing</minor_category>
33
+ <minor_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/storage/">Storage</minor_category>
34
+ </categories>
35
+ <version>
36
+ <major_version>1</major_version>
37
+ <minor_version>2</minor_version>
38
+ <micro_version>3</micro_version>
39
+ </version>
40
+ <copyright>1999-2002 Gentoo Technologies,Inc.</copyright>
41
+ <license>Ruby</license>
42
+ <status>Stable</status>
43
+ <full_name>Ruby Electric XML</full_name>
44
+ <description>Pure Ruby parser, blah blah. Based of Electrice XML</description>
45
+ <homepage xlink:type="simple" xlink:href="http://www.germane-software.com/~ser/Software/rexml/">REXML Home</homepage>
46
+ <download xlink:type="simple" xlink:href="http://www.germane-software.com/~ser/Software/rexml/rexml-1.2.3.bz2/">REXML Download</download>
47
+ </meta>
48
+ <dependencies>
49
+ <dependency name="ruby" uri="http://www.rubynet.org/packages/ruby/">
50
+ <required_version restriction="no-lower-than">
51
+ <version>
52
+ <major_version>1</major_version>
53
+ <minor_version>6</minor_version>
54
+ <micro_version>0</micro_version>
55
+ </version>
56
+ </required_version>
57
+ </dependency>
58
+ </dependencies>
59
+ <files>
60
+ <file>
61
+ <filename>uga.rb</filename>
62
+ <mode>0444</mode>
63
+ <content encoding="xml">... the file here</content>
64
+ </file>
65
+ <file>
66
+ <filename>booga.h</filename>
67
+ <mode>0444</mode>
68
+ <content encoding="xml">... the file here</content>
69
+ </file>
70
+ <file>
71
+ <filename>foo.so</filename>
72
+ <mode>0555</mode>
73
+ <!-- Encode routine: str.to_a.pack('m')
74
+ Decode routine: str.unpack('m') -->
75
+ <content encoding="mime64">Li4uIHRoZSBmaWxlIGhlcmU=\n</content>
76
+ </file>
77
+ </files>
78
+ </pkg>
79
+ </rubynet>
@@ -0,0 +1 @@
1
+ This is some text to include in an xml file via XInclude.
@@ -0,0 +1,28 @@
1
+ #
2
+ # relax ng schema in compact syntax; this cannot be used within libxml but
3
+ # was used to write the schema as compact syntax makes it easier to handle.
4
+ # relax ng schema in xml syntax was created using trang.
5
+ #
6
+ namespace xsi = "http://www.w3.org/2001/XMLSchema-instance"
7
+
8
+ start = shiporder
9
+
10
+ shiporder = element shiporder { attribute orderid { text },
11
+ attribute xsi:noNamespaceSchemaLocation { text },
12
+ orderperson, shipto, item* }
13
+
14
+ orderperson = element orderperson { text }
15
+
16
+ shipto = element shipto { name, address, city, country }
17
+
18
+ name = element name { text }
19
+ address = element address { text }
20
+ city = element city { text }
21
+ country = element country { text }
22
+
23
+ item = element item { title, note?, quantity, price }
24
+
25
+ title = element title { text }
26
+ note = element note { text }
27
+ quantity = element quantity { text }
28
+ price = element price { text }
@@ -0,0 +1,86 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!--
3
+
4
+ relax ng schema in compact syntax; this cannot be used within libxml but
5
+ was used to write the schema as it's easier to understand
6
+
7
+ -->
8
+ <grammar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://relaxng.org/ns/structure/1.0">
9
+ <start>
10
+ <ref name="shiporder"/>
11
+ </start>
12
+ <define name="shiporder">
13
+ <element name="shiporder">
14
+ <attribute name="orderid"/>
15
+ <attribute name="xsi:noNamespaceSchemaLocation"/>
16
+ <ref name="orderperson"/>
17
+ <ref name="shipto"/>
18
+ <zeroOrMore>
19
+ <ref name="item"/>
20
+ </zeroOrMore>
21
+ </element>
22
+ </define>
23
+ <define name="orderperson">
24
+ <element name="orderperson">
25
+ <text/>
26
+ </element>
27
+ </define>
28
+ <define name="shipto">
29
+ <element name="shipto">
30
+ <ref name="name"/>
31
+ <ref name="address"/>
32
+ <ref name="city"/>
33
+ <ref name="country"/>
34
+ </element>
35
+ </define>
36
+ <define name="name">
37
+ <element name="name">
38
+ <text/>
39
+ </element>
40
+ </define>
41
+ <define name="address">
42
+ <element name="address">
43
+ <text/>
44
+ </element>
45
+ </define>
46
+ <define name="city">
47
+ <element name="city">
48
+ <text/>
49
+ </element>
50
+ </define>
51
+ <define name="country">
52
+ <element name="country">
53
+ <text/>
54
+ </element>
55
+ </define>
56
+ <define name="item">
57
+ <element name="item">
58
+ <ref name="title"/>
59
+ <optional>
60
+ <ref name="note"/>
61
+ </optional>
62
+ <ref name="quantity"/>
63
+ <ref name="price"/>
64
+ </element>
65
+ </define>
66
+ <define name="title">
67
+ <element name="title">
68
+ <text/>
69
+ </element>
70
+ </define>
71
+ <define name="note">
72
+ <element name="note">
73
+ <text/>
74
+ </element>
75
+ </define>
76
+ <define name="quantity">
77
+ <element name="quantity">
78
+ <text/>
79
+ </element>
80
+ </define>
81
+ <define name="price">
82
+ <element name="price">
83
+ <text/>
84
+ </element>
85
+ </define>
86
+ </grammar>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <shiporder orderid="889923"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:noNamespaceSchemaLocation="shiporder.xsd">
5
+ <orderperson>John Smith</orderperson>
6
+ <shipto>
7
+ <name>Ola Nordmann</name>
8
+ <address>Langgt 23</address>
9
+ <city>4000 Stavanger</city>
10
+ <country>Norway</country>
11
+ </shipto>
12
+ <item>
13
+ <title>Empire Burlesque</title>
14
+ <note>Special Edition</note>
15
+ <quantity>1</quantity>
16
+ <price>10.90</price>
17
+ </item>
18
+ <item>
19
+ <title>Hide your heart</title>
20
+ <quantity>1</quantity>
21
+ <price>9.90</price>
22
+ </item>
23
+ </shiporder>
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="iso-8859-1" ?>
2
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
+ <xs:element name="shiporder">
4
+ <xs:complexType>
5
+ <xs:sequence>
6
+ <xs:element name="orderperson" type="xs:string"/>
7
+ <xs:element name="shipto">
8
+ <xs:complexType>
9
+ <xs:sequence>
10
+ <xs:element name="name" type="xs:string"/>
11
+ <xs:element name="address" type="xs:string"/>
12
+ <xs:element name="city" type="xs:string"/>
13
+ <xs:element name="country" type="xs:string"/>
14
+ </xs:sequence>
15
+ </xs:complexType>
16
+ </xs:element>
17
+ <xs:element name="item" maxOccurs="unbounded">
18
+ <xs:complexType>
19
+ <xs:sequence>
20
+ <xs:element name="title" type="xs:string"/>
21
+ <xs:element name="note" type="xs:string" minOccurs="0"/>
22
+ <xs:element name="quantity" type="xs:positiveInteger"/>
23
+ <xs:element name="price" type="xs:decimal"/>
24
+ </xs:sequence>
25
+ </xs:complexType>
26
+ </xs:element>
27
+ </xs:sequence>
28
+ <xs:attribute name="orderid" type="xs:string" use="required"/>
29
+ </xs:complexType>
30
+ </xs:element>
31
+ </xs:schema>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope
3
+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
7
+ <soap:Body>
8
+ <getManufacturerNamesResponse name="widgestRus" xmlns="http://services.somewhere.com">
9
+ <IDAndNameList xmlns="http://services.somewhere.com">
10
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
11
+ <id xmlns="http://domain.somewhere.com">1</id>
12
+ <name xmlns="http://domain.somewhere.com">man1</name>
13
+
14
+ </ns1:IdAndName>
15
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
16
+ <id xmlns="http://domain.somewhere.com">2</id>
17
+ <name xmlns="http://domain.somewhere.com">man2</name>
18
+
19
+ </ns1:IdAndName>
20
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
21
+ <id xmlns="http://domain.somewhere.com">3</id>
22
+ <name xmlns="http://domain.somewhere.com">man3</name>
23
+ </ns1:IdAndName>
24
+ </IDAndNameList>
25
+ </getManufacturerNamesResponse>
26
+ </soap:Body>
27
+ </soap:Envelope>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0"?>
2
+ <document xmlns:xi="http://www.w3.org/2001/XInclude">
3
+ <p>This libxml2 binding has the following project information:
4
+ <code><xi:include href="rubynet_project" parse="text"/></code></p>
5
+ </document>
@@ -0,0 +1,33 @@
1
+ #!/usr/local/ruby/bin/ruby
2
+ # encoding: UTF-8
3
+
4
+ ARGV.reject! { |path| !File.file?(path) }
5
+ (puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty?
6
+
7
+ ARGV.each do |path|
8
+ ls = IO.readlines(path)
9
+ ix = ls[0] !~ /^#!/ ? 0 : 1
10
+ next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/
11
+ ls.insert ix, "# encoding: UTF-8\n", ("\n" unless ls[ix] =~ /^#?\s*\n/)
12
+ open(path, 'w') { |f| f.write ls.join }
13
+ end
14
+
15
+ __END__
16
+ Add the unicode magic comment to ruby files.
17
+
18
+ * Files are modified in-place.
19
+ * If a file already contains a magic comment, it's skipped.
20
+ * Comment is added below the shebang if it exists, otherwise as the first line.
21
+
22
+ Usage:
23
+ $0 file-1 [file-2 ... file-n]
24
+
25
+ Examples:
26
+ # Add comment to standalone ruby files:
27
+ $0 foo.rb bar.rb
28
+
29
+ # Add comment to an entire ruby library or app:
30
+ find . -name '*.rb' -type f -print0 | xargs -0 $0
31
+
32
+ # Add comment to app files in a rails application:
33
+ find app config lib -name '*.rb' -type f -print0 | xargs -0 $0
@@ -0,0 +1,181 @@
1
+ # encoding: UTF-8
2
+
3
+ require './test_helper'
4
+ require 'test/unit'
5
+
6
+ class AttrNodeTest < Test::Unit::TestCase
7
+ def setup
8
+ xp = XML::Parser.string(<<-EOS)
9
+ <CityModel
10
+ xmlns="http://www.opengis.net/examples"
11
+ xmlns:city="http://www.opengis.net/examples"
12
+ xmlns:gml="http://www.opengis.net/gml"
13
+ xmlns:xlink="http://www.w3.org/1999/xlink"
14
+ xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
15
+ xsi:schemaLocation="http://www.opengis.net/examples city.xsd">
16
+ <type>City</type>
17
+ <cityMember name="Cambridge"
18
+ xlink:type="simple"
19
+ xlink:title="Trinity Lane"
20
+ xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239"
21
+ gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
22
+ </CityModel>
23
+ EOS
24
+
25
+ @doc = xp.parse
26
+ end
27
+
28
+ def teardown
29
+ @doc = nil
30
+ end
31
+
32
+ def city_member
33
+ @doc.find('/city:CityModel/city:cityMember').first
34
+ end
35
+
36
+ def test_doc
37
+ assert_not_nil(@doc)
38
+ assert_equal(XML::Encoding::NONE, @doc.encoding)
39
+ end
40
+
41
+ def test_types
42
+ attribute = city_member.attributes.get_attribute('name')
43
+ assert_instance_of(XML::Attr, attribute)
44
+ assert_equal('attribute', attribute.node_type_name)
45
+ end
46
+
47
+ def test_name
48
+ attribute = city_member.attributes.get_attribute('name')
49
+ assert_equal('name', attribute.name)
50
+ assert_equal(Encoding::ASCII_8BIT, attribute.name.encoding) if defined?(Encoding)
51
+
52
+ attribute = city_member.attributes.get_attribute('href')
53
+ assert_equal('href', attribute.name)
54
+ assert_equal('xlink', attribute.ns.prefix)
55
+ assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
56
+
57
+ attribute = city_member.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
58
+ assert_equal('href', attribute.name)
59
+ assert_equal('xlink', attribute.ns.prefix)
60
+ assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
61
+ end
62
+
63
+ def test_value
64
+ attribute = city_member.attributes.get_attribute('name')
65
+ assert_equal('Cambridge', attribute.value)
66
+ assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
67
+
68
+ attribute = city_member.attributes.get_attribute('href')
69
+ assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
70
+ end
71
+
72
+ def test_set_value
73
+ attribute = city_member.attributes.get_attribute('name')
74
+ attribute.value = 'London'
75
+ assert_equal('London', attribute.value)
76
+ assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
77
+
78
+ attribute = city_member.attributes.get_attribute('href')
79
+ attribute.value = 'http://i.have.changed'
80
+ assert_equal('http://i.have.changed', attribute.value)
81
+ assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
82
+ end
83
+
84
+ def test_set_nil
85
+ attribute = city_member.attributes.get_attribute('name')
86
+ assert_raise(TypeError) do
87
+ attribute.value = nil
88
+ end
89
+ end
90
+
91
+ def test_create
92
+ attributes = city_member.attributes
93
+ assert_equal(5, attributes.length)
94
+
95
+ attr = XML::Attr.new(city_member, 'size', '50,000')
96
+ assert_instance_of(XML::Attr, attr)
97
+
98
+ attributes = city_member.attributes
99
+ assert_equal(6, attributes.length)
100
+
101
+ assert_equal(attributes['size'], '50,000')
102
+ end
103
+
104
+ def test_create_on_node
105
+ attributes = city_member.attributes
106
+ assert_equal(5, attributes.length)
107
+
108
+ attributes['country'] = 'England'
109
+
110
+ attributes = city_member.attributes
111
+ assert_equal(6, attributes.length)
112
+
113
+ assert_equal(attributes['country'], 'England')
114
+ end
115
+
116
+ def test_create_ns
117
+ assert_equal(5, city_member.attributes.length)
118
+
119
+ ns = XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
120
+ attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
121
+ assert_instance_of(XML::Attr, attr)
122
+ assert_equal('rating', attr.name)
123
+ assert_equal('rocks', attr.value)
124
+
125
+ attributes = city_member.attributes
126
+ assert_equal(6, attributes.length)
127
+
128
+ assert_equal('rocks', city_member['rating'])
129
+ end
130
+
131
+ def test_remove
132
+ attributes = city_member.attributes
133
+ assert_equal(5, attributes.length)
134
+
135
+ attribute = attributes.get_attribute('name')
136
+ assert_not_nil(attribute.parent)
137
+ assert(attribute.parent?)
138
+
139
+ attribute.remove!
140
+ assert_equal(4, attributes.length)
141
+ assert_nil(attribute.parent)
142
+ assert(!attribute.parent?)
143
+ end
144
+
145
+ def test_first
146
+ attribute = city_member.attributes.first
147
+ assert_instance_of(XML::Attr, attribute)
148
+ assert_equal('name', attribute.name)
149
+ assert_equal('Cambridge', attribute.value)
150
+
151
+ attribute = attribute.next
152
+ assert_instance_of(XML::Attr, attribute)
153
+ assert_equal('type', attribute.name)
154
+ assert_equal('simple', attribute.value)
155
+
156
+ attribute = attribute.next
157
+ assert_instance_of(XML::Attr, attribute)
158
+ assert_equal('title', attribute.name)
159
+ assert_equal('Trinity Lane', attribute.value)
160
+
161
+ attribute = attribute.next
162
+ assert_instance_of(XML::Attr, attribute)
163
+ assert_equal('href', attribute.name)
164
+ assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
165
+
166
+ attribute = attribute.next
167
+ assert_instance_of(XML::Attr, attribute)
168
+ assert_equal('remoteSchema', attribute.name)
169
+ assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
170
+
171
+ attribute = attribute.next
172
+ assert_nil(attribute)
173
+ end
174
+
175
+ def test_no_attributes
176
+ element = @doc.find('/city:CityModel/city:type').first
177
+
178
+ assert_not_nil(element.attributes)
179
+ assert_equal(0, element.attributes.length)
180
+ end
181
+ end