mame-xmlparser 0.6.81.1

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 (119) hide show
  1. data/Encodings/README.ja +18 -0
  2. data/Encodings/euc-jp.enc +0 -0
  3. data/Encodings/shift_jis.enc +0 -0
  4. data/History.txt +5 -0
  5. data/Manifest.txt +118 -0
  6. data/README +697 -0
  7. data/README.ja +789 -0
  8. data/README.txt +49 -0
  9. data/Rakefile +30 -0
  10. data/ext/encoding.h +91 -0
  11. data/ext/extconf.rb +58 -0
  12. data/ext/xmlparser.c +2231 -0
  13. data/lib/sax.rb +1 -0
  14. data/lib/saxdriver.rb +1 -0
  15. data/lib/wget.rb +47 -0
  16. data/lib/xml/dom/builder-ja.rb +58 -0
  17. data/lib/xml/dom/builder.rb +310 -0
  18. data/lib/xml/dom/core.rb +3276 -0
  19. data/lib/xml/dom/digest.rb +94 -0
  20. data/lib/xml/dom/visitor.rb +182 -0
  21. data/lib/xml/dom2/attr.rb +213 -0
  22. data/lib/xml/dom2/cdatasection.rb +76 -0
  23. data/lib/xml/dom2/characterdata.rb +177 -0
  24. data/lib/xml/dom2/comment.rb +81 -0
  25. data/lib/xml/dom2/core.rb +19 -0
  26. data/lib/xml/dom2/document.rb +317 -0
  27. data/lib/xml/dom2/documentfragment.rb +82 -0
  28. data/lib/xml/dom2/documenttype.rb +102 -0
  29. data/lib/xml/dom2/dombuilder.rb +277 -0
  30. data/lib/xml/dom2/dombuilderfilter.rb +12 -0
  31. data/lib/xml/dom2/domentityresolver.rb +13 -0
  32. data/lib/xml/dom2/domentityresolverimpl.rb +37 -0
  33. data/lib/xml/dom2/domexception.rb +95 -0
  34. data/lib/xml/dom2/domimplementation.rb +61 -0
  35. data/lib/xml/dom2/dominputsource.rb +29 -0
  36. data/lib/xml/dom2/element.rb +533 -0
  37. data/lib/xml/dom2/entity.rb +110 -0
  38. data/lib/xml/dom2/entityreference.rb +107 -0
  39. data/lib/xml/dom2/namednodemap.rb +138 -0
  40. data/lib/xml/dom2/node.rb +587 -0
  41. data/lib/xml/dom2/nodelist.rb +231 -0
  42. data/lib/xml/dom2/notation.rb +86 -0
  43. data/lib/xml/dom2/processinginstruction.rb +155 -0
  44. data/lib/xml/dom2/text.rb +128 -0
  45. data/lib/xml/dom2/xpath.rb +398 -0
  46. data/lib/xml/encoding-ja.rb +42 -0
  47. data/lib/xml/parser.rb +13 -0
  48. data/lib/xml/parserns.rb +236 -0
  49. data/lib/xml/sax.rb +353 -0
  50. data/lib/xml/saxdriver.rb +370 -0
  51. data/lib/xml/xpath.rb +3284 -0
  52. data/lib/xml/xpath.ry +2352 -0
  53. data/lib/xmldigest.rb +1 -0
  54. data/lib/xmlencoding-ja.rb +11 -0
  55. data/lib/xmltree.rb +1 -0
  56. data/lib/xmltreebuilder-ja.rb +9 -0
  57. data/lib/xmltreebuilder.rb +1 -0
  58. data/lib/xmltreevisitor.rb +1 -0
  59. data/samples/buildertest.rb +47 -0
  60. data/samples/buildertest2.rb +50 -0
  61. data/samples/digesttest.rb +26 -0
  62. data/samples/digesttest2.rb +192 -0
  63. data/samples/doctype.rb +40 -0
  64. data/samples/doctype.xml +21 -0
  65. data/samples/doctypei.rb +19 -0
  66. data/samples/document.dtd +77 -0
  67. data/samples/dom2/dom2test1.rb +7 -0
  68. data/samples/dom2/dom2test2.rb +10 -0
  69. data/samples/dom2/gtkxpath.rb +259 -0
  70. data/samples/dom2/test1.xml +16 -0
  71. data/samples/dom2/test2.xml +7 -0
  72. data/samples/dtd/ext1.dtd +4 -0
  73. data/samples/dtd/ext2.dtd +1 -0
  74. data/samples/dtd/extdtd.rb +34 -0
  75. data/samples/dtd/extdtd.xml +5 -0
  76. data/samples/expat-1.2/CVS/Entries +8 -0
  77. data/samples/expat-1.2/CVS/Repository +1 -0
  78. data/samples/expat-1.2/CVS/Root +1 -0
  79. data/samples/expat-1.2/ext.ent +2 -0
  80. data/samples/expat-1.2/exttest.rb +82 -0
  81. data/samples/expat-1.2/exttesti.rb +81 -0
  82. data/samples/expat-1.2/hoge.dtd +7 -0
  83. data/samples/expat-1.2/idattr.xml +8 -0
  84. data/samples/expat-1.2/idtest.rb +21 -0
  85. data/samples/expat-1.2/idtest.xml +12 -0
  86. data/samples/expat-1.2/xmlextparser.rb +39 -0
  87. data/samples/gtktree.rb +146 -0
  88. data/samples/idattrtest.rb +28 -0
  89. data/samples/index_euc.xml +72 -0
  90. data/samples/index_jis.xml +72 -0
  91. data/samples/index_noenc.xml +71 -0
  92. data/samples/index_sjis.xml +72 -0
  93. data/samples/index_u16.xml +0 -0
  94. data/samples/index_u8.xml +72 -0
  95. data/samples/my-html.rb +65 -0
  96. data/samples/namespaces/CVS/Entries +5 -0
  97. data/samples/namespaces/CVS/Repository +1 -0
  98. data/samples/namespaces/CVS/Root +1 -0
  99. data/samples/namespaces/namespace1.rb +29 -0
  100. data/samples/namespaces/namespace1.xml +10 -0
  101. data/samples/namespaces/namespace2.rb +41 -0
  102. data/samples/namespaces/namespace2.xml +12 -0
  103. data/samples/nstest.rb +21 -0
  104. data/samples/saxtest.rb +70 -0
  105. data/samples/test/featurelist.rb +11 -0
  106. data/samples/test/skippedentity.rb +48 -0
  107. data/samples/test/useforeigndtd.rb +42 -0
  108. data/samples/treetest.rb +14 -0
  109. data/samples/visitor.rb +29 -0
  110. data/samples/visitortest.rb +36 -0
  111. data/samples/writer.rb +43 -0
  112. data/samples/xmlcheck.rb +40 -0
  113. data/samples/xmlcomments.rb +30 -0
  114. data/samples/xmlevent.rb +76 -0
  115. data/samples/xmliter.rb +57 -0
  116. data/samples/xmlstats.rb +167 -0
  117. data/samples/xpointer.rb +233 -0
  118. data/samples/xpointertest.rb +23 -0
  119. metadata +185 -0
@@ -0,0 +1,233 @@
1
+ #! /usr/local/bin/ruby
2
+
3
+ ## XPointer demo for Gtk
4
+ ## 1999 by yoshidam
5
+ ##
6
+ ## Required: ruby-gtk-0.16 (and gtk+-1.0jp)
7
+ ## xmlparser-0.5.7
8
+ ## uconv-0.3.0
9
+
10
+ require 'gtk'
11
+ require 'xml/dom/builder'
12
+ #require 'uconv'
13
+
14
+ ## TREE_MODE = 0: expand entity references, and not create DOCUMENT_TYPE_NODE
15
+ ## TREE_MODE = 1: not expand entity references
16
+ TREE_MODE = 0
17
+ ## enpand tree at the beginning
18
+ EXPAND_TREE = false
19
+ ## trim extra white spaces
20
+ TRIM = true
21
+ ## concatenate folding lines
22
+ UNFOLD = false
23
+ ## parse external entity
24
+ PARSE_EXT = true
25
+
26
+ ## Gtk resources
27
+ #Gtk::RC::parse_string <<EOS
28
+ #style "default" {
29
+ # fontset = "-*-helvetica-medium-r-normal--14-*-*-*-*-*-*-*,\
30
+ # -*-fixed-medium-r-normal--14-*-*-*-*-*-jisx0208.1983-0,*"
31
+ #}
32
+ #widget_class "*" style "default"
33
+ #EOS
34
+
35
+ def unfold(str)
36
+ str.
37
+ gsub(/([��-��])\n\s*([��-��])/, '\1\2').
38
+ gsub(/([a-z])-\n\s+([a-z])/, '\1\2').
39
+ gsub(/\s+/, ' ')
40
+ end
41
+
42
+ module Gtk
43
+ class TreeItem
44
+ attr :xml_node
45
+ alias initialize0 initialize
46
+ def initialize(*arg)
47
+ initialize0(arg[0])
48
+ @xml_node = arg[1]
49
+ end
50
+ end
51
+ end
52
+
53
+ ## Extend the Node class to manipulate the Gtk::Tree
54
+ module XML
55
+ module DOM
56
+ class Node
57
+ ## append a node to Gtk::Tree
58
+ def appendNodeToTree(node)
59
+ if @treeitem.nil?
60
+ raise "Cannot append tree"
61
+ end
62
+ if @tree.nil?
63
+ @tree = Gtk::Tree::new()
64
+ @treeitem.set_subtree(@tree)
65
+ if EXPAND_TREE
66
+ @tree.show
67
+ @treeitem.expand
68
+ end
69
+ end
70
+ @tree.append(node)
71
+ end
72
+
73
+ ## create Gtk::Tree from XML::Node tree
74
+ def newTreeItem(parent = nil)
75
+ if !@treeitem.nil?
76
+ raise "tree item already exist"
77
+ end
78
+
79
+ case self.nodeType
80
+ when TEXT_NODE
81
+ attr = self.parentNode.attributes
82
+ if attr && attr['xml:space'] != 'preserve'
83
+ self.nodeValue = unfold(self.nodeValue) if UNFOLD
84
+ end
85
+ str = "\"" + self.nodeValue + "\""
86
+ when CDATA_SECTION_NODE
87
+ str = "<![CDATA[" + self.nodeValue + "]]>"
88
+ when PROCESSING_INSTRUCTION_NODE
89
+ str = "?" + self.nodeValue
90
+ when ELEMENT_NODE
91
+ attr = ''
92
+ @attr.each do |a| ## self.attributes do |a|
93
+ attr += a.to_s + ", "
94
+ end if @attr
95
+ attr.chop!
96
+ attr.chop!
97
+ str = self.nodeName
98
+ if (attr != '');
99
+ str += " (" + attr + ")"
100
+ end
101
+ when COMMENT_NODE
102
+ str = "<!--" + self.nodeValue + "-->"
103
+ when DOCUMENT_TYPE_NODE
104
+ str = "#doctype: " + self.nodeName
105
+ when ENTITY_REFERENCE_NODE
106
+ str = "&" + self.nodeName + ";"
107
+ else
108
+ str = self.nodeName
109
+ end
110
+ str.gsub!(/\n/, "\\\\n")
111
+ @treeitem = Gtk::TreeItem::new(str, self)
112
+ @treeitem.signal_connect("select") do |w|
113
+ $text.set_text(w.xml_node.makeXPointer)
114
+ end
115
+ if (parent.nil? && !self.parentNode.nil?)
116
+ self.parentNode.appendNodeToTree(@treeitem)
117
+ else
118
+ parent.append(@treeitem)
119
+ end
120
+ @treeitem.show
121
+ self.childNodes do |c|
122
+ c.newTreeItem
123
+ end
124
+ end
125
+
126
+ def selectNode
127
+ parentNode.showTree if parentNode
128
+ if @treeitem
129
+ @treeitem.activate
130
+ else
131
+ print "Unseen node on the tree view\n"
132
+ end
133
+ end
134
+
135
+ def showTree
136
+ if parentNode
137
+ parentNode.showTree
138
+ end
139
+ @tree.show if @tree
140
+ end
141
+
142
+ def deselect
143
+ @treeitem.deselect
144
+ childNodes do |node|
145
+ node.deselect
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ ## create XML tree
153
+ builder = XML::DOM::Builder.new(TREE_MODE)
154
+ #def builder.nameConverter(str) Uconv::u8toeuc(str) end
155
+ #def builder.nameConverter(str) Uconv::u8toeuc(str) end
156
+ builder.setBase("./")
157
+ begin
158
+ xmltree = builder.parse($<.read, PARSE_EXT)
159
+ rescue XML::Parser::Error
160
+ line = builder.line
161
+ print "#{$0}: #{$!} (in line #{line})\n"
162
+ exit 1
163
+ end
164
+ print "Parsing end\n"
165
+
166
+ ## unify sequential Text nodes
167
+ xmltree.documentElement.normalize
168
+ xmltree.trim if TRIM
169
+ print "Normalization end\n"
170
+
171
+ ## create Gtk window
172
+ window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
173
+ window.signal_connect("delete_event") { exit }
174
+ window.signal_connect("destroy_event") { exit }
175
+
176
+ window.border_width(10)
177
+ window.set_title($<.filename)
178
+
179
+ box1 = Gtk::VBox::new(FALSE, 5)
180
+ window.add(box1)
181
+ box1.show
182
+
183
+ $text = Gtk::Entry.new()
184
+ $text.signal_connect("key_release_event") do |w, k|
185
+ ## Enter key pressed
186
+ if k.keyval == 0xff0d
187
+ text = w.get_text
188
+ xmltree.deselect
189
+ begin
190
+ xmltree.getNodesByXPointer(text) do |node|
191
+ node.selectNode
192
+ end
193
+ rescue
194
+ ## XPointer Error
195
+ print "\a#{$!}: #{text}\n"
196
+ end
197
+ end
198
+ 1
199
+ end
200
+ box1.pack_start($text, TRUE, TRUE, 0)
201
+ $text.show
202
+
203
+ scroll = Gtk::ScrolledWindow.new
204
+ scroll.show
205
+ scroll.set_usize(600,400)
206
+ box1.add(scroll)
207
+
208
+
209
+ tree = Gtk::Tree::new()
210
+ tree.set_selection_mode(Gtk::SELECTION_MULTIPLE)
211
+ scroll.add_with_viewport(tree) ## gtk+-1.2
212
+ ##scroll.add(tree) ## gtk+-1.0
213
+ tree.show
214
+
215
+ ## construct Gtk tree
216
+ xmltree.newTreeItem(tree)
217
+ print "Tree construction end\n"
218
+
219
+ box2 = Gtk::VBox::new(FALSE, 10)
220
+ box2.border_width(10)
221
+ box1.pack_start(box2, FALSE, TRUE, 0)
222
+ box2.show
223
+
224
+ button = Gtk::Button::new("Quit")
225
+ button.signal_connect("clicked") do
226
+ exit
227
+ end
228
+ box2.pack_start(button, TRUE, TRUE, 0)
229
+ button.show
230
+
231
+
232
+ window.show
233
+ Gtk::main()
@@ -0,0 +1,23 @@
1
+ #! /usr/local/bin/ruby
2
+
3
+ require 'xml/dom/builder'
4
+ #require 'uconv'
5
+
6
+ p = XML::DOM::Builder.new
7
+ #def p.nameConverter(str)
8
+ # Uconv.u8toeuc(str)
9
+ #end
10
+ #def p.cdataConverter(str)
11
+ # Uconv.u8toeuc(str)
12
+ #end
13
+
14
+ t = p.parse($<.read)
15
+ allelem = t.getElementsByTagName("*")
16
+ allelem.each do | node|
17
+ p = node.makeXPointer
18
+ print "#{p}: ["
19
+ t.getNodesByXPointer(p).each do |n|
20
+ print n.makeXPointer(true)
21
+ end
22
+ print "]\n"
23
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mame-xmlparser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.81.1
5
+ platform: ruby
6
+ authors:
7
+ - Yoshida Mataso with Jeff Hodges with Yusuke Endoh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ description: "Expat (XML Parser Toolkit) Module for Ruby This is a module to access to James Clark's XML Parser Toolkit \"expat\" (http://www.jclark.com/xml/expat.html) from Ruby. This is a modified version of xmlparser: - works on Ruby 1.9 - depends on hoe instead of mkrf"
26
+ email:
27
+ - mame@tsg.ne.jp
28
+ executables: []
29
+
30
+ extensions:
31
+ - ext/extconf.rb
32
+ extra_rdoc_files:
33
+ - Manifest.txt
34
+ - History.txt
35
+ - README.txt
36
+ files:
37
+ - Manifest.txt
38
+ - History.txt
39
+ - README.txt
40
+ - README
41
+ - README.ja
42
+ - Rakefile
43
+ - ext/extconf.rb
44
+ - ext/xmlparser.c
45
+ - ext/encoding.h
46
+ - lib/sax.rb
47
+ - lib/saxdriver.rb
48
+ - lib/wget.rb
49
+ - lib/xml/dom/builder-ja.rb
50
+ - lib/xml/dom/builder.rb
51
+ - lib/xml/dom/core.rb
52
+ - lib/xml/dom/digest.rb
53
+ - lib/xml/dom/visitor.rb
54
+ - lib/xml/dom2/attr.rb
55
+ - lib/xml/dom2/cdatasection.rb
56
+ - lib/xml/dom2/characterdata.rb
57
+ - lib/xml/dom2/comment.rb
58
+ - lib/xml/dom2/core.rb
59
+ - lib/xml/dom2/document.rb
60
+ - lib/xml/dom2/documentfragment.rb
61
+ - lib/xml/dom2/documenttype.rb
62
+ - lib/xml/dom2/dombuilder.rb
63
+ - lib/xml/dom2/dombuilderfilter.rb
64
+ - lib/xml/dom2/domentityresolver.rb
65
+ - lib/xml/dom2/domentityresolverimpl.rb
66
+ - lib/xml/dom2/domexception.rb
67
+ - lib/xml/dom2/domimplementation.rb
68
+ - lib/xml/dom2/dominputsource.rb
69
+ - lib/xml/dom2/element.rb
70
+ - lib/xml/dom2/entity.rb
71
+ - lib/xml/dom2/entityreference.rb
72
+ - lib/xml/dom2/namednodemap.rb
73
+ - lib/xml/dom2/node.rb
74
+ - lib/xml/dom2/nodelist.rb
75
+ - lib/xml/dom2/notation.rb
76
+ - lib/xml/dom2/processinginstruction.rb
77
+ - lib/xml/dom2/text.rb
78
+ - lib/xml/dom2/xpath.rb
79
+ - lib/xml/encoding-ja.rb
80
+ - lib/xml/parser.rb
81
+ - lib/xml/parserns.rb
82
+ - lib/xml/sax.rb
83
+ - lib/xml/saxdriver.rb
84
+ - lib/xml/xpath.rb
85
+ - lib/xml/xpath.ry
86
+ - lib/xmldigest.rb
87
+ - lib/xmlencoding-ja.rb
88
+ - lib/xmltree.rb
89
+ - lib/xmltreebuilder-ja.rb
90
+ - lib/xmltreebuilder.rb
91
+ - lib/xmltreevisitor.rb
92
+ - samples/buildertest.rb
93
+ - samples/buildertest2.rb
94
+ - samples/digesttest.rb
95
+ - samples/digesttest2.rb
96
+ - samples/doctype.rb
97
+ - samples/doctype.xml
98
+ - samples/doctypei.rb
99
+ - samples/document.dtd
100
+ - samples/dom2/dom2test1.rb
101
+ - samples/dom2/dom2test2.rb
102
+ - samples/dom2/gtkxpath.rb
103
+ - samples/dom2/test1.xml
104
+ - samples/dom2/test2.xml
105
+ - samples/dtd/ext1.dtd
106
+ - samples/dtd/ext2.dtd
107
+ - samples/dtd/extdtd.rb
108
+ - samples/dtd/extdtd.xml
109
+ - samples/expat-1.2/CVS/Entries
110
+ - samples/expat-1.2/CVS/Repository
111
+ - samples/expat-1.2/CVS/Root
112
+ - samples/expat-1.2/ext.ent
113
+ - samples/expat-1.2/exttest.rb
114
+ - samples/expat-1.2/exttesti.rb
115
+ - samples/expat-1.2/hoge.dtd
116
+ - samples/expat-1.2/idattr.xml
117
+ - samples/expat-1.2/idtest.rb
118
+ - samples/expat-1.2/idtest.xml
119
+ - samples/expat-1.2/xmlextparser.rb
120
+ - samples/gtktree.rb
121
+ - samples/idattrtest.rb
122
+ - samples/index_euc.xml
123
+ - samples/index_jis.xml
124
+ - samples/index_noenc.xml
125
+ - samples/index_sjis.xml
126
+ - samples/index_u16.xml
127
+ - samples/index_u8.xml
128
+ - samples/my-html.rb
129
+ - samples/namespaces/CVS/Entries
130
+ - samples/namespaces/CVS/Repository
131
+ - samples/namespaces/CVS/Root
132
+ - samples/namespaces/namespace1.rb
133
+ - samples/namespaces/namespace1.xml
134
+ - samples/namespaces/namespace2.rb
135
+ - samples/namespaces/namespace2.xml
136
+ - samples/nstest.rb
137
+ - samples/saxtest.rb
138
+ - samples/test/featurelist.rb
139
+ - samples/test/skippedentity.rb
140
+ - samples/test/useforeigndtd.rb
141
+ - samples/treetest.rb
142
+ - samples/visitor.rb
143
+ - samples/visitortest.rb
144
+ - samples/writer.rb
145
+ - samples/xmlcheck.rb
146
+ - samples/xmlcomments.rb
147
+ - samples/xmlevent.rb
148
+ - samples/xmliter.rb
149
+ - samples/xmlstats.rb
150
+ - samples/xpointer.rb
151
+ - samples/xpointertest.rb
152
+ - Encodings/README.ja
153
+ - Encodings/euc-jp.enc
154
+ - Encodings/shift_jis.enc
155
+ has_rdoc: false
156
+ homepage: http://www.yoshidam.net/Ruby.html#xmlparser
157
+ licenses:
158
+ post_install_message:
159
+ rdoc_options:
160
+ - --main
161
+ - README.txt
162
+ require_paths:
163
+ - lib
164
+ - ext
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: "0"
170
+ version:
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: "0"
176
+ version:
177
+ requirements: []
178
+
179
+ rubyforge_project: xmlparser
180
+ rubygems_version: 1.3.5
181
+ signing_key:
182
+ specification_version: 3
183
+ summary: Expat (XML Parser Toolkit) Module for Ruby This is a module to access to James Clark's XML Parser Toolkit "expat" (http://www.jclark.com/xml/expat.html) from Ruby
184
+ test_files: []
185
+