mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
committed latest 1.3 snapshot
This commit is contained in:
parent
b7a945da93
commit
b60344ddcd
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/XML/Makefile#11 $
|
||||
# $Id: //poco/Main/XML/Makefile#12 $
|
||||
#
|
||||
# Makefile for Poco XML
|
||||
#
|
||||
@ -22,7 +22,7 @@ objects = AbstractContainerNode AbstractNode Attr AttrMap Attributes \
|
||||
NamespaceSupport Node NodeFilter NodeIterator NodeList Notation \
|
||||
ParserEngine ProcessingInstruction SAXException SAXParser Text \
|
||||
TreeWalker WhitespaceFilter XMLException XMLFilter XMLFilterImpl XMLReader \
|
||||
XMLString XMLWriter xmlparse xmlrole xmltok
|
||||
XMLString XMLWriter NodeAppender xmlparse xmlrole xmltok
|
||||
|
||||
target = PocoXML
|
||||
target_version = $(LIBVERSION)
|
||||
|
@ -538,6 +538,9 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\DOM\Node.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Dom\NodeAppender.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DOM\NodeFilter.h">
|
||||
</File>
|
||||
@ -659,6 +662,9 @@
|
||||
<File
|
||||
RelativePath=".\src\Node.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppender.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeFilter.cpp">
|
||||
</File>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="XML"
|
||||
ProjectGUID="{9E211743-85FE-4977-82F3-4F04B40C912D}"
|
||||
>
|
||||
@ -735,6 +735,10 @@
|
||||
RelativePath=".\include\Poco\DOM\Node.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DOM\NodeAppender.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Dom\NodeFilter.h"
|
||||
>
|
||||
@ -895,6 +899,10 @@
|
||||
RelativePath=".\src\Node.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppender.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeFilter.cpp"
|
||||
>
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractContainerNode.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/AbstractContainerNode.h#2 $
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/AbstractContainerNode.h#3 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -77,6 +77,7 @@ private:
|
||||
AbstractNode* _pFirstChild;
|
||||
|
||||
friend class AbstractNode;
|
||||
friend class NodeAppender;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractNode.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/AbstractNode.h#2 $
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/AbstractNode.h#3 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -135,6 +135,7 @@ private:
|
||||
friend class Attr;
|
||||
friend class CharacterData;
|
||||
friend class DOMBuilder;
|
||||
friend class NodeAppender;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DOMWriter.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/DOMWriter.h#3 $
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/DOMWriter.h#4 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -94,7 +94,7 @@ public:
|
||||
|
||||
void writeNode(const std::string& systemId, const Node* pNode);
|
||||
/// Writes the XML for the given node to the file specified in systemId,
|
||||
/// using a standard file output stream (std::ofstream).
|
||||
/// using a standard file output stream (Poco::FileOutputStream).
|
||||
|
||||
private:
|
||||
std::string _encodingName;
|
||||
|
103
XML/include/Poco/DOM/NodeAppender.h
Normal file
103
XML/include/Poco/DOM/NodeAppender.h
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// NodeAppender.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/include/Poco/DOM/NodeAppender.h#1 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
// Module: NodeAppender
|
||||
//
|
||||
// Definition of the NodeAppender class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef DOM_NodeAppender_INCLUDED
|
||||
#define DOM_NodeAppender_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/DOM/Node.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class AbstractNode;
|
||||
class Element;
|
||||
|
||||
|
||||
class XML_API NodeAppender
|
||||
/// The NodeAppender class provides a very fast way to
|
||||
/// build larger DOM documents.
|
||||
///
|
||||
/// In the DOM, child nodes are usually appended to a parent
|
||||
/// node using the appendChild() method. For nodes containing
|
||||
/// more than a few children, this method can be quite slow,
|
||||
/// due to the way it's implemented, and because of the
|
||||
/// requirements of the DOM specification.
|
||||
///
|
||||
/// While the NodeAppender is being used on an Element, no
|
||||
/// children-modifying methods of that Element must be used.
|
||||
///
|
||||
/// This class is not part of the DOM specification.
|
||||
{
|
||||
public:
|
||||
NodeAppender(Element* parent);
|
||||
/// Creates the NodeAppender for the given parent node,
|
||||
/// which must be an Element.
|
||||
|
||||
~NodeAppender();
|
||||
/// Destroys the NodeAppender.
|
||||
|
||||
void appendChild(Node* newChild);
|
||||
/// Appends the node newChild to the end of the list of children of
|
||||
/// the parent node specified in the constructor.
|
||||
/// If the newChild is already in the tree, it is first removed.
|
||||
///
|
||||
/// NewChild can be a DocumentFragment. In this case, all children
|
||||
/// of the fragment become children of the parent element.
|
||||
///
|
||||
/// In order to speed up the function, no DOM events
|
||||
/// are fired.
|
||||
|
||||
private:
|
||||
NodeAppender();
|
||||
NodeAppender(const NodeAppender&);
|
||||
NodeAppender& operator = (const NodeAppender&);
|
||||
|
||||
Element* _pParent;
|
||||
AbstractNode* _pLast;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // #include "Poco/XML/XML.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// EntityResolverImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/include/Poco/SAX/EntityResolverImpl.h#2 $
|
||||
// $Id: //poco/Main/XML/include/Poco/SAX/EntityResolverImpl.h#3 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
@ -58,7 +58,7 @@ class XML_API EntityResolverImpl: public EntityResolver
|
||||
/// for an InputSource.
|
||||
///
|
||||
/// If the system ID is not a valid URI, it is
|
||||
/// interpreted as a filesystem path and a ifstream
|
||||
/// interpreted as a filesystem path and a Poco::FileInputStream
|
||||
/// is opened for it.
|
||||
{
|
||||
public:
|
||||
@ -78,7 +78,7 @@ public:
|
||||
/// for the given systemId, which is interpreted as an URI.
|
||||
///
|
||||
/// If the systemId is not a valid URI, it is interpreted as
|
||||
/// a local filesystem path and an ifstream is opened for it.
|
||||
/// a local filesystem path and a Poco::FileInputStream is opened for it.
|
||||
|
||||
void releaseInputSource(InputSource* pSource);
|
||||
/// Deletes the InputSource's stream.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DOMWriter.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/src/DOMWriter.cpp#13 $
|
||||
// $Id: //poco/Main/XML/src/DOMWriter.cpp#14 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
@ -45,7 +45,7 @@
|
||||
#include "Poco/SAX/LexicalHandler.h"
|
||||
#include "Poco/XML/XMLException.h"
|
||||
#include "Poco/Path.h"
|
||||
#include <fstream>
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -104,7 +104,7 @@ void DOMWriter::writeNode(XMLByteOutputStream& ostr, const Node* pNode)
|
||||
|
||||
void DOMWriter::writeNode(const std::string& systemId, const Node* pNode)
|
||||
{
|
||||
std::ofstream ostr(Poco::Path::transcode(systemId).c_str());
|
||||
Poco::FileOutputStream ostr(systemId);
|
||||
if (ostr.good())
|
||||
writeNode(ostr, pNode);
|
||||
else
|
||||
|
104
XML/src/NodeAppender.cpp
Normal file
104
XML/src/NodeAppender.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
//
|
||||
// NodeAppender.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/src/NodeAppender.cpp#1 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: DOM
|
||||
// Module: NodeAppender
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/DOM/NodeAppender.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/DOMException.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
NodeAppender::NodeAppender(Element* parent):
|
||||
_pParent(parent),
|
||||
_pLast(0)
|
||||
{
|
||||
poco_check_ptr (parent);
|
||||
|
||||
_pLast = static_cast<AbstractNode*>(_pParent->lastChild());
|
||||
}
|
||||
|
||||
|
||||
NodeAppender::~NodeAppender()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppender::appendChild(Node* newChild)
|
||||
{
|
||||
poco_check_ptr (newChild);
|
||||
poco_assert (_pLast == 0 || _pLast->_pNext == 0);
|
||||
|
||||
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pParent->_pOwner)
|
||||
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
|
||||
|
||||
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
|
||||
{
|
||||
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
|
||||
AbstractNode* pChild = pFrag->_pFirstChild;
|
||||
if (pChild)
|
||||
{
|
||||
if (_pLast)
|
||||
_pLast->_pNext = pChild;
|
||||
else
|
||||
_pParent->_pFirstChild = pChild;
|
||||
while (pChild)
|
||||
{
|
||||
_pLast = pChild;
|
||||
pChild->_pParent = _pParent;
|
||||
pChild = pChild->_pNext;
|
||||
}
|
||||
pFrag->_pFirstChild = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AbstractNode* pAN = static_cast<AbstractNode*>(newChild);
|
||||
pAN->duplicate();
|
||||
if (pAN->_pParent)
|
||||
pAN->_pParent->removeChild(pAN);
|
||||
pAN->_pParent = _pParent;
|
||||
if (_pLast)
|
||||
_pLast->_pNext = pAN;
|
||||
else
|
||||
_pParent->_pFirstChild = pAN;
|
||||
_pLast = pAN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/XML/testsuite/Makefile#5 $
|
||||
# $Id: //poco/Main/XML/testsuite/Makefile#6 $
|
||||
#
|
||||
# Makefile for Poco XML testsuite
|
||||
#
|
||||
@ -12,7 +12,7 @@ objects = AttributesImplTest ChildNodesTest DOMTestSuite DocumentTest \
|
||||
DocumentTypeTest Driver ElementTest EventTest NamePoolTest NameTest \
|
||||
NamespaceSupportTest NodeIteratorTest NodeTest ParserWriterTest \
|
||||
SAXParserTest SAXTestSuite TextTest TreeWalkerTest \
|
||||
XMLTestSuite XMLWriterTest
|
||||
XMLTestSuite XMLWriterTest NodeAppenderTest
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
|
@ -340,6 +340,9 @@
|
||||
<File
|
||||
RelativePath=".\src\EventTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppenderTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeIteratorTest.h">
|
||||
</File>
|
||||
@ -377,6 +380,9 @@
|
||||
<File
|
||||
RelativePath=".\src\EventTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppenderTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeIteratorTest.cpp">
|
||||
</File>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="TestSuite"
|
||||
ProjectGUID="{C9ACF028-17A1-44C2-8C09-DFD3BD9E7D45}"
|
||||
Keyword="Win32Proj"
|
||||
@ -482,6 +482,10 @@
|
||||
RelativePath=".\src\EventTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppenderTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeIteratorTest.h"
|
||||
>
|
||||
@ -530,6 +534,10 @@
|
||||
RelativePath=".\src\EventTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeAppenderTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NodeIteratorTest.cpp"
|
||||
>
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DOMTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/DOMTestSuite.cpp#8 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/DOMTestSuite.cpp#9 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -41,6 +41,7 @@
|
||||
#include "NodeIteratorTest.h"
|
||||
#include "TreeWalkerTest.h"
|
||||
#include "ParserWriterTest.h"
|
||||
#include "NodeAppenderTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* DOMTestSuite::suite()
|
||||
@ -57,6 +58,7 @@ CppUnit::Test* DOMTestSuite::suite()
|
||||
pSuite->addTest(NodeIteratorTest::suite());
|
||||
pSuite->addTest(TreeWalkerTest::suite());
|
||||
pSuite->addTest(ParserWriterTest::suite());
|
||||
pSuite->addTest(NodeAppenderTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
162
XML/testsuite/src/NodeAppenderTest.cpp
Normal file
162
XML/testsuite/src/NodeAppenderTest.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
//
|
||||
// NodeAppenderTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/NodeAppenderTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "NodeAppenderTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/DOM/NodeAppender.h"
|
||||
#include "Poco/DOM/Element.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/DocumentFragment.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
|
||||
|
||||
using Poco::XML::NodeAppender;
|
||||
using Poco::XML::Element;
|
||||
using Poco::XML::Document;
|
||||
using Poco::XML::DocumentFragment;
|
||||
using Poco::XML::AutoPtr;
|
||||
using Poco::XML::XMLString;
|
||||
|
||||
|
||||
NodeAppenderTest::NodeAppenderTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NodeAppenderTest::~NodeAppenderTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNode()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
|
||||
appender.appendChild(pElem1);
|
||||
appender.appendChild(pElem2);
|
||||
appender.appendChild(pElem3);
|
||||
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::testAppendNodeList()
|
||||
{
|
||||
AutoPtr<Document> pDoc = new Document;
|
||||
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
||||
pDoc->appendChild(pRoot);
|
||||
|
||||
NodeAppender appender(pRoot);
|
||||
|
||||
AutoPtr<DocumentFragment> pFrag1 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag2 = pDoc->createDocumentFragment();
|
||||
AutoPtr<DocumentFragment> pFrag3 = pDoc->createDocumentFragment();
|
||||
|
||||
AutoPtr<Element> pElem1 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem2 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem3 = pDoc->createElement("elem");
|
||||
AutoPtr<Element> pElem4 = pDoc->createElement("elem");
|
||||
|
||||
pFrag2->appendChild(pElem1);
|
||||
pFrag2->appendChild(pElem2);
|
||||
pFrag2->appendChild(pElem3);
|
||||
|
||||
pFrag3->appendChild(pElem4);
|
||||
|
||||
appender.appendChild(pFrag1);
|
||||
assert (pRoot->firstChild() == 0);
|
||||
|
||||
appender.appendChild(pFrag2);
|
||||
assert (pRoot->firstChild() == pElem1);
|
||||
assert (pRoot->lastChild() == pElem3);
|
||||
|
||||
assert (pElem1->nextSibling() == pElem2);
|
||||
assert (pElem2->nextSibling() == pElem3);
|
||||
assert (pElem3->nextSibling() == 0);
|
||||
|
||||
assert (pElem1->previousSibling() == 0);
|
||||
assert (pElem2->previousSibling() == pElem1);
|
||||
assert (pElem3->previousSibling() == pElem2);
|
||||
|
||||
assert (pElem1->parentNode() == pRoot);
|
||||
assert (pElem2->parentNode() == pRoot);
|
||||
assert (pElem3->parentNode() == pRoot);
|
||||
|
||||
appender.appendChild(pFrag3);
|
||||
assert (pRoot->lastChild() == pElem4);
|
||||
assert (pElem4->parentNode() == pRoot);
|
||||
assert (pElem3->nextSibling() == pElem4);
|
||||
assert (pElem4->previousSibling() == pElem3);
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NodeAppenderTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* NodeAppenderTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NodeAppenderTest");
|
||||
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNode);
|
||||
CppUnit_addTest(pSuite, NodeAppenderTest, testAppendNodeList);
|
||||
|
||||
return pSuite;
|
||||
}
|
61
XML/testsuite/src/NodeAppenderTest.h
Normal file
61
XML/testsuite/src/NodeAppenderTest.h
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// NodeAppenderTest.h
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/NodeAppenderTest.h#1 $
|
||||
//
|
||||
// Definition of the NodeAppenderTest class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef NodeAppenderTest_INCLUDED
|
||||
#define NodeAppenderTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class NodeAppenderTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NodeAppenderTest(const std::string& name);
|
||||
~NodeAppenderTest();
|
||||
|
||||
void testAppendNode();
|
||||
void testAppendNodeList();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // NodeAppenderTest_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ParserWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/ParserWriterTest.cpp#11 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/ParserWriterTest.cpp#12 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -40,7 +40,6 @@
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using Poco::XML::DOMParser;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SAXParserTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/XML/testsuite/src/SAXParserTest.cpp#9 $
|
||||
// $Id: //poco/Main/XML/testsuite/src/SAXParserTest.cpp#10 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -40,8 +40,8 @@
|
||||
#include "Poco/SAX/WhitespaceFilter.h"
|
||||
#include "Poco/XML/XMLWriter.h"
|
||||
#include "Poco/Latin9Encoding.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using Poco::XML::SAXParser;
|
||||
@ -277,7 +277,7 @@ void SAXParserTest::testRSS()
|
||||
parser.setFeature(XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES, true);
|
||||
|
||||
std::istringstream istr(RSS);
|
||||
std::ofstream ostr("rss.xml", std::ios::binary);
|
||||
Poco::FileOutputStream ostr("rss.xml");
|
||||
XMLWriter writer(ostr, XMLWriter::CANONICAL | XMLWriter::PRETTY_PRINT);
|
||||
filter.setContentHandler(&writer);
|
||||
filter.setDTDHandler(&writer);
|
||||
|
Loading…
Reference in New Issue
Block a user