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