root / trunk / tbeta / Windows / libs / Poco / include / Poco / DOM / CDATASection.h @ 139

View | Annotate | Download (4.2 KB)

1
//
2
// CDATASection.h
3
//
4
// $Id: //poco/1.3/XML/include/Poco/DOM/CDATASection.h#1 $
5
//
6
// Library: XML
7
// Package: DOM
8
// Module:  DOM
9
//
10
// Definition of the DOM CDATASection class.
11
//
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13
// and Contributors.
14
//
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
21
// 
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
28
// 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
36
//
37
38
39
#ifndef DOM_CDATASection_INCLUDED
40
#define DOM_CDATASection_INCLUDED
41
42
43
#include "Poco/XML/XML.h"
44
#include "Poco/DOM/Text.h"
45
46
47
namespace Poco {
48
namespace XML {
49
50
51
class XML_API CDATASection: public Text
52
        /// CDATA sections are used to escape blocks of text containing characters that
53
        /// would otherwise be regarded as markup. The only delimiter that is recognized
54
        /// in a CDATA section is the "]]>" string that ends the CDATA section. CDATA
55
        /// sections cannot be nested. Their primary purpose is for including material
56
        /// such as XML fragments, without needing to escape all the delimiters.
57
        /// 
58
        /// The DOMString attribute of the Text node holds the text that is contained
59
        /// by the CDATA section. Note that this may contain characters that need to
60
        /// be escaped outside of CDATA sections and that, depending on the character
61
        /// encoding ("charset") chosen for serialization, it may be impossible to write
62
        /// out some characters as part of a CDATA section.
63
        /// 
64
        /// The CDATASection interface inherits from the CharacterData interface through
65
        /// the Text interface. Adjacent CDATASection nodes are not merged by use of
66
        /// the normalize method on the Element interface.
67
        /// 
68
        /// Note: Because no markup is recognized within a CDATASection, character numeric
69
        /// references cannot be used as an escape mechanism when serializing. Therefore,
70
        /// action needs to be taken when serializing a CDATASection with a character
71
        /// encoding where some of the contained characters cannot be represented. Failure
72
        /// to do so would not produce well-formed XML.
73
        /// One potential solution in the serialization process is to end the CDATA
74
        /// section before the character, output the character using a character reference
75
        /// or entity reference, and open a new CDATA section for any further characters
76
        /// in the text node. Note, however, that some code conversion libraries at
77
        /// the time of writing do not return an error or exception when a character
78
        /// is missing from the encoding, making the task of ensuring that data is not
79
        /// corrupted on serialization more difficult.
80
{
81
public:
82
        // Text
83
        Text* splitText(unsigned long offset);
84
85
        // Node
86
        const XMLString& nodeName() const;
87
        unsigned short nodeType() const;
88
89
protected:
90
        CDATASection(Document* pOwnerDocument, const XMLString& data);
91
        CDATASection(Document* pOwnerDocument, const CDATASection& sec);
92
        ~CDATASection();
93
94
        Node* copyNode(bool deep, Document* pOwnerDocument) const;
95
96
private:
97
        static const XMLString NODE_NAME;
98
        
99
        friend class Document;
100
};
101
102
103
} } // namespace Poco::XML
104
105
106
#endif // DOM_CDATASection_INCLUDED