5
require 'rexml/document'
7
class TestDocTypeAccessor < Test::Unit::TestCase
10
@sysid = "urn:x-test:sysid1"
11
@notid1 = "urn:x-test:notation1"
12
@notid2 = "urn:x-test:notation2"
13
document_string1 = <<-"XMLEND"
14
<!DOCTYPE r SYSTEM "#{@sysid}" [
15
<!NOTATION n1 SYSTEM "#{@notid1}">
16
<!NOTATION n2 SYSTEM "#{@notid2}">
20
@doctype1 = REXML::Document.new(document_string1).doctype
23
document_string2 = <<-"XMLEND"
24
<!DOCTYPE r PUBLIC "#{@pubid}">
27
@doctype2 = REXML::Document.new(document_string2).doctype
29
document_string3 = <<-"XMLEND"
30
<!DOCTYPE r PUBLIC "#{@pubid}" "#{@sysid}">
33
@doctype3 = REXML::Document.new(document_string3).doctype
38
assert_equal(nil, @doctype1.public)
39
assert_equal(@pubid, @doctype2.public)
40
assert_equal(@pubid, @doctype3.public)
44
assert_equal(@sysid, @doctype1.system)
45
assert_equal(nil, @doctype2.system)
46
assert_equal(@sysid, @doctype3.system)
50
assert_equal(@notid1, @doctype1.notation("n1").system)
51
assert_equal(@notid2, @doctype1.notation("n2").system)
55
notations = @doctype1.notations
56
assert_equal(2, notations.length)
57
assert_equal(@notid1, find_notation(notations, "n1").system)
58
assert_equal(@notid2, find_notation(notations, "n2").system)
61
def find_notation(notations, name)
62
notations.find { |notation|
69
class TestNotationDeclPublic < Test::Unit::TestCase
73
@uri = "http://www.web3d.org/"
77
assert_equal("<!NOTATION #{@name} PUBLIC \"#{@id}\">",
81
def test_to_s_with_uri
82
assert_equal("<!NOTATION #{@name} PUBLIC \"#{@id}\" \"#{@uri}\">",
88
REXML::NotationDecl.new(@name, "PUBLIC", id, uri)
92
class TestNotationDeclSystem < Test::Unit::TestCase
99
assert_equal("<!NOTATION #{@name} SYSTEM \"#{@id}\">",
105
REXML::NotationDecl.new(@name, "SYSTEM", id, nil)