diff --git a/XML/src/XMLWriter.cpp b/XML/src/XMLWriter.cpp index 8eefe606d..c3807178e 100644 --- a/XML/src/XMLWriter.cpp +++ b/XML/src/XMLWriter.cpp @@ -493,7 +493,11 @@ void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const } if (!systemId.empty()) { - writeMarkup(" SYSTEM \""); + if (publicId.empty()) + { + writeMarkup(" SYSTEM"); + } + writeMarkup(" \""); writeXML(systemId); writeMarkup("\""); } diff --git a/XML/testsuite/src/XMLWriterTest.cpp b/XML/testsuite/src/XMLWriterTest.cpp index cb12b72ce..3717d59c4 100644 --- a/XML/testsuite/src/XMLWriterTest.cpp +++ b/XML/testsuite/src/XMLWriterTest.cpp @@ -1,7 +1,7 @@ // // XMLWriterTest.cpp // -// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.cpp#3 $ +// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.cpp#4 $ // // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // and Contributors. @@ -169,6 +169,24 @@ void XMLWriterTest::testDTD() } +void XMLWriterTest::testDTDPublic() +{ + std::ostringstream str; + XMLWriter writer(str, XMLWriter::WRITE_XML_DECLARATION); + writer.setNewLine("\n"); + writer.startDocument(); + writer.startDTD("test", "test", "http://www.appinf.com/DTDs/test"); + writer.endDTD(); + writer.startElement("", "", "foo"); + writer.endElement("", "", "foo"); + writer.endDocument(); + std::string xml = str.str(); + assert (xml == "" + "" + ""); +} + + void XMLWriterTest::testDTDNotation() { std::ostringstream str; @@ -621,6 +639,7 @@ CppUnit::Test* XMLWriterTest::suite() CppUnit_addTest(pSuite, XMLWriterTest, testTrivialFragmentPretty); CppUnit_addTest(pSuite, XMLWriterTest, testDTDPretty); CppUnit_addTest(pSuite, XMLWriterTest, testDTD); + CppUnit_addTest(pSuite, XMLWriterTest, testDTDPublic); CppUnit_addTest(pSuite, XMLWriterTest, testDTDNotation); CppUnit_addTest(pSuite, XMLWriterTest, testDTDEntity); CppUnit_addTest(pSuite, XMLWriterTest, testAttributes); diff --git a/XML/testsuite/src/XMLWriterTest.h b/XML/testsuite/src/XMLWriterTest.h index 22e89b888..3e266fe58 100644 --- a/XML/testsuite/src/XMLWriterTest.h +++ b/XML/testsuite/src/XMLWriterTest.h @@ -1,7 +1,7 @@ // // XMLWriterTest.h // -// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#1 $ +// $Id: //poco/1.4/XML/testsuite/src/XMLWriterTest.h#2 $ // // Definition of the XMLWriterTest class. // @@ -54,6 +54,7 @@ public: void testTrivialFragmentPretty(); void testDTDPretty(); void testDTD(); + void testDTDPublic(); void testDTDNotation(); void testDTDEntity(); void testAttributes();