libxml-ruby 0.5.4 → 0.6.0

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 (139) hide show
  1. data/LICENSE +23 -23
  2. data/README +144 -144
  3. data/ext/libxml/extconf.rb +26 -27
  4. data/ext/libxml/libxml.c +7 -37
  5. data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
  6. data/ext/libxml/ruby_xml_attr.c +405 -387
  7. data/ext/libxml/ruby_xml_attr.h +19 -18
  8. data/ext/libxml/ruby_xml_document.c +1111 -1115
  9. data/ext/libxml/ruby_xml_document.h +27 -24
  10. data/ext/libxml/ruby_xml_dtd.c +168 -168
  11. data/ext/libxml/ruby_xml_html_parser.c +449 -450
  12. data/ext/libxml/ruby_xml_html_parser.h +1 -1
  13. data/ext/libxml/ruby_xml_input_cbg.c +158 -158
  14. data/ext/libxml/ruby_xml_node.c +2410 -2395
  15. data/ext/libxml/ruby_xml_node.h +1 -1
  16. data/ext/libxml/ruby_xml_node_set.c +170 -170
  17. data/ext/libxml/ruby_xml_node_set.h +1 -1
  18. data/ext/libxml/ruby_xml_ns.c +153 -153
  19. data/ext/libxml/ruby_xml_ns.h +1 -1
  20. data/ext/libxml/ruby_xml_parser.c +1425 -1422
  21. data/ext/libxml/ruby_xml_parser.h +1 -1
  22. data/ext/libxml/ruby_xml_parser_context.c +750 -716
  23. data/ext/libxml/ruby_xml_parser_context.h +1 -1
  24. data/ext/libxml/ruby_xml_reader.c +900 -896
  25. data/ext/libxml/ruby_xml_sax_parser.c +485 -485
  26. data/ext/libxml/ruby_xml_sax_parser.h +1 -1
  27. data/ext/libxml/ruby_xml_schema.c +146 -142
  28. data/ext/libxml/ruby_xml_state.c +5 -6
  29. data/ext/libxml/ruby_xml_state.h +1 -0
  30. data/ext/libxml/ruby_xml_tree.c +43 -43
  31. data/ext/libxml/ruby_xml_tree.h +1 -1
  32. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  33. data/ext/libxml/ruby_xml_xinclude.h +1 -1
  34. data/ext/libxml/ruby_xml_xpath.c +243 -252
  35. data/ext/libxml/ruby_xml_xpath.h +1 -1
  36. data/ext/libxml/ruby_xml_xpath_context.c +118 -118
  37. data/ext/libxml/ruby_xml_xpath_context.h +1 -1
  38. data/ext/libxml/ruby_xml_xpath_object.c +43 -29
  39. data/ext/libxml/ruby_xml_xpath_object.h +0 -1
  40. data/ext/libxml/ruby_xml_xpointer.c +100 -100
  41. data/ext/libxml/ruby_xml_xpointer.h +1 -1
  42. data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
  43. data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
  44. data/ext/libxml/sax_parser_callbacks.inc +213 -213
  45. data/ext/libxml/version.h +9 -9
  46. data/lib/libxml.rb +24 -3
  47. data/mingw/libiconv-2.dll +0 -0
  48. data/mingw/libxml2-2.dll +0 -0
  49. data/mingw/libxml_ruby.so +0 -0
  50. data/mingw/mingw.rake +36 -0
  51. data/test/dtd-test.rb +24 -24
  52. data/test/etc_doc_to_s.rb +1 -3
  53. data/test/ets_copy_bug.rb +21 -21
  54. data/test/ets_copy_bug2.rb +32 -32
  55. data/test/ets_copy_bug3.rb +38 -0
  56. data/test/ets_doc_file.rb +1 -0
  57. data/test/{model/default_validation_bug.rb → gc.log} +0 -0
  58. data/test/merge_bug.rb +55 -55
  59. data/test/schema-test.rb +74 -74
  60. data/test/tc_well_formed.rb +11 -0
  61. data/test/tc_xml_document.rb +52 -52
  62. data/test/tc_xml_document_write.rb +24 -24
  63. data/test/tc_xml_document_write2.rb +54 -54
  64. data/test/tc_xml_document_write3.rb +96 -96
  65. data/test/tc_xml_html_parser.rb +63 -63
  66. data/test/tc_xml_node.rb +59 -59
  67. data/test/tc_xml_node2.rb +25 -25
  68. data/test/tc_xml_node3.rb +27 -27
  69. data/test/tc_xml_node4.rb +86 -86
  70. data/test/tc_xml_node5.rb +52 -52
  71. data/test/tc_xml_node6.rb +27 -27
  72. data/test/tc_xml_node7.rb +35 -35
  73. data/test/tc_xml_node8.rb +32 -32
  74. data/test/tc_xml_node9.rb +32 -32
  75. data/test/tc_xml_node_set.rb +24 -24
  76. data/test/tc_xml_node_set2.rb +37 -37
  77. data/test/tc_xml_node_xlink.rb +28 -28
  78. data/test/tc_xml_parser.rb +190 -178
  79. data/test/tc_xml_parser2.rb +16 -17
  80. data/test/tc_xml_parser3.rb +23 -23
  81. data/test/tc_xml_parser4.rb +33 -33
  82. data/test/tc_xml_parser5.rb +27 -27
  83. data/test/tc_xml_parser6.rb +23 -23
  84. data/test/tc_xml_parser7.rb +28 -28
  85. data/test/tc_xml_parser8.rb +32 -32
  86. data/test/tc_xml_parser9.rb +11 -0
  87. data/test/tc_xml_parser_context.rb +88 -88
  88. data/test/tc_xml_reader.rb +112 -109
  89. data/test/tc_xml_sax_parser.rb +104 -94
  90. data/test/tc_xml_sax_parser2.rb +51 -0
  91. data/test/tc_xml_xinclude.rb +30 -30
  92. data/test/tc_xml_xpath.rb +38 -38
  93. data/test/tc_xml_xpath2.rb +14 -0
  94. data/test/tc_xml_xpointer.rb +78 -78
  95. data/vc/libxml.sln +20 -0
  96. data/vc/libxml.vcproj +389 -0
  97. data/work/Rakefile +247 -0
  98. data/work/task/make +26 -0
  99. data/work/task/memory +37 -0
  100. data/work/task/rdoc +39 -0
  101. data/work/task/setup +1616 -0
  102. data/work/task/test +29 -0
  103. data/work/test/ets_runner.rb +33 -0
  104. data/work/test/libxml_test.rb +3 -0
  105. data/work/test/runner.rb +0 -0
  106. data/work/test/runner_ets.rb +33 -0
  107. data/work/vc/debug/libxml.exp +0 -0
  108. data/work/vc/debug/libxml.ilk +0 -0
  109. data/work/vc/debug/libxml.lib +0 -0
  110. data/work/vc/debug/libxml.pdb +0 -0
  111. data/work/vc/debug/libxml.so +0 -0
  112. metadata +158 -189
  113. data/MANIFEST +0 -138
  114. data/NOTES +0 -9
  115. data/Rakefile +0 -38
  116. data/TODO +0 -75
  117. data/VERSION +0 -1
  118. data/log/Changelog-0.txt +0 -426
  119. data/log/Changelog.txt +0 -435
  120. data/meta/project.yaml +0 -27
  121. data/meta/unixname +0 -1
  122. data/setup.rb +0 -1472
  123. data/site/css/normal.css +0 -182
  124. data/site/img/raze-tiny.png +0 -0
  125. data/site/img/red-cube.jpg +0 -0
  126. data/site/img/xml-ruby.png +0 -0
  127. data/site/index.xml +0 -43
  128. data/site/install.xml +0 -77
  129. data/site/layout.rhtml +0 -38
  130. data/site/layout.xsl +0 -67
  131. data/site/license.xml +0 -32
  132. data/site/log/changelog.xml +0 -1324
  133. data/site/log/changelog.xsl +0 -42
  134. data/test/model/merge_bug_data.xml +0 -58
  135. data/test/model/rubynet.xml +0 -78
  136. data/test/model/rubynet_project +0 -13
  137. data/test/model/saxtest.xml +0 -5
  138. data/test/model/simple.xml +0 -7
  139. data/test/model/xinclude.xml +0 -5
@@ -1,94 +1,104 @@
1
- require 'libxml'
2
- require 'test/unit'
3
-
4
- # TODO this is woefully inadequate
5
-
6
- class TC_XML_SaxParser2 < Test::Unit::TestCase
7
- class TestCaseCallbacks
8
- include XML::SaxParser::Callbacks
9
-
10
- attr_accessor :test
11
-
12
- def initialize
13
- @test = Hash.new { |h,k| h[k] = [] }
14
- @i = 0
15
- end
16
-
17
- def on_start_document
18
- @test[:startdoc] << @i+=1
19
- end
20
-
21
- def on_start_element(name, attr_hash)
22
- @test[:startel] << [@i+=1,name,attr_hash]
23
- end
24
-
25
- def on_characters(chars)
26
- @test[:chars] << [@i+=1,chars]
27
- end
28
-
29
- def on_comment(msg)
30
- @test[:comment] << [@i+=1,msg]
31
- end
32
-
33
- def on_processing_instruction(target, data)
34
- @test[:pinstr] << [@i+=1, target, data]
35
- end
36
-
37
- def on_cdata_block(cdata)
38
- @test[:cdata] << [@i+=1,cdata]
39
- end
40
-
41
- def on_end_element(name)
42
- @test[:endel] << [@i+=1,name]
43
- end
44
-
45
- def on_end_document
46
- @test[:enddoc] << @i+=1
47
- end
48
- end
49
-
50
- def setup()
51
- @xp = XML::SaxParser.new
52
- end
53
-
54
- def teardown()
55
- @xp = nil
56
- end
57
-
58
- def test_string_without_callbacks
59
- @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
60
- assert_equal true, @xp.parse
61
- end
62
-
63
- def test_file_without_callbacks
64
- @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
65
- assert_equal true, @xp.parse
66
- end
67
-
68
- def test_callbacks_with_string
69
- @xp.callbacks = TestCaseCallbacks.new
70
- @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
71
- do_test
72
- end
73
-
74
- def test_callbacks_with_file
75
- @xp.callbacks = TestCaseCallbacks.new
76
- @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
77
- do_test
78
- end
79
-
80
- def do_test
81
- @xp.parse
82
-
83
- assert_equal [1], @xp.callbacks.test[:startdoc]
84
- assert_equal [[2,'test',{'uga'=>'booga','foo'=>'bar'}],[3,'fixnum',{}],[6,'fixnum',{}]],
85
- @xp.callbacks.test[:startel]
86
- assert_equal [[4,'one'],[7,'two'],[9,"\n "],[11,"\n "],[13,"\n "],[15,"\n"]],
87
- @xp.callbacks.test[:chars]
88
- assert_equal [[10, ' msg ']], @xp.callbacks.test[:comment]
89
- assert_equal [[12, 'custom', 'foo="bar"']], @xp.callbacks.test[:pinstr]
90
- assert_equal [[14, 'here it goes']], @xp.callbacks.test[:cdata]
91
- assert_equal [[5,'fixnum'],[8,'fixnum'],[16,'test']], @xp.callbacks.test[:endel]
92
- assert_equal [17], @xp.callbacks.test[:enddoc]
93
- end
94
- end # TC_XML_Sax_Parser
1
+ require 'libxml'
2
+ require 'test/unit'
3
+
4
+ # TODO this is woefully inadequate
5
+
6
+ class TC_XML_SaxParser2 < Test::Unit::TestCase
7
+ class TestCaseCallbacks
8
+ include XML::SaxParser::Callbacks
9
+
10
+ attr_accessor :test
11
+
12
+ def initialize
13
+ @test = Hash.new { |h,k| h[k] = [] }
14
+ @i = 0
15
+ end
16
+
17
+ def on_start_document
18
+ @test[:startdoc] << @i+=1
19
+ end
20
+
21
+ def on_start_element(name, attr_hash)
22
+ @test[:startel] << [@i+=1,name,attr_hash]
23
+ end
24
+
25
+ def on_characters(chars)
26
+ @test[:chars] << [@i+=1,chars]
27
+ end
28
+
29
+ def on_comment(msg)
30
+ @test[:comment] << [@i+=1,msg]
31
+ end
32
+
33
+ def on_processing_instruction(target, data)
34
+ @test[:pinstr] << [@i+=1, target, data]
35
+ end
36
+
37
+ def on_cdata_block(cdata)
38
+ @test[:cdata] << [@i+=1,cdata]
39
+ end
40
+
41
+ def on_end_element(name)
42
+ @test[:endel] << [@i+=1,name]
43
+ end
44
+
45
+ def on_end_document
46
+ @test[:enddoc] << @i+=1
47
+ end
48
+ end
49
+
50
+ def setup()
51
+ @xp = XML::SaxParser.new
52
+ end
53
+
54
+ def teardown()
55
+ @xp = nil
56
+ end
57
+
58
+ def test_string_without_callbacks
59
+ @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
60
+ assert_equal true, @xp.parse
61
+ end
62
+
63
+ def test_file_without_callbacks
64
+ @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
65
+ assert_equal true, @xp.parse
66
+ end
67
+
68
+ def test_callbacks_with_string
69
+ @xp.callbacks = TestCaseCallbacks.new
70
+ @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
71
+ do_test
72
+ end
73
+
74
+ def test_callbacks_with_file
75
+ @xp.callbacks = TestCaseCallbacks.new
76
+ @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
77
+ do_test
78
+ end
79
+
80
+ def do_test
81
+ @xp.parse
82
+ assert_equal [1], @xp.callbacks.test[:startdoc]
83
+ assert_equal [[2,'test',{'uga'=>'booga','foo'=>'bar'}],[3,'fixnum',{}],[6,'fixnum',{}]],
84
+ @xp.callbacks.test[:startel]
85
+ assert_equal [[4,'one'],[7,'two'],[9,"\n "],[11,"\n "],[13,"\n "],[15,"\n"]],
86
+ @xp.callbacks.test[:chars]
87
+ assert_equal [[10, ' msg ']], @xp.callbacks.test[:comment]
88
+ assert_equal [[12, 'custom', 'foo="bar"']], @xp.callbacks.test[:pinstr]
89
+ assert_equal [[14, 'here it goes']], @xp.callbacks.test[:cdata]
90
+ assert_equal [[5,'fixnum'],[8,'fixnum'],[16,'test']], @xp.callbacks.test[:endel]
91
+ assert_equal [17], @xp.callbacks.test[:enddoc]
92
+ end
93
+
94
+ def test_doctype
95
+ @xp.callbacks = TestCaseCallbacks.new
96
+ @xp.string = <<-EOS
97
+ <?xml version="1.0" encoding="UTF-8"?>
98
+ <!DOCTYPE ONIXmessage SYSTEM "http://www.editeur.org/onix/2.1/short/onix-international.dtd">
99
+ <ONIXmessage release="2.1">
100
+ </ONIXmessage>
101
+ EOS
102
+ @xp.parse
103
+ end
104
+ end # TC_XML_Sax_Parser
@@ -0,0 +1,51 @@
1
+ require 'libxml'
2
+ require 'test/unit'
3
+
4
+ # TODO this is woefully inadequate
5
+
6
+ class TC_XML_SaxParser2 < Test::Unit::TestCase
7
+ def setup()
8
+ @xp = XML::SaxParser.new
9
+ end
10
+
11
+ def teardown()
12
+ @xp = nil
13
+ end
14
+
15
+ def test_string_without_callbacks
16
+ @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
17
+ assert_equal true, @xp.parse
18
+ end
19
+
20
+ def test_file_without_callbacks
21
+ @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
22
+ assert_equal true, @xp.parse
23
+ end
24
+
25
+ def test_callbacks_with_string
26
+ @xp.callbacks = TestCaseCallbacks.new
27
+ @xp.string = File.read(File.join(File.dirname(__FILE__), 'model/saxtest.xml'))
28
+ do_test
29
+ end
30
+
31
+ def test_callbacks_with_file
32
+ @xp.callbacks = TestCaseCallbacks.new
33
+ @xp.filename = File.join(File.dirname(__FILE__), 'model/saxtest.xml')
34
+ do_test
35
+ end
36
+
37
+ def do_test
38
+ @xp.parse
39
+
40
+ assert_equal [1], @xp.callbacks.test[:startdoc]
41
+ assert_equal [[2,'test',{'uga'=>'booga','foo'=>'bar'}],[3,'fixnum',{}],[6,'fixnum',{}]],
42
+ @xp.callbacks.test[:startel]
43
+ assert_equal [[4,'one'],[7,'two'],[9,"\n "],[11,"\n "],[13,"\n "],[15,"\n"]],
44
+ @xp.callbacks.test[:chars]
45
+ assert_equal [[10, ' msg ']], @xp.callbacks.test[:comment]
46
+ assert_equal [[12, 'custom', 'foo="bar"']], @xp.callbacks.test[:pinstr]
47
+ assert_equal [[14, 'here it goes']], @xp.callbacks.test[:cdata]
48
+ assert_equal [[5,'fixnum'],[8,'fixnum'],[16,'test']], @xp.callbacks.test[:endel]
49
+ assert_equal [17], @xp.callbacks.test[:enddoc]
50
+ end
51
+ end # TC_XML_Sax_Parser
@@ -1,30 +1,30 @@
1
- require "libxml"
2
- require 'test/unit'
3
-
4
- class TC_XML_XInclude < Test::Unit::TestCase
5
- def setup()
6
- @doc = XML::Document.file('test/model/xinclude.xml')
7
- assert_instance_of(XML::Document, @doc)
8
- end
9
-
10
- def teardown()
11
- @doc = nil
12
- end
13
-
14
- def test_ruby_xml_xinclude()
15
- xinclude_doc = "<?xml version=\"1.0\"?>\n<document xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n"
16
- xinclude_doc << " <p>This libxml2 binding has the following project information:\n <code>"
17
- msg = ''
18
- File.open('test/model/rubynet_project') do |f|
19
- for line in f
20
- msg << line
21
- end
22
- end
23
- xinclude_doc << msg << "</code></p>\n</document>\n"
24
-
25
- ret = @doc.xinclude
26
- assert_equal(1, ret)
27
- assert_equal(xinclude_doc, @doc.to_s)
28
- end
29
- end
30
-
1
+ require "libxml"
2
+ require 'test/unit'
3
+
4
+ class TC_XML_XInclude < Test::Unit::TestCase
5
+ def setup()
6
+ @doc = XML::Document.file('model/xinclude.xml')
7
+ assert_instance_of(XML::Document, @doc)
8
+ end
9
+
10
+ def teardown()
11
+ @doc = nil
12
+ end
13
+
14
+ def test_ruby_xml_xinclude()
15
+ xinclude_doc = "<?xml version=\"1.0\"?>\n<document xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n"
16
+ xinclude_doc << " <p>This libxml2 binding has the following project information:\n <code>"
17
+ msg = ''
18
+ File.open('model/rubynet_project') do |f|
19
+ for line in f
20
+ msg << line
21
+ end
22
+ end
23
+ xinclude_doc << msg << "</code></p>\n</document>\n"
24
+
25
+ ret = @doc.xinclude
26
+ assert_equal(1, ret)
27
+ assert_equal(xinclude_doc, @doc.to_s)
28
+ end
29
+ end
30
+
data/test/tc_xml_xpath.rb CHANGED
@@ -1,38 +1,38 @@
1
- require "libxml"
2
- require "test/unit"
3
-
4
- class TC_XML_XPath < Test::Unit::TestCase
5
- def setup()
6
- xp = XML::Parser.new()
7
- str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
8
- assert_equal(str, xp.string = str)
9
- doc = xp.parse
10
- assert_instance_of(XML::Document, doc)
11
- @xpt = doc.find('/ruby_array/fixnum')
12
- assert_instance_of(XML::XPath::Object, @xpt)
13
- end
14
-
15
- def teardown()
16
- @xpt = nil
17
- end
18
-
19
- def test_libxml_xpath_set()
20
- set = @xpt.set
21
- assert_instance_of(XML::Node::Set, set)
22
- end
23
-
24
- def test_ary()
25
- assert_equal(2,@xpt.length)
26
- assert_equal("one",@xpt.first.content)
27
- assert_equal("one",@xpt[0].content)
28
- assert_equal("two",@xpt[1].content)
29
- assert_equal("two",@xpt[-1].content)
30
- assert_equal(nil,@xpt[-3])
31
- assert_equal(nil,@xpt[2])
32
-
33
- @xpt.inject(%w(one two).reverse) {|m,v|
34
- assert_equal(m.pop,v.content)
35
- m
36
- }
37
- end
38
- end # TC_XML_Document
1
+ require "libxml"
2
+ require "test/unit"
3
+
4
+ class TC_XML_XPath < Test::Unit::TestCase
5
+ def setup()
6
+ xp = XML::Parser.new()
7
+ str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
8
+ assert_equal(str, xp.string = str)
9
+ doc = xp.parse
10
+ assert_instance_of(XML::Document, doc)
11
+ @xpt = doc.find('/ruby_array/fixnum')
12
+ assert_instance_of(XML::XPath::Object, @xpt)
13
+ end
14
+
15
+ def teardown()
16
+ @xpt = nil
17
+ end
18
+
19
+ def test_libxml_xpath_set()
20
+ set = @xpt.set
21
+ assert_instance_of(XML::Node::Set, set)
22
+ end
23
+
24
+ def test_ary()
25
+ assert_equal(2,@xpt.length)
26
+ assert_equal("one",@xpt.first.content)
27
+ assert_equal("one",@xpt[0].content)
28
+ assert_equal("two",@xpt[1].content)
29
+ assert_equal("two",@xpt[-1].content)
30
+ assert_equal(nil,@xpt[-3])
31
+ assert_equal(nil,@xpt[2])
32
+
33
+ @xpt.inject(%w(one two).reverse) {|m,v|
34
+ assert_equal(m.pop,v.content)
35
+ m
36
+ }
37
+ end
38
+ end # TC_XML_Document
@@ -0,0 +1,14 @@
1
+ require "libxml"
2
+ require "test/unit"
3
+ require "tempfile"
4
+
5
+ class TC_XML_XPath2 < Test::Unit::TestCase
6
+ def test_custom_xpath_function
7
+ xml = Tempfile.new("xxx")
8
+ xml.puts("<a/>")
9
+ xml.close
10
+
11
+ doc = XML::Document.file(xml.path)
12
+ assert_nil(doc.find("//*[name(.)=normalize_space(' a ')]"))
13
+ end
14
+ end
@@ -1,78 +1,78 @@
1
- require "libxml"
2
- require "test/unit"
3
-
4
- class TC_XML_XPointer < Test::Unit::TestCase
5
- def setup()
6
- xp = XML::Parser.new()
7
- str = '<!DOCTYPE ra [<!ELEMENT ra (foo+)><!ATTLIST ra id ID #IMPLIED><!ELEMENT foo (#PCDATA)><!ATTLIST foo id ID #IMPLIED>]><ra id="start"><foo id="one">one</foo><foo id="two">two</foo><foo id="three">three</foo></ra>'
8
- assert_equal(str, xp.string = str)
9
- @doc = xp.parse
10
- assert_instance_of(XML::Document, @doc)
11
- @root = @doc.root
12
- assert_instance_of(XML::Node, @root)
13
- end
14
-
15
- def teardown()
16
- @doc = nil
17
- @root = nil
18
- @xptr = nil
19
- end
20
-
21
- def test_libxml_xpointer_id()
22
- @xptr = @root.pointer('xpointer(id("two"))')
23
- assert_instance_of(XML::XPath::Object, @xptr)
24
- set = @xptr.set
25
- assert_instance_of(XML::Node::Set, set)
26
- for n in set
27
- # It seems from the spec that the pointer should
28
- # be the whole node, rather than just the ID attr.
29
-
30
- # assert_equal('two', n.to_s)
31
-
32
- assert_instance_of(XML::Node, n)
33
- assert_equal('two', n['id'])
34
- end
35
-
36
- # FIXME: Not sure at all about this kind of range
37
- if ENV['NOTWORKING']
38
- @xptr = @root.pointer('xpointer(id("two")) xpointer(id("three"))')
39
- assert_instance_of(XML::XPath, @xptr)
40
- assert_instance_of(XML::Node::Set, @xptr.set)
41
- assert_equal(2, @xptr.set.length)
42
- for n in @xptr.set
43
- assert_match(/two|three/, n.to_s)
44
- end
45
- end
46
- end
47
-
48
- # FIXME: There is a bug in these ranges...
49
- if ENV['NOTWORKING']
50
- def test_libxml_xpointer_range()
51
- nstart = nend = nil
52
- @xptr = @root.pointer('xpointer(id("one"))').set
53
- @xptr.each{|n| nstart = n}
54
- assert_instance_of(XML::Node, nstart)
55
- @xptr = @root.pointer('xpointer(id("three"))').set
56
- @xptr.each{|n| nend = n}
57
- assert_instance_of(XML::Node, nend)
58
- range = XML::XPointer.range(nstart, nend)
59
- assert_instance_of(XML::XPath, range)
60
- assert_instance_of(XML::Node::Set, range.set)
61
-
62
- for n in range.set
63
- assert_match(/one|two|three/, n.to_s)
64
- end
65
- assert_equal(3, range.set.length)
66
- end
67
- end
68
-
69
- # def test_libxml_xpointer_start_point()
70
- # @xptr = @root.pointer('xpointer(start-point("one"))')
71
- # assert_instance_of(XML::XPath, @xptr)
72
- # set = @xptr.set
73
- # assert_instance_of(XML::Node::Set, set)
74
- # for n in set
75
- # assert_match(/one|two|three/, n.to_s)
76
- # end
77
- # end
78
- end
1
+ require "libxml"
2
+ require "test/unit"
3
+
4
+ class TC_XML_XPointer < Test::Unit::TestCase
5
+ def setup()
6
+ xp = XML::Parser.new()
7
+ str = '<!DOCTYPE ra [<!ELEMENT ra (foo+)><!ATTLIST ra id ID #IMPLIED><!ELEMENT foo (#PCDATA)><!ATTLIST foo id ID #IMPLIED>]><ra id="start"><foo id="one">one</foo><foo id="two">two</foo><foo id="three">three</foo></ra>'
8
+ assert_equal(str, xp.string = str)
9
+ @doc = xp.parse
10
+ assert_instance_of(XML::Document, @doc)
11
+ @root = @doc.root
12
+ assert_instance_of(XML::Node, @root)
13
+ end
14
+
15
+ def teardown()
16
+ @doc = nil
17
+ @root = nil
18
+ @xptr = nil
19
+ end
20
+
21
+ def test_libxml_xpointer_id()
22
+ @xptr = @root.pointer('xpointer(id("two"))')
23
+ assert_instance_of(XML::XPath::Object, @xptr)
24
+ set = @xptr.set
25
+ assert_instance_of(XML::Node::Set, set)
26
+ for n in set
27
+ # It seems from the spec that the pointer should
28
+ # be the whole node, rather than just the ID attr.
29
+
30
+ # assert_equal('two', n.to_s)
31
+
32
+ assert_instance_of(XML::Node, n)
33
+ assert_equal('two', n['id'])
34
+ end
35
+
36
+ # FIXME: Not sure at all about this kind of range
37
+ if ENV['NOTWORKING']
38
+ @xptr = @root.pointer('xpointer(id("two")) xpointer(id("three"))')
39
+ assert_instance_of(XML::XPath, @xptr)
40
+ assert_instance_of(XML::Node::Set, @xptr.set)
41
+ assert_equal(2, @xptr.set.length)
42
+ for n in @xptr.set
43
+ assert_match(/two|three/, n.to_s)
44
+ end
45
+ end
46
+ end
47
+
48
+ # FIXME: There is a bug in these ranges...
49
+ if ENV['NOTWORKING']
50
+ def test_libxml_xpointer_range()
51
+ nstart = nend = nil
52
+ @xptr = @root.pointer('xpointer(id("one"))').set
53
+ @xptr.each{|n| nstart = n}
54
+ assert_instance_of(XML::Node, nstart)
55
+ @xptr = @root.pointer('xpointer(id("three"))').set
56
+ @xptr.each{|n| nend = n}
57
+ assert_instance_of(XML::Node, nend)
58
+ range = XML::XPointer.range(nstart, nend)
59
+ assert_instance_of(XML::XPath, range)
60
+ assert_instance_of(XML::Node::Set, range.set)
61
+
62
+ for n in range.set
63
+ assert_match(/one|two|three/, n.to_s)
64
+ end
65
+ assert_equal(3, range.set.length)
66
+ end
67
+ end
68
+
69
+ # def test_libxml_xpointer_start_point()
70
+ # @xptr = @root.pointer('xpointer(start-point("one"))')
71
+ # assert_instance_of(XML::XPath, @xptr)
72
+ # set = @xptr.set
73
+ # assert_instance_of(XML::Node::Set, set)
74
+ # for n in set
75
+ # assert_match(/one|two|three/, n.to_s)
76
+ # end
77
+ # end
78
+ end
data/vc/libxml.sln ADDED
@@ -0,0 +1,20 @@
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 9.00
3
+ # Visual Studio 2005
4
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml", "libxml.vcproj", "{6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}"
5
+ EndProject
6
+ Global
7
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
8
+ Debug|Win32 = Debug|Win32
9
+ Release|Win32 = Release|Win32
10
+ EndGlobalSection
11
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
12
+ {6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Debug|Win32.ActiveCfg = Debug|Win32
13
+ {6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Debug|Win32.Build.0 = Debug|Win32
14
+ {6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Release|Win32.ActiveCfg = Release|Win32
15
+ {6DCFD1E6-224E-479C-BBD9-B6931DFCD02C}.Release|Win32.Build.0 = Release|Win32
16
+ EndGlobalSection
17
+ GlobalSection(SolutionProperties) = preSolution
18
+ HideSolutionNode = FALSE
19
+ EndGlobalSection
20
+ EndGlobal