fixed GH# 128: DOMWriter incorrectly adds SYSTEM keyword to DTD if PUBLIC is already specified

This commit is contained in:
Guenter Obiltschnig 2013-05-24 23:13:03 +02:00
parent e6a24b3101
commit 173f205cb6
3 changed files with 27 additions and 3 deletions

View File

@ -493,7 +493,11 @@ void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const
} }
if (!systemId.empty()) if (!systemId.empty())
{ {
writeMarkup(" SYSTEM \""); if (publicId.empty())
{
writeMarkup(" SYSTEM");
}
writeMarkup(" \"");
writeXML(systemId); writeXML(systemId);
writeMarkup("\""); writeMarkup("\"");
} }

View File

@ -1,7 +1,7 @@
// //
// XMLWriterTest.cpp // 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. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // 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 == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<!DOCTYPE test PUBLIC \"test\" \"http://www.appinf.com/DTDs/test\">"
"<foo/>");
}
void XMLWriterTest::testDTDNotation() void XMLWriterTest::testDTDNotation()
{ {
std::ostringstream str; std::ostringstream str;
@ -621,6 +639,7 @@ CppUnit::Test* XMLWriterTest::suite()
CppUnit_addTest(pSuite, XMLWriterTest, testTrivialFragmentPretty); CppUnit_addTest(pSuite, XMLWriterTest, testTrivialFragmentPretty);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDPretty); CppUnit_addTest(pSuite, XMLWriterTest, testDTDPretty);
CppUnit_addTest(pSuite, XMLWriterTest, testDTD); CppUnit_addTest(pSuite, XMLWriterTest, testDTD);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDPublic);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDNotation); CppUnit_addTest(pSuite, XMLWriterTest, testDTDNotation);
CppUnit_addTest(pSuite, XMLWriterTest, testDTDEntity); CppUnit_addTest(pSuite, XMLWriterTest, testDTDEntity);
CppUnit_addTest(pSuite, XMLWriterTest, testAttributes); CppUnit_addTest(pSuite, XMLWriterTest, testAttributes);

View File

@ -1,7 +1,7 @@
// //
// XMLWriterTest.h // 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. // Definition of the XMLWriterTest class.
// //
@ -54,6 +54,7 @@ public:
void testTrivialFragmentPretty(); void testTrivialFragmentPretty();
void testDTDPretty(); void testDTDPretty();
void testDTD(); void testDTD();
void testDTDPublic();
void testDTDNotation(); void testDTDNotation();
void testDTDEntity(); void testDTDEntity();
void testAttributes(); void testAttributes();