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 
20 namespace Poco {
21 namespace XML {
22 
23 
24 const XMLString CDATASection::NODE_NAME = toXMLString("#cdata-section");
25 
26 
CDATASection(Document * pOwnerDocument,const XMLString & data)27 CDATASection::CDATASection(Document* pOwnerDocument, const XMLString& data):
28 	Text(pOwnerDocument, data)
29 {
30 }
31 
32 
CDATASection(Document * pOwnerDocument,const CDATASection & sec)33 CDATASection::CDATASection(Document* pOwnerDocument, const CDATASection& sec):
34 	Text(pOwnerDocument, sec)
35 {
36 }
37 
38 
~CDATASection()39 CDATASection::~CDATASection()
40 {
41 }
42 
43 
splitText(unsigned long offset)44 Text* 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 
nodeName() const56 const XMLString& CDATASection::nodeName() const
57 {
58 	return NODE_NAME;
59 }
60 
61 
nodeType() const62 unsigned short CDATASection::nodeType() const
63 {
64 	return Node::CDATA_SECTION_NODE;
65 }
66 
67 
copyNode(bool deep,Document * pOwnerDocument) const68 Node* CDATASection::copyNode(bool deep, Document* pOwnerDocument) const
69 {
70 	return new CDATASection(pOwnerDocument, *this);
71 }
72 
73 
74 } } // namespace Poco::XML
75