# File tests/tokenizertester.rb, line 170 def test_entities sourceWithoutPreproc = '<!DOCTYPE x [ <!ENTITY example "<p>An ampersand (&#38;) may be escaped numerically (&#38;#38;) or with a general entity (&amp;).</p>" > ]>' body = "\n<x>&example;</x>" toker = NQXML::Tokenizer.new("<?xml version=\1.0\?>\n" + sourceWithoutPreproc + body) newline = NQXML::Text.new("\n", "\n") literal = '<p>An ampersand (&) may be escaped numerically' + ' (&#38;) or with a general entity (&amp;).</p>' src = '<!ENTITY example "<p>An ampersand (&#38;) may be escaped' + ' numerically (&#38;#38;) or with a general entity' + ' (&amp;).</p>" >' exampleEntity = NQXML::GeneralEntityTag.new('example', literal, nil, nil, src) doctype = NQXML::Doctype.new('x', nil, [exampleEntity], sourceWithoutPreproc) expected = [ NQXML::XMLDecl.new('xml', {'version'=>'1.0'}, '<?xml version="1.0"?>'), newline, doctype, newline, NQXML::Tag.new('x', {}, false, '<x>'), NQXML::Tag.new('p', {}, false, '<p>'), NQXML::Text.new('An ampersand (&) may be escaped numerically' + ' (&) or with a general entity (&).', 'An ampersand (&) may be escaped numerically' + ' (&38;) or with a general entity' + ' (&amp;).'), NQXML::Tag.new('p', nil, true, '</p>'), NQXML::Tag.new('x', nil, true, '</x>'), newline ] i = 0 toker.each { | entity | assert_equal(expected[i], entity) if entity.instance_of?(NQXML::Doctype) assert_equal(1, entity.entities.length) assert_equal(exampleEntity, entity.entities[0]) end i += 1 } end