1//
2// Text.h
3//
4// Library: XML
5// Package: DOM
6// Module: DOM
7//
8// Definition of the DOM Text class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef DOM_Text_INCLUDED
18#define DOM_Text_INCLUDED
19
20
21#include "Poco/XML/XML.h"
22#include "Poco/DOM/CharacterData.h"
23#include "Poco/XML/XMLString.h"
24
25
26namespace Poco {
27namespace XML {
28
29
30class XML_API Text: public CharacterData
31 /// The Text interface inherits from CharacterData and represents the textual
32 /// content (termed character data in XML) of an Element or Attr. If there is
33 /// no markup inside an element's content, the text is contained in a single
34 /// object implementing the Text interface that is the only child of the element.
35 /// If there is markup, it is parsed into the information items (elements, comments,
36 /// etc.) and Text nodes that form the list of children of the element.
37 ///
38 /// When a document is first made available via the DOM, there is only one Text
39 /// node for each block of text. Users may create adjacent Text nodes that represent
40 /// the contents of a given element without any intervening markup, but should
41 /// be aware that there is no way to represent the separations between these
42 /// nodes in XML or HTML, so they will not (in general) persist between DOM
43 /// editing sessions. The normalize() method on Element merges any such adjacent
44 /// Text objects into a single node for each block of text.
45{
46public:
47 Text* splitText(unsigned long offset);
48 /// Breaks this node into two nodes at the specified offset, keeping both in
49 /// the tree as siblings. This node then only contains all the content up to
50 /// the offset point. A new node of the same type, which is inserted as the
51 /// next sibling of this node, contains all the content at and after the offset
52 /// point. When the offset is equal to the length of this node, the new node
53 /// has no data.
54
55 // Node
56 const XMLString& nodeName() const;
57 unsigned short nodeType() const;
58
59 // Non-standard extensions
60 XMLString innerText() const;
61
62protected:
63 Text(Document* pOwnerDocument, const XMLString& data);
64 Text(Document* pOwnerDocument, const Text& text);
65 ~Text();
66
67 Node* copyNode(bool deep, Document* pOwnerDocument) const;
68
69private:
70 static const XMLString NODE_NAME;
71
72 friend class Document;
73};
74
75
76} } // namespace Poco::XML
77
78
79#endif // DOM_Text_INCLUDED
80