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.
- data/Encodings/README.ja +18 -0
- data/Encodings/euc-jp.enc +0 -0
- data/Encodings/shift_jis.enc +0 -0
- data/History.txt +5 -0
- data/Manifest.txt +118 -0
- data/README +697 -0
- data/README.ja +789 -0
- data/README.txt +49 -0
- data/Rakefile +30 -0
- data/ext/encoding.h +91 -0
- data/ext/extconf.rb +58 -0
- data/ext/xmlparser.c +2231 -0
- data/lib/sax.rb +1 -0
- data/lib/saxdriver.rb +1 -0
- data/lib/wget.rb +47 -0
- data/lib/xml/dom/builder-ja.rb +58 -0
- data/lib/xml/dom/builder.rb +310 -0
- data/lib/xml/dom/core.rb +3276 -0
- data/lib/xml/dom/digest.rb +94 -0
- data/lib/xml/dom/visitor.rb +182 -0
- data/lib/xml/dom2/attr.rb +213 -0
- data/lib/xml/dom2/cdatasection.rb +76 -0
- data/lib/xml/dom2/characterdata.rb +177 -0
- data/lib/xml/dom2/comment.rb +81 -0
- data/lib/xml/dom2/core.rb +19 -0
- data/lib/xml/dom2/document.rb +317 -0
- data/lib/xml/dom2/documentfragment.rb +82 -0
- data/lib/xml/dom2/documenttype.rb +102 -0
- data/lib/xml/dom2/dombuilder.rb +277 -0
- data/lib/xml/dom2/dombuilderfilter.rb +12 -0
- data/lib/xml/dom2/domentityresolver.rb +13 -0
- data/lib/xml/dom2/domentityresolverimpl.rb +37 -0
- data/lib/xml/dom2/domexception.rb +95 -0
- data/lib/xml/dom2/domimplementation.rb +61 -0
- data/lib/xml/dom2/dominputsource.rb +29 -0
- data/lib/xml/dom2/element.rb +533 -0
- data/lib/xml/dom2/entity.rb +110 -0
- data/lib/xml/dom2/entityreference.rb +107 -0
- data/lib/xml/dom2/namednodemap.rb +138 -0
- data/lib/xml/dom2/node.rb +587 -0
- data/lib/xml/dom2/nodelist.rb +231 -0
- data/lib/xml/dom2/notation.rb +86 -0
- data/lib/xml/dom2/processinginstruction.rb +155 -0
- data/lib/xml/dom2/text.rb +128 -0
- data/lib/xml/dom2/xpath.rb +398 -0
- data/lib/xml/encoding-ja.rb +42 -0
- data/lib/xml/parser.rb +13 -0
- data/lib/xml/parserns.rb +236 -0
- data/lib/xml/sax.rb +353 -0
- data/lib/xml/saxdriver.rb +370 -0
- data/lib/xml/xpath.rb +3284 -0
- data/lib/xml/xpath.ry +2352 -0
- data/lib/xmldigest.rb +1 -0
- data/lib/xmlencoding-ja.rb +11 -0
- data/lib/xmltree.rb +1 -0
- data/lib/xmltreebuilder-ja.rb +9 -0
- data/lib/xmltreebuilder.rb +1 -0
- data/lib/xmltreevisitor.rb +1 -0
- data/samples/buildertest.rb +47 -0
- data/samples/buildertest2.rb +50 -0
- data/samples/digesttest.rb +26 -0
- data/samples/digesttest2.rb +192 -0
- data/samples/doctype.rb +40 -0
- data/samples/doctype.xml +21 -0
- data/samples/doctypei.rb +19 -0
- data/samples/document.dtd +77 -0
- data/samples/dom2/dom2test1.rb +7 -0
- data/samples/dom2/dom2test2.rb +10 -0
- data/samples/dom2/gtkxpath.rb +259 -0
- data/samples/dom2/test1.xml +16 -0
- data/samples/dom2/test2.xml +7 -0
- data/samples/dtd/ext1.dtd +4 -0
- data/samples/dtd/ext2.dtd +1 -0
- data/samples/dtd/extdtd.rb +34 -0
- data/samples/dtd/extdtd.xml +5 -0
- data/samples/expat-1.2/CVS/Entries +8 -0
- data/samples/expat-1.2/CVS/Repository +1 -0
- data/samples/expat-1.2/CVS/Root +1 -0
- data/samples/expat-1.2/ext.ent +2 -0
- data/samples/expat-1.2/exttest.rb +82 -0
- data/samples/expat-1.2/exttesti.rb +81 -0
- data/samples/expat-1.2/hoge.dtd +7 -0
- data/samples/expat-1.2/idattr.xml +8 -0
- data/samples/expat-1.2/idtest.rb +21 -0
- data/samples/expat-1.2/idtest.xml +12 -0
- data/samples/expat-1.2/xmlextparser.rb +39 -0
- data/samples/gtktree.rb +146 -0
- data/samples/idattrtest.rb +28 -0
- data/samples/index_euc.xml +72 -0
- data/samples/index_jis.xml +72 -0
- data/samples/index_noenc.xml +71 -0
- data/samples/index_sjis.xml +72 -0
- data/samples/index_u16.xml +0 -0
- data/samples/index_u8.xml +72 -0
- data/samples/my-html.rb +65 -0
- data/samples/namespaces/CVS/Entries +5 -0
- data/samples/namespaces/CVS/Repository +1 -0
- data/samples/namespaces/CVS/Root +1 -0
- data/samples/namespaces/namespace1.rb +29 -0
- data/samples/namespaces/namespace1.xml +10 -0
- data/samples/namespaces/namespace2.rb +41 -0
- data/samples/namespaces/namespace2.xml +12 -0
- data/samples/nstest.rb +21 -0
- data/samples/saxtest.rb +70 -0
- data/samples/test/featurelist.rb +11 -0
- data/samples/test/skippedentity.rb +48 -0
- data/samples/test/useforeigndtd.rb +42 -0
- data/samples/treetest.rb +14 -0
- data/samples/visitor.rb +29 -0
- data/samples/visitortest.rb +36 -0
- data/samples/writer.rb +43 -0
- data/samples/xmlcheck.rb +40 -0
- data/samples/xmlcomments.rb +30 -0
- data/samples/xmlevent.rb +76 -0
- data/samples/xmliter.rb +57 -0
- data/samples/xmlstats.rb +167 -0
- data/samples/xpointer.rb +233 -0
- data/samples/xpointertest.rb +23 -0
- metadata +185 -0
data/lib/xmldigest.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'xml/dom/digest'
|
data/lib/xmltree.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'xml/dom/core'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'xml/dom/builder'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'xml/dom/visitor'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby -Ku
|
|
2
|
+
|
|
3
|
+
require 'xml/dom/builder'
|
|
4
|
+
require 'nkf'
|
|
5
|
+
#require 'uconv'
|
|
6
|
+
|
|
7
|
+
class XMLRetry<Exception; end
|
|
8
|
+
|
|
9
|
+
#def Uconv.unknown_unicode_handler(u)
|
|
10
|
+
# return '??'
|
|
11
|
+
## return "#[#{format('%04x', u)}]"
|
|
12
|
+
#end
|
|
13
|
+
|
|
14
|
+
class EUCTreeBuilder < XML::DOM::Builder
|
|
15
|
+
# def nameConverter(str)
|
|
16
|
+
# Uconv.u8toeuc(str)
|
|
17
|
+
# end
|
|
18
|
+
# def cdataConverter(str)
|
|
19
|
+
# Uconv.u8toeuc(str)
|
|
20
|
+
# end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
builder = EUCTreeBuilder.new
|
|
24
|
+
def builder.unknownEncoding(e)
|
|
25
|
+
raise XMLRetry, e
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
xml = $<.read
|
|
29
|
+
|
|
30
|
+
begin
|
|
31
|
+
tree = builder.parse(xml)
|
|
32
|
+
rescue XMLRetry
|
|
33
|
+
newencoding = nil
|
|
34
|
+
e = $!.to_s
|
|
35
|
+
if e =~ /^iso-2022-jp$/i
|
|
36
|
+
xml = NKF.nkf("-Je", xml)
|
|
37
|
+
newencoding = "EUC-JP"
|
|
38
|
+
end
|
|
39
|
+
builder = EUCTreeBuilder.new(0, newencoding)
|
|
40
|
+
retry
|
|
41
|
+
rescue XML::Parser::Error
|
|
42
|
+
line = builder.line
|
|
43
|
+
print "#{$0}: #{$!} (in line #{line})\n"
|
|
44
|
+
exit 1
|
|
45
|
+
end
|
|
46
|
+
#print tree.to_s.gsub(/\#\[([0-9a-f]{4})\]/, "&#x\\1;"), "\n"
|
|
47
|
+
tree.dump
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby -Ku
|
|
2
|
+
|
|
3
|
+
require 'xml/dom/builder'
|
|
4
|
+
require 'nkf'
|
|
5
|
+
#require 'uconv'
|
|
6
|
+
|
|
7
|
+
class XMLRetry<Exception; end
|
|
8
|
+
|
|
9
|
+
#def Uconv.unknown_unicode_handler(u)
|
|
10
|
+
# return '??'
|
|
11
|
+
## return "#[#{format('%04x', u)}]"
|
|
12
|
+
#end
|
|
13
|
+
|
|
14
|
+
class EUCTreeBuilder < XML::DOM::Builder
|
|
15
|
+
# def nameConverter(str)
|
|
16
|
+
# Uconv.u8toeuc(str)
|
|
17
|
+
# end
|
|
18
|
+
# def cdataConverter(str)
|
|
19
|
+
# Uconv.u8toeuc(str)
|
|
20
|
+
# end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
builder = EUCTreeBuilder.new(1)
|
|
24
|
+
def builder.unknownEncoding(e)
|
|
25
|
+
raise XMLRetry, e
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
xml = $<.read
|
|
29
|
+
|
|
30
|
+
begin
|
|
31
|
+
tree = builder.parse(xml)
|
|
32
|
+
rescue XMLRetry
|
|
33
|
+
newencoding = nil
|
|
34
|
+
e = $!.to_s
|
|
35
|
+
if e =~ /^iso-2022-jp$/i
|
|
36
|
+
xml = NKF.nkf("-Je", xml)
|
|
37
|
+
newencoding = "EUC-JP"
|
|
38
|
+
end
|
|
39
|
+
builder = EUCTreeBuilder.new(1, newencoding)
|
|
40
|
+
retry
|
|
41
|
+
rescue XML::Parser::Error
|
|
42
|
+
line = builder.line
|
|
43
|
+
print "#{$0}: #{$!} (in line #{line})\n"
|
|
44
|
+
exit 1
|
|
45
|
+
end
|
|
46
|
+
#print tree.to_s.gsub(/\#\[([0-9a-f]{4})\]/, "&#x\\1;"), "\n"
|
|
47
|
+
tree.documentElement.normalize
|
|
48
|
+
tree.dump
|
|
49
|
+
#print tree
|
|
50
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
## DOMHASH test
|
|
4
|
+
## 1999 by yoshidam
|
|
5
|
+
##
|
|
6
|
+
## Namespace support required
|
|
7
|
+
##
|
|
8
|
+
## Apr 20, 1999 Change for draft-hiroshi-dom-hash-01.txt
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
require 'xml/dom/builder'
|
|
12
|
+
require 'xml/dom/digest'
|
|
13
|
+
|
|
14
|
+
p = XML::DOM::Builder.new(0, nil, ":") ## nssep must be ':'
|
|
15
|
+
if p.respond_to?(:setParamEntityParsing)
|
|
16
|
+
p.setParamEntityParsing(XML::Parser::PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
|
|
17
|
+
end
|
|
18
|
+
begin
|
|
19
|
+
tree = p.parse($<.read, true)
|
|
20
|
+
rescue XML::ParserError
|
|
21
|
+
print "#{$<.filename}:#{p.line}: #{$!}\n"
|
|
22
|
+
exit
|
|
23
|
+
end
|
|
24
|
+
tree.documentElement.normalize
|
|
25
|
+
tree.documentElement.getDigest.each_byte { |c|; print "%02X" % c }
|
|
26
|
+
print "\n"
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
## DOMHASH without DOM tree
|
|
4
|
+
## 1999 by yoshidam
|
|
5
|
+
##
|
|
6
|
+
## Namespace support required
|
|
7
|
+
##
|
|
8
|
+
|
|
9
|
+
require 'xml/parser'
|
|
10
|
+
require 'md5'
|
|
11
|
+
#require 'uconv'
|
|
12
|
+
|
|
13
|
+
module XML
|
|
14
|
+
class ExtEntParser < Parser
|
|
15
|
+
def initialize(parent, *rest)
|
|
16
|
+
super
|
|
17
|
+
@parent = parent
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def startElement(name, attr)
|
|
21
|
+
@parent.startElement(name, attr)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def endElement(name)
|
|
25
|
+
@parent.endElement(name)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def character(data)
|
|
29
|
+
@parent.character(data)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def processingInstruction(target, data)
|
|
33
|
+
@parent.processingInstruction(target, data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def comment(data)
|
|
37
|
+
@parent.comment(data)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def externalEntityRef(context, base, systemId, publicId)
|
|
41
|
+
extp = ExtEntParser.new(self, context)
|
|
42
|
+
begin
|
|
43
|
+
tree = extp.parse(open(systemId).read)
|
|
44
|
+
rescue XML::ParserError
|
|
45
|
+
raise XML::ParserError.new("#{systemId}(#{extp.line}): #{$!}")
|
|
46
|
+
rescue Errno::ENOENT
|
|
47
|
+
raise Errno::ENOENT.new("#{$!}")
|
|
48
|
+
end
|
|
49
|
+
extp.done
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class DigestParser < Parser
|
|
54
|
+
NODE_NODE = 0
|
|
55
|
+
ELEMENT_NODE = 1
|
|
56
|
+
ATTRIBUTE_NODE = 2
|
|
57
|
+
TEXT_NODE = 3
|
|
58
|
+
CDATA_SECTION_NODE = 4
|
|
59
|
+
ENTITY_REFERENCE_NODE = 5
|
|
60
|
+
ENTITY_NODE = 6
|
|
61
|
+
PROCESSING_INSTRUCTION_NODE = 7
|
|
62
|
+
COMMENT_NODE = 8
|
|
63
|
+
DOCUMENT_NODE = 9
|
|
64
|
+
DOCUMENT_TYPE_NODE = 10
|
|
65
|
+
DOCUMENT_FRAGMENT_NODE = 11
|
|
66
|
+
NOTATION_NODE = 12
|
|
67
|
+
|
|
68
|
+
def initialize(*rest)
|
|
69
|
+
super
|
|
70
|
+
@elem_stack = []
|
|
71
|
+
@elem_data = [ "#document", [], [] ]
|
|
72
|
+
@text = ''
|
|
73
|
+
@root = nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
## convert UTF-8 into UTF-16BE
|
|
77
|
+
def tou16(str)
|
|
78
|
+
# Uconv.u16swap(Uconv.u8tou16(str))
|
|
79
|
+
str.unpack("U*").pack("n*")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
## create digest value for the text node
|
|
83
|
+
def textDigest(text)
|
|
84
|
+
MD5.new([TEXT_NODE].pack("N") + tou16(text)).digest
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
## create digest value for the element node
|
|
88
|
+
def elementDigest(name, attrs, children)
|
|
89
|
+
MD5.new([ELEMENT_NODE].pack("N") +
|
|
90
|
+
tou16(name) +
|
|
91
|
+
"\0\0" +
|
|
92
|
+
[attrs.length].pack("N") +
|
|
93
|
+
attrs.join +
|
|
94
|
+
[children.length].pack("N") +
|
|
95
|
+
children.join).digest
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
## create digest value for the attribute node
|
|
99
|
+
def attrDigest(name, value)
|
|
100
|
+
MD5.new([ATTRIBUTE_NODE].pack("N") +
|
|
101
|
+
tou16(name) + "\0\0" + tou16(value)).digest
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def processingInstructionDigest(target, data)
|
|
105
|
+
MD5.new([PROCESSING_INSTRUCTION_NODE].pack("N") +
|
|
106
|
+
tou16(target) + "\0\0" + tou16(data)).digest
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
## flush a bufferd text
|
|
110
|
+
def flushText
|
|
111
|
+
if @text.length > 0
|
|
112
|
+
@elem_data[2].push(textDigest(@text))
|
|
113
|
+
@text = ''
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
## start element handler
|
|
118
|
+
def startElement(name, attr)
|
|
119
|
+
flushText
|
|
120
|
+
@elem_stack.push(@elem_data)
|
|
121
|
+
attr_digests = []
|
|
122
|
+
attr_array = attr.sort {|a, b|
|
|
123
|
+
tou16(a[0]) <=> tou16(b[0])
|
|
124
|
+
}
|
|
125
|
+
attr_array.each {|a|
|
|
126
|
+
attr_digests.push(attrDigest(a[0], a[1]))
|
|
127
|
+
}
|
|
128
|
+
@elem_data = [name, attr_digests, []]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
## end element handler
|
|
132
|
+
def endElement(name)
|
|
133
|
+
flushText
|
|
134
|
+
digest = elementDigest(*@elem_data)
|
|
135
|
+
@elem_data = @elem_stack.pop
|
|
136
|
+
@elem_data[2].push(digest)
|
|
137
|
+
|
|
138
|
+
## digest for root element
|
|
139
|
+
if @elem_stack.length == 0
|
|
140
|
+
@root = digest
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
## character data handler
|
|
145
|
+
def character(data)
|
|
146
|
+
## Character data must be concatenated because expat split a text
|
|
147
|
+
## node into some fragments.
|
|
148
|
+
@text << data
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
## PI handler
|
|
152
|
+
def processingInstruction(target, data)
|
|
153
|
+
flushText
|
|
154
|
+
@elem_data[2].push(processingInstructionDigest(target, data))
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
## comment handler
|
|
158
|
+
def comment(data)
|
|
159
|
+
flushText
|
|
160
|
+
## ignore comment node
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def externalEntityRef(context, base, systemId, publicId)
|
|
164
|
+
extp = ExtEntParser.new(self, context)
|
|
165
|
+
begin
|
|
166
|
+
tree = extp.parse(open(systemId).read)
|
|
167
|
+
rescue XML::ParserError
|
|
168
|
+
raise XML::ParserError.new("#{systemId}(#{extp.line}): #{$!}")
|
|
169
|
+
rescue Errno::ENOENT
|
|
170
|
+
raise Errno::ENOENT.new("#{$!}")
|
|
171
|
+
end
|
|
172
|
+
extp.done
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def getRootDigest
|
|
176
|
+
@root
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
p = XML::DigestParser.new(nil, ":") ## nssep must be ':'
|
|
182
|
+
if p.respond_to?(:setParamEntityParsing)
|
|
183
|
+
p.setParamEntityParsing(XML::Parser::PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
|
|
184
|
+
end
|
|
185
|
+
begin
|
|
186
|
+
p.parse($<.read)
|
|
187
|
+
rescue XML::ParserError
|
|
188
|
+
print "#{$<.filename}:#{p.line}: #{$!}\n"
|
|
189
|
+
exit
|
|
190
|
+
end
|
|
191
|
+
p.getRootDigest.each_byte { |c|; print "%02X" % c }
|
|
192
|
+
print "\n"
|
data/samples/doctype.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'xml/parser'
|
|
4
|
+
|
|
5
|
+
p = XML::Parser.new(nil, "!")
|
|
6
|
+
p.setReturnNSTriplet(true);
|
|
7
|
+
|
|
8
|
+
def p.startDoctypeDecl(name, sysid, pubid, has_internal)
|
|
9
|
+
p(["startDoctypeDecl", sysid, pubid, has_internal])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def p.endDoctypeDecl
|
|
13
|
+
p(["endDoctypeDecl"])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def p.elementDecl(name, model)
|
|
17
|
+
p(["elementDecl", name, model])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def p.attlistDecl(elname, attname, att_type, dflt, isreq)
|
|
21
|
+
p(["attlistDecl", elname, attname, att_type, dflt, isreq])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def p.xmlDecl(version, enc, standalone)
|
|
25
|
+
p(["xmlDecl", version, enc, standalone])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def p.entityDecl(name, param, value, base, sysid, pubid, notation)
|
|
29
|
+
p(["entityDecl", name, param, value, base, sysid, pubid, notation])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def p.startElement(name, attrs)
|
|
33
|
+
p(["startElement", name, attrs])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def p.endElement(name)
|
|
37
|
+
p(["endElement", name])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
p.parse($<.read)
|
data/samples/doctype.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<!DOCTYPE hoge PUBLIC "-//Hoge Version 1.0//JA"
|
|
3
|
+
"http://www.yoshidam.net/hoge/1.0/hoge.dtd" [
|
|
4
|
+
<!ELEMENT hoge (hoge:a|hoge:b)>
|
|
5
|
+
<!ATTLIST hoge aaa (AAAA|BBBB|CCCC) 'AAAA'
|
|
6
|
+
bbb CDATA #IMPLIED
|
|
7
|
+
ccc ID #IMPLIED
|
|
8
|
+
ddd NMTOKEN 'aaa'
|
|
9
|
+
eee NMTOKENS #REQUIRED>
|
|
10
|
+
<!ELEMENT hoge:a EMPTY >
|
|
11
|
+
<!ELEMENT hoge:b ANY >
|
|
12
|
+
<!ELEMENT hoge:c (hoge:b?)>
|
|
13
|
+
<!ELEMENT d (#PCDATA|hoge:a|hoge:b|hoge:c)*>
|
|
14
|
+
<!ELEMENT e (hoge:a|hoge:b|hoge:c)?>
|
|
15
|
+
<!ENTITY aaa "AAAAAAA">
|
|
16
|
+
]>
|
|
17
|
+
|
|
18
|
+
<hoge:ahoge xmlns:hoge="http://www.yoshidam.net/hoge" eee='a b c'>
|
|
19
|
+
<aaa:aaa xmlns:aaa="http://aaaa" aaa:hoge="aaa"/>
|
|
20
|
+
hoge
|
|
21
|
+
</hoge:ahoge>
|
data/samples/doctypei.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#! /usr/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'xml/parser'
|
|
4
|
+
|
|
5
|
+
p = XML::Parser.new(nil, " ")
|
|
6
|
+
p.setReturnNSTriplet(true);
|
|
7
|
+
|
|
8
|
+
def p.startDoctypeDecl(name, sysid, pubid, has_internal) end
|
|
9
|
+
def p.endDoctypeDecl() end
|
|
10
|
+
def p.elementDecl(name, model) end
|
|
11
|
+
def p.attlistDecl(name, elname, attname, att_type, dflt, isreq) end
|
|
12
|
+
def p.xmlDecl(version, enc, standalone) end
|
|
13
|
+
def p.entityDecl(name, param, value, base, sysid, pubid, notation) end
|
|
14
|
+
def p.startElement(name, attrs) end
|
|
15
|
+
def p.endElement(name) end
|
|
16
|
+
|
|
17
|
+
p.parse($<.read) do |t, n, d|
|
|
18
|
+
p([t, n, d])
|
|
19
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!-- <!DOCTYPE document [ -->
|
|
2
|
+
|
|
3
|
+
<!ENTITY % coreattrs "id ID #IMPLIED">
|
|
4
|
+
<!ENTITY % phrase "em|code">
|
|
5
|
+
<!ENTITY % special "link|image">
|
|
6
|
+
<!ENTITY % inline "#PCDATA|%phrase;|%special;">
|
|
7
|
+
<!ENTITY % block "para|rpara|list|pre|table">
|
|
8
|
+
<!ENTITY % flow "%inline;|%block;">
|
|
9
|
+
|
|
10
|
+
<!ELEMENT document (title,(index|contents|section|%block;)*)>
|
|
11
|
+
<!ATTLIST document %coreattrs;>
|
|
12
|
+
|
|
13
|
+
<!ELEMENT em (%inline;)*>
|
|
14
|
+
<!ATTLIST em %coreattrs;>
|
|
15
|
+
|
|
16
|
+
<!ELEMENT code (%inline;)*>
|
|
17
|
+
<!ATTLIST code %coreattrs;>
|
|
18
|
+
|
|
19
|
+
<!ELEMENT title (%inline;)*>
|
|
20
|
+
<!ATTLIST title %coreattrs;>
|
|
21
|
+
|
|
22
|
+
<!ELEMENT para (%inline;)*>
|
|
23
|
+
<!ATTLIST para %coreattrs;>
|
|
24
|
+
|
|
25
|
+
<!ELEMENT rpara (%inline;)*>
|
|
26
|
+
<!ATTLIST rpara %coreattrs;>
|
|
27
|
+
|
|
28
|
+
<!ELEMENT contents (item)+>
|
|
29
|
+
<!ATTLIST contents %coreattrs;>
|
|
30
|
+
|
|
31
|
+
<!ELEMENT index (link)+>
|
|
32
|
+
<!ATTLIST index %coreattrs;>
|
|
33
|
+
|
|
34
|
+
<!ELEMENT pre (%inline;)*>
|
|
35
|
+
<!ATTLIST pre %coreattrs;>
|
|
36
|
+
|
|
37
|
+
<!ELEMENT section (heading,(%block;|subsection)*)>
|
|
38
|
+
<!ATTLIST section %coreattrs;>
|
|
39
|
+
|
|
40
|
+
<!ELEMENT subsection (heading,(%block;)*)>
|
|
41
|
+
<!ATTLIST subsection %coreattrs;>
|
|
42
|
+
|
|
43
|
+
<!ELEMENT heading (%inline;)*>
|
|
44
|
+
<!ATTLIST heading %coreattrs;>
|
|
45
|
+
|
|
46
|
+
<!ELEMENT link (%inline;)*>
|
|
47
|
+
<!ATTLIST link %coreattrs;>
|
|
48
|
+
<!ATTLIST link xml:link CDATA #FIXED 'simple'
|
|
49
|
+
href CDATA #REQUIRED>
|
|
50
|
+
|
|
51
|
+
<!ELEMENT image EMPTY>
|
|
52
|
+
<!ATTLIST image %coreattrs;
|
|
53
|
+
xml:link CDATA #FIXED 'simple'
|
|
54
|
+
href CDATA #REQUIRED
|
|
55
|
+
title CDATA #REQUIRED
|
|
56
|
+
role CDATA #IMPLIED
|
|
57
|
+
show CDATA #IMPLIED>
|
|
58
|
+
|
|
59
|
+
<!ELEMENT list (item)+>
|
|
60
|
+
<!ATTLIST list %coreattrs;>
|
|
61
|
+
|
|
62
|
+
<!ELEMENT item (%flow;)*>
|
|
63
|
+
<!ATTLIST item %coreattrs;>
|
|
64
|
+
|
|
65
|
+
<!ELEMENT table (caption?,tr+)>
|
|
66
|
+
<!ATTLIST table %coreattrs;>
|
|
67
|
+
|
|
68
|
+
<!ELEMENT tr (td)+>
|
|
69
|
+
<!ATTLIST tr %coreattrs;>
|
|
70
|
+
|
|
71
|
+
<!ELEMENT td (%flow;)*>
|
|
72
|
+
<!ATTLIST td %coreattrs;>
|
|
73
|
+
|
|
74
|
+
<!ELEMENT caption (%inline;)*>
|
|
75
|
+
<!ATTLIST caption %coreattrs;>
|
|
76
|
+
|
|
77
|
+
<!-- ]> -->
|