# File test/core_test.rb, line 145 def test_doctype string = "something" correct = "<!DOCTYPE something>" doc = DocType.new string assert_equals string, doc.name out = "" doc.write(out) assert_equals correct, out doc2 = DocType.new doc assert_equals doc.name, doc2.name assert_equals doc.external_id, doc2.external_id correct = '<!DOCTYPE xsa PUBLIC "-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML" "http://www.garshol.priv.no/download/xsa/xsa.dtd">' one_line_source = '<!DOCTYPE xsa PUBLIC "-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML" "http://www.garshol.priv.no/download/xsa/xsa.dtd"><a/>' doc = DocType.new SourceFactory.create_from(one_line_source) assert_not_nil doc test = "" doc.write(test) assert_equal correct, test multi_line_source = '<!DOCTYPE xsa PUBLIC "-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML" "http://www.garshol.priv.no/download/xsa/xsa.dtd"> <a/>' doc = DocType.new SourceFactory.create_from(multi_line_source) assert_not_nil doc test = "" doc.write(test) assert_equal correct, test odd_space_source = ' <!DOCTYPE xsa PUBLIC "-//LM Garshol//DTD XML Software Autoupdate 1.0//EN//XML" "http://www.garshol.priv.no/download/xsa/xsa.dtd"> <a/>' doc = DocType.new SourceFactory.create_from(odd_space_source) assert_not_nil doc test = "" doc.write(test) assert_equal correct, test # OK, the BIG doctype test, numba wun docin = File.new "benchmarks/doctype_test.xml" doc = Document.new docin test = "" doc.write(test) assert_equal 31, doc.doc_type.size # Here's a little ditty from Tobias... src = "\t\t<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"\n\t\t\"http://www.w3.org/TR/SVG/DTD/svg10.dtd\"\n\t\t[\n\t\t<!-- <!ENTITY % fast-slow \"0 0 .5 1\">-->\n\t\t<!--<!ENTITY % slow-fast \".5 0 1 1\">-->\n\t\t<!ENTITY hover_ani\n\t\t'<animateTransform attributeName=\"transform\"\n\t\ttype=\"scale\" restart=\"whenNotActive\" values=\"1;0.96\"\n\t\tdur=\"0.5s\" calcMode=\"spline\" keySplines=\"0 0 .5 1\"\n\t\tfill=\"freeze\" begin=\"mouseover\"/>\n\t\t<animateTransform attributeName=\"transform\"\n\t\ttype=\"scale\" restart=\"whenNotActive\" values=\"0.96;1\"\n\t\tdur=\"0.5s\" calcMode=\"spline\" keySplines=\".5 0 1 1\"\n\t\tfill=\"freeze\" begin=\"mouseover+0.5s\"/>'\n\t\t>\n\t\t]\n\t\t> <a/>\n" doc = Document.new src end