1//
2// CDATASection.cpp
3//
4// Library: XML
5// Package: DOM
6// Module: DOM
7//
8// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/DOM/CDATASection.h"
16#include "Poco/DOM/Document.h"
17#include "Poco/DOM/DOMException.h"
18
19
20namespace Poco {
21namespace XML {
22
23
24const XMLString CDATASection::NODE_NAME = toXMLString("#cdata-section");
25
26
27CDATASection::CDATASection(Document* pOwnerDocument, const XMLString& data):
28 Text(pOwnerDocument, data)
29{
30}
31
32
33CDATASection::CDATASection(Document* pOwnerDocument, const CDATASection& sec):
34 Text(pOwnerDocument, sec)
35{
36}
37
38
39CDATASection::~CDATASection()
40{
41}
42
43
44Text* CDATASection::splitText(unsigned long offset)
45{
46 Node* pParent = parentNode();
47 if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
48 int n = length() - offset;
49 Text* pNew = ownerDocument()->createCDATASection(substringData(offset, n));
50 deleteData(offset, n);
51 pParent->insertBefore(pNew, nextSibling())->release();
52 return pNew;
53}
54
55
56const XMLString& CDATASection::nodeName() const
57{
58 return NODE_NAME;
59}
60
61
62unsigned short CDATASection::nodeType() const
63{
64 return Node::CDATA_SECTION_NODE;
65}
66
67
68Node* CDATASection::copyNode(bool /*deep*/, Document* pOwnerDocument) const
69{
70 return new CDATASection(pOwnerDocument, *this);
71}
72
73
74} } // namespace Poco::XML
75