libxml-ruby 0.6.0-x86-mswin32-60

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 (127) hide show
  1. data/CHANGES +122 -0
  2. data/LICENSE +23 -0
  3. data/README +144 -0
  4. data/ext/libxml/cbg.c +76 -0
  5. data/ext/libxml/extconf.rb +308 -0
  6. data/ext/libxml/libxml.c +62 -0
  7. data/ext/libxml/ruby_libxml.h +93 -0
  8. data/ext/libxml/ruby_xml_attr.c +405 -0
  9. data/ext/libxml/ruby_xml_attr.h +19 -0
  10. data/ext/libxml/ruby_xml_document.c +1111 -0
  11. data/ext/libxml/ruby_xml_document.h +27 -0
  12. data/ext/libxml/ruby_xml_dtd.c +168 -0
  13. data/ext/libxml/ruby_xml_dtd.h +17 -0
  14. data/ext/libxml/ruby_xml_html_parser.c +449 -0
  15. data/ext/libxml/ruby_xml_html_parser.h +29 -0
  16. data/ext/libxml/ruby_xml_input_cbg.c +158 -0
  17. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  18. data/ext/libxml/ruby_xml_node.c +2410 -0
  19. data/ext/libxml/ruby_xml_node.h +27 -0
  20. data/ext/libxml/ruby_xml_node_set.c +170 -0
  21. data/ext/libxml/ruby_xml_node_set.h +20 -0
  22. data/ext/libxml/ruby_xml_ns.c +153 -0
  23. data/ext/libxml/ruby_xml_ns.h +21 -0
  24. data/ext/libxml/ruby_xml_parser.c +1425 -0
  25. data/ext/libxml/ruby_xml_parser.h +31 -0
  26. data/ext/libxml/ruby_xml_parser_context.c +750 -0
  27. data/ext/libxml/ruby_xml_parser_context.h +22 -0
  28. data/ext/libxml/ruby_xml_reader.c +900 -0
  29. data/ext/libxml/ruby_xml_reader.h +14 -0
  30. data/ext/libxml/ruby_xml_sax_parser.c +485 -0
  31. data/ext/libxml/ruby_xml_sax_parser.h +56 -0
  32. data/ext/libxml/ruby_xml_schema.c +146 -0
  33. data/ext/libxml/ruby_xml_schema.h +16 -0
  34. data/ext/libxml/ruby_xml_state.c +113 -0
  35. data/ext/libxml/ruby_xml_state.h +12 -0
  36. data/ext/libxml/ruby_xml_tree.c +43 -0
  37. data/ext/libxml/ruby_xml_tree.h +12 -0
  38. data/ext/libxml/ruby_xml_xinclude.c +20 -0
  39. data/ext/libxml/ruby_xml_xinclude.h +13 -0
  40. data/ext/libxml/ruby_xml_xpath.c +243 -0
  41. data/ext/libxml/ruby_xml_xpath.h +23 -0
  42. data/ext/libxml/ruby_xml_xpath_context.c +118 -0
  43. data/ext/libxml/ruby_xml_xpath_context.h +20 -0
  44. data/ext/libxml/ruby_xml_xpath_object.c +293 -0
  45. data/ext/libxml/ruby_xml_xpath_object.h +28 -0
  46. data/ext/libxml/ruby_xml_xpointer.c +100 -0
  47. data/ext/libxml/ruby_xml_xpointer.h +27 -0
  48. data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
  49. data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
  50. data/ext/libxml/sax_parser_callbacks.inc +213 -0
  51. data/ext/libxml/version.h +9 -0
  52. data/lib/libxml.rb +125 -0
  53. data/lib/libxml_ruby.so +0 -0
  54. data/lib/xml/libxml.rb +5 -0
  55. data/mingw/libiconv-2.dll +0 -0
  56. data/mingw/libxml2-2.dll +0 -0
  57. data/mingw/libxml_ruby.so +0 -0
  58. data/mingw/mingw.rake +36 -0
  59. data/test/dtd-test.rb +24 -0
  60. data/test/etc_doc_to_s.rb +19 -0
  61. data/test/ets_copy_bug.rb +21 -0
  62. data/test/ets_copy_bug2.rb +32 -0
  63. data/test/ets_copy_bug3.rb +38 -0
  64. data/test/ets_doc_file.rb +15 -0
  65. data/test/ets_doc_to_s.rb +21 -0
  66. data/test/ets_gpx.rb +26 -0
  67. data/test/ets_node_gc.rb +21 -0
  68. data/test/ets_test.xml +2 -0
  69. data/test/ets_tsr.rb +9 -0
  70. data/test/gc.log +0 -0
  71. data/test/merge_bug.rb +55 -0
  72. data/test/schema-test.rb +74 -0
  73. data/test/tc_well_formed.rb +11 -0
  74. data/test/tc_xml_document.rb +52 -0
  75. data/test/tc_xml_document_write.rb +24 -0
  76. data/test/tc_xml_document_write2.rb +54 -0
  77. data/test/tc_xml_document_write3.rb +96 -0
  78. data/test/tc_xml_html_parser.rb +63 -0
  79. data/test/tc_xml_node.rb +59 -0
  80. data/test/tc_xml_node2.rb +25 -0
  81. data/test/tc_xml_node3.rb +27 -0
  82. data/test/tc_xml_node4.rb +86 -0
  83. data/test/tc_xml_node5.rb +52 -0
  84. data/test/tc_xml_node6.rb +27 -0
  85. data/test/tc_xml_node7.rb +35 -0
  86. data/test/tc_xml_node8.rb +32 -0
  87. data/test/tc_xml_node9.rb +32 -0
  88. data/test/tc_xml_node_copy.rb +40 -0
  89. data/test/tc_xml_node_set.rb +24 -0
  90. data/test/tc_xml_node_set2.rb +37 -0
  91. data/test/tc_xml_node_text.rb +17 -0
  92. data/test/tc_xml_node_xlink.rb +28 -0
  93. data/test/tc_xml_parser.rb +190 -0
  94. data/test/tc_xml_parser2.rb +16 -0
  95. data/test/tc_xml_parser3.rb +23 -0
  96. data/test/tc_xml_parser4.rb +33 -0
  97. data/test/tc_xml_parser5.rb +27 -0
  98. data/test/tc_xml_parser6.rb +23 -0
  99. data/test/tc_xml_parser7.rb +28 -0
  100. data/test/tc_xml_parser8.rb +32 -0
  101. data/test/tc_xml_parser9.rb +11 -0
  102. data/test/tc_xml_parser_context.rb +88 -0
  103. data/test/tc_xml_reader.rb +112 -0
  104. data/test/tc_xml_sax_parser.rb +104 -0
  105. data/test/tc_xml_sax_parser2.rb +51 -0
  106. data/test/tc_xml_xinclude.rb +30 -0
  107. data/test/tc_xml_xpath.rb +38 -0
  108. data/test/tc_xml_xpath2.rb +14 -0
  109. data/test/tc_xml_xpointer.rb +78 -0
  110. data/vc/libxml.sln +20 -0
  111. data/vc/libxml.vcproj +389 -0
  112. data/work/Rakefile +247 -0
  113. data/work/task/make +26 -0
  114. data/work/task/memory +37 -0
  115. data/work/task/rdoc +39 -0
  116. data/work/task/setup +1616 -0
  117. data/work/task/test +29 -0
  118. data/work/test/ets_runner.rb +33 -0
  119. data/work/test/libxml_test.rb +3 -0
  120. data/work/test/runner.rb +0 -0
  121. data/work/test/runner_ets.rb +33 -0
  122. data/work/vc/debug/libxml.exp +0 -0
  123. data/work/vc/debug/libxml.ilk +0 -0
  124. data/work/vc/debug/libxml.lib +0 -0
  125. data/work/vc/debug/libxml.pdb +0 -0
  126. data/work/vc/debug/libxml.so +0 -0
  127. metadata +224 -0
Binary file
data/lib/xml/libxml.rb ADDED
@@ -0,0 +1,5 @@
1
+ # This is here for backward compatibility.
2
+ # Ultimately we can deprecate it.
3
+
4
+ require 'libxml.rb'
5
+
Binary file
Binary file
Binary file
data/mingw/mingw.rake ADDED
@@ -0,0 +1,36 @@
1
+ # We can't use Ruby's standard build procedures
2
+ # on Windows because the Ruby executable is
3
+ # built with VC++ while here we want to build
4
+ # with MingW. So just roll our own...
5
+
6
+ require 'rake/clean'
7
+ require 'rbconfig'
8
+
9
+ RUBY_INCLUDE_DIR = Config::CONFIG["archdir"]
10
+ RUBY_BIN_DIR = Config::CONFIG["bindir"]
11
+ RUBY_LIB_DIR = Config::CONFIG["libdir"]
12
+ RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"]
13
+ RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll')
14
+
15
+ CLEAN.include('*.o')
16
+ CLOBBER.include('libxml.so')
17
+
18
+ task :default => "libxml"
19
+
20
+ SRC = FileList['../ext/libxml/*.c']
21
+ OBJ = SRC.collect do |file_name|
22
+ File.basename(file_name).ext('o')
23
+ end
24
+
25
+ SRC.each do |srcfile|
26
+ objfile = File.basename(srcfile).ext('o')
27
+ file objfile => srcfile do
28
+ command = "gcc -c -fPIC -O2 -Wall -o #{objfile} -I/usr/local/include #{srcfile} -I#{RUBY_INCLUDE_DIR}"
29
+ sh "sh -c '#{command}'"
30
+ end
31
+ end
32
+
33
+ file "libxml" => OBJ do
34
+ command = "libtool --mode=link gcc -shared -o libxml_ruby.so -L/usr/local/lib -lxml2 #{OBJ} #{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}"
35
+ sh "sh -c '#{command}'"
36
+ end
data/test/dtd-test.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "libxml"
2
+
3
+ xp = XML::Parser.new
4
+ xp.string = '<?xml version="1.0" encoding="utf-8"?>
5
+ <root><head a="ee" id="1">ass<buzz/></head><descr>really big ass</descr></root>'
6
+
7
+ doc = xp.parse
8
+
9
+ dtd = XML::Dtd.new('
10
+ <!ELEMENT root (head, descr)>
11
+ <!ELEMENT head (#PCDATA)>
12
+ <!ATTLIST head
13
+ id NMTOKEN #REQUIRED
14
+ a CDATA #IMPLIED
15
+ >
16
+ <!ELEMENT descr (#PCDATA)>
17
+ ')
18
+
19
+ if doc.validate(dtd) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
20
+ puts "validation passed"
21
+ else
22
+ puts "validation failed"
23
+ end
24
+
@@ -0,0 +1,19 @@
1
+ require 'libxml'
2
+
3
+ 1.times do |count|
4
+
5
+ xml_doc = XML::Document.new()
6
+ xml_doc.encoding = "UTF-8"
7
+ xml_doc.root = XML::Node.new("Request")
8
+
9
+ 1000.times do |index|
10
+ xml_doc.root << node = XML::Node.new("row")
11
+ node["user_id"] = index.to_s
12
+ node << "600445"
13
+ end
14
+
15
+ xml_str = xml_doc.to_s
16
+ print "\r#{count}"
17
+ $stdout.flush
18
+ end
19
+ puts "\n"
@@ -0,0 +1,21 @@
1
+ require 'libxml'
2
+
3
+ def test( doc2 )
4
+ doc = XML::Document.new('1.0')
5
+ doc.root = XML::Node.new("ccc")
6
+ doc.root['aaa'] = 'aaa'
7
+ doc.root.child_add(doc2.root) # BUG!
8
+ doc.root << doc2.root.copy(true)
9
+ return doc
10
+ end
11
+
12
+ def test2
13
+ doc2 = XML::Document.new('1.0')
14
+ doc2.root = XML::Node.new("aaa")
15
+ test( doc2 )
16
+ end
17
+
18
+ 1000.times { |i|
19
+ print "\r#{i}"; $stdout.flush
20
+ test2
21
+ }
@@ -0,0 +1,32 @@
1
+ require 'libxml'
2
+
3
+ $FAILS = []
4
+
5
+ def test( doc, doc2, iter )
6
+ doc.root = XML::Node.new("ccc")
7
+ iter.times { |i|
8
+ doc.root.child_add(doc2.root)
9
+ # doc.root << doc2.root.copy(true)
10
+ }
11
+ return doc
12
+ end
13
+
14
+ def test2(iter)
15
+ doc = XML::Document.new('1.0')
16
+ doc2 = XML::Document.new('1.0')
17
+ doc2.root = XML::Node.new("aaa")
18
+ ret = test( doc, doc2, iter )
19
+ li=ret.find('aaa').length
20
+ $FAILS << [li,iter] unless li == iter
21
+ end
22
+
23
+ test2(5)
24
+ 1000.times do |i|
25
+ test2(i)
26
+ print "\r#{i}"; $stdout.flush
27
+ end
28
+
29
+ puts "\n#{$FAILS.length} failures"
30
+ p $FAILS
31
+
32
+
@@ -0,0 +1,38 @@
1
+ require 'libxml'
2
+
3
+ str = <<-STR
4
+ <html>
5
+ <body>
6
+ <div class="textarea" id="t1"
7
+ style="STATIC">werwerwerwerwer </div>
8
+ <div class="textarea" id="t2" style="STATIC">
9
+ Quisque et diam dapibus nisi bibendum blandit.
10
+ </div>
11
+ <div class="textarea" id="t3" style="STATIC">
12
+ <p>aaaaaaaaa</p>
13
+ </div>
14
+ </body>
15
+ </html>
16
+ STR
17
+
18
+ XML::Parser.default_keep_blanks = false
19
+ xp = XML::Parser.new
20
+ xp.string = str
21
+ doc = xp.parse
22
+
23
+ xpath = "//div[@id='t1']"
24
+ div1 = doc.find(xpath).to_a[0]
25
+ printf "xxx div1: #{div1}\n"
26
+
27
+ xpath = "//div[@id='t2']"
28
+ div2 = doc.find(xpath).to_a[0]
29
+ printf "xxx div2: #{div2}\n"
30
+
31
+
32
+ div2.each do |child|
33
+ #c = child.clone
34
+ c = child.copy(false)
35
+ div1.child_add(c)
36
+ end
37
+
38
+ printf "xxx root: #{doc.root}\n"
@@ -0,0 +1,15 @@
1
+ require 'libxml'
2
+
3
+ # This is related to bug 8337, complaint is on amd64/fbsd
4
+ # unknown if it happens on other amd64/os combos
5
+
6
+ Process.setrlimit(Process::RLIMIT_NOFILE,10005)
7
+
8
+ (1..10000).each{|time|
9
+ XML::Document.file(File.join(File.dirname(__FILE__),'ets_test.xml'))
10
+ if time % 100 == 0
11
+ print "\r#{time}"
12
+ $stdout.flush
13
+ end
14
+ }
15
+ puts "\n"
@@ -0,0 +1,21 @@
1
+ require 'libxml'
2
+
3
+ 1000.times do |count|
4
+
5
+ xml_doc = XML::Document.new()
6
+ xml_doc.encoding = "UTF-8"
7
+ xml_doc.root = XML::Node.new("Request")
8
+
9
+ 1000.times do |index|
10
+
11
+ xml_doc.root << node = XML::Node.new("row")
12
+ node["user_id"] = index.to_s
13
+ node << "600445"
14
+
15
+ end
16
+
17
+ xml_str = xml_doc.to_s
18
+ print "\r#{count}"
19
+ $stdout.flush
20
+ end
21
+ puts "\n"
data/test/ets_gpx.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'libxml'
2
+
3
+ 100.times do
4
+ doc = XML::Document.new
5
+ doc.encoding = 'UTF-8'
6
+
7
+ root = XML::Node.new 'gpx'
8
+ root['version'] = '1.0'
9
+ root['creator'] = 'OpenStreetMap.org'
10
+ root['xmlns'] = "http://www.topografix.com/GPX/1/0/"
11
+
12
+ doc.root = root
13
+
14
+ track = XML::Node.new 'trk'
15
+ doc.root << track
16
+
17
+ trkseg = XML::Node.new 'trkseg'
18
+ track << trkseg
19
+
20
+ 1.upto(10000) do |n|
21
+ trkpt = XML::Node.new 'trkpt'
22
+ trkpt['lat'] = n.to_s
23
+ trkpt['lon'] = n.to_s
24
+ trkseg << trkpt
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'libxml'
2
+
3
+ # test of bug 13310, clears MEM2
4
+
5
+ include GC
6
+
7
+ inner = XML::Node.new('inner')
8
+ save = nil
9
+ 1.times do
10
+ outer = XML::Node.new('outer')
11
+ outer.child = inner
12
+ 1.times do
13
+ doc = XML::Document.new
14
+ doc.root = outer
15
+ # Uncomment the following line and it won't crash
16
+ # save = doc
17
+ end
18
+ garbage_collect
19
+ end
20
+ garbage_collect
21
+ puts inner
data/test/ets_test.xml ADDED
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0"?>
2
+ <test/>
data/test/ets_tsr.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'libxml'
2
+
3
+ 1_000_000.times {|n|
4
+ j=XML::Node.new2(nil,"happy#{n}")
5
+ 10.times {|r|
6
+ j1=XML::Node.new("happy#{r}","farts")
7
+ j.child=j1
8
+ }
9
+ }
data/test/gc.log ADDED
File without changes
data/test/merge_bug.rb ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require 'libxml'
4
+
5
+ class XML::Node
6
+ def first_child_element
7
+ result = nil
8
+ if self.children?
9
+ self.each_child{|node_child| result = node_child if ((result.nil?) && node_child.element?) }
10
+ end
11
+ result
12
+ end
13
+ end
14
+
15
+ #
16
+ # Method which generates crash
17
+ #
18
+ def merge(forms)
19
+ starting_form = forms.shift
20
+ forms.inject(starting_form) do |master_form,form|
21
+ master_form.find("//body").first << form.find("//body").first.first_child_element
22
+ master_form
23
+ end
24
+ end
25
+
26
+ #
27
+ # Run
28
+ # Must tell it how many times to merge a document
29
+ # On my linux box, it takes about 350 to crash it
30
+ # On my OS X box, it takes about 150
31
+ #
32
+
33
+ if (ARGV[0].to_i > 0)
34
+ count = ARGV[0].to_i
35
+ else
36
+ count = 500
37
+ end
38
+
39
+
40
+ merge_list = []
41
+
42
+ count.times do
43
+ merge_list << XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
44
+ end
45
+
46
+ result = merge(merge_list)
47
+ puts "Merged!"
48
+
49
+ #File.open(File.join(File.dirname(__FILE__), 'model', '/generated_form.xml'), "w") do |f|
50
+ # puts "Trying to write to file"
51
+ # f << result
52
+ # puts "After trying to write to file"
53
+ #end
54
+
55
+ puts "nothing left to do but print this message"
@@ -0,0 +1,74 @@
1
+ require "libxml"
2
+
3
+ xp = XML::Parser.new
4
+ xp.string = '<?xml version="1.0" encoding="utf-8"?>
5
+
6
+ <shiporder orderid="889923"
7
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8
+ xsi:noNamespaceSchemaLocation="shiporder.xsd">
9
+ <orderperson>John Smith</orderperson>
10
+ <shipto>
11
+ <name>Ola Nordmann</name>
12
+ <address>Langgt 23</address>
13
+ <city>4000 Stavanger</city>
14
+ <country>Norway</country>
15
+ </shipto>
16
+ <item>
17
+ <title>Empire Burlesque</title>
18
+ <note>Special Edition</note>
19
+ <quantity>1</quantity>
20
+ <price>10.90</price>
21
+ </item>
22
+ <item>
23
+ <title>Hide your heart</title>
24
+ <quantity>1</quantity>
25
+ <price>9.90</price>
26
+ </item>
27
+ </shiporder>
28
+ '
29
+
30
+ doc = xp.parse
31
+
32
+ schema = XML::Schema.from_string('<?xml version="1.0" encoding="ISO-8859-1" ?>
33
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
34
+
35
+ <xs:element name="shiporder">
36
+ <xs:complexType>
37
+ <xs:sequence>
38
+ <xs:element name="orderperson" type="xs:string"/>
39
+ <xs:element name="shipto">
40
+ <xs:complexType>
41
+ <xs:sequence>
42
+ <xs:element name="name" type="xs:string"/>
43
+ <xs:element name="address" type="xs:string"/>
44
+ <xs:element name="city" type="xs:string"/>
45
+ <xs:element name="country" type="xs:string"/>
46
+ </xs:sequence>
47
+ </xs:complexType>
48
+ </xs:element>
49
+ <xs:element name="item" maxOccurs="unbounded">
50
+ <xs:complexType>
51
+ <xs:sequence>
52
+ <xs:element name="title" type="xs:string"/>
53
+ <xs:element name="note" type="xs:string" minOccurs="0"/>
54
+ <xs:element name="quantity" type="xs:positiveInteger"/>
55
+ <xs:element name="price" type="xs:decimal"/>
56
+ </xs:sequence>
57
+ </xs:complexType>
58
+ </xs:element>
59
+ </xs:sequence>
60
+ <xs:attribute name="orderid" type="xs:string" use="required"/>
61
+ </xs:complexType>
62
+ </xs:element>
63
+
64
+ </xs:schema>
65
+ ')
66
+
67
+ p schema
68
+
69
+ if doc.validate_schema(schema) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
70
+ puts "validation passed"
71
+ else
72
+ puts "validation failed"
73
+ end
74
+
@@ -0,0 +1,11 @@
1
+ require "libxml"
2
+ require 'test/unit'
3
+
4
+ class TC_WELL_FORMED < Test::Unit::TestCase
5
+ def test_xml_node_doc_get()
6
+ parser = XML::Parser.new
7
+ parser.string = "<p>I am well formed</p>"
8
+ assert(parser.context.well_formed?)
9
+ end
10
+ end
11
+