File indexing completed on 2024-04-28 15:22:58
0001 /* 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 1999 Lars Knoll (knoll@kde.org) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 * This file includes excerpts from the Document Object Model (DOM) 0022 * Level 1 Specification (Recommendation) 0023 * https://www.w3.org/TR/REC-DOM-Level-1/ 0024 * Copyright © World Wide Web Consortium , (Massachusetts Institute of 0025 * Technology , Institut National de Recherche en Informatique et en 0026 * Automatique , Keio University ). All Rights Reserved. 0027 * 0028 */ 0029 #ifndef _DOM_XML_h 0030 #define _DOM_XML_h 0031 0032 #include <dom/dom_text.h> 0033 #include <dom/css_stylesheet.h> 0034 0035 namespace DOM 0036 { 0037 0038 class CDATASectionImpl; 0039 class EntityImpl; 0040 class EntityReferenceImpl; 0041 class NotationImpl; 0042 class ProcessingInstructionImpl; 0043 0044 /** 0045 * CDATA sections are used to escape blocks of text containing 0046 * characters that would otherwise be regarded as markup. The only 0047 * delimiter that is recognized in a CDATA section is the "]]>" 0048 * string that ends the CDATA section. CDATA sections can not be 0049 * nested. The primary purpose is for including material such as XML 0050 * fragments, without needing to escape all the delimiters. 0051 * 0052 * The \c DOMString attribute of the \c Text 0053 * node holds the text that is contained by the CDATA section. Note 0054 * that this may contain characters that need to be escaped outside of 0055 * CDATA sections and that, depending on the character encoding 0056 * ("charset") chosen for serialization, it may be impossible to write 0057 * out some characters as part of a CDATA section. 0058 * 0059 * The \c CDATASection interface inherits the 0060 * \c CharacterData interface through the \c Text 0061 * interface. Adjacent \c CDATASections nodes are not 0062 * merged by use of the Element.normalize() method. 0063 * 0064 */ 0065 class KHTML_EXPORT CDATASection : public Text 0066 { 0067 friend class Document; 0068 public: 0069 CDATASection(); 0070 CDATASection(const CDATASection &other); 0071 CDATASection(const Node &other) : Text() 0072 { 0073 (*this) = other; 0074 } 0075 0076 CDATASection &operator = (const Node &other); 0077 CDATASection &operator = (const CDATASection &other); 0078 0079 ~CDATASection(); 0080 protected: 0081 CDATASection(CDATASectionImpl *i); 0082 }; 0083 0084 class DOMString; 0085 0086 /** 0087 * This interface represents an entity, either parsed or unparsed, in 0088 * an XML document. Note that this models the entity itself not the 0089 * entity declaration. \c Entity declaration modeling has 0090 * been left for a later Level of the DOM specification. 0091 * 0092 * The \c nodeName attribute that is inherited from 0093 * \c Node contains the name of the entity. 0094 * 0095 * An XML processor may choose to completely expand entities before 0096 * the structure model is passed to the DOM; in this case there will 0097 * be no \c EntityReference nodes in the document tree. 0098 * 0099 * XML does not mandate that a non-validating XML processor read and 0100 * process entity declarations made in the external subset or declared 0101 * in external parameter entities. This means that parsed entities 0102 * declared in the external subset need not be expanded by some 0103 * classes of applications, and that the replacement value of the 0104 * entity may not be available. When the replacement value is 0105 * available, the corresponding \c Entity node's child 0106 * list represents the structure of that replacement text. Otherwise, 0107 * the child list is empty. 0108 * 0109 * The resolution of the children of the \c Entity (the 0110 * replacement value) may be lazily evaluated; actions by the user 0111 * (such as calling the \c childNodes method on the 0112 * \c Entity Node) are assumed to trigger the evaluation. 0113 * 0114 * The DOM Level 1 does not support editing \c Entity 0115 * nodes; if a user wants to make changes to the contents of an 0116 * \c Entity , every related \c EntityReference node 0117 * has to be replaced in the structure model by a clone of the 0118 * \c Entity 's contents, and then the desired changes must be 0119 * made to each of those clones instead. All the descendants of an 0120 * \c Entity node are readonly. 0121 * 0122 * An \c Entity node does not have any parent. 0123 * 0124 */ 0125 class KHTML_EXPORT Entity : public Node 0126 { 0127 public: 0128 Entity(); 0129 Entity(const Entity &other); 0130 Entity(const Node &other) : Node() 0131 { 0132 (*this) = other; 0133 } 0134 0135 Entity &operator = (const Node &other); 0136 Entity &operator = (const Entity &other); 0137 0138 ~Entity(); 0139 0140 /** 0141 * The public identifier associated with the entity, if specified. 0142 * If the public identifier was not specified, this is \c null . 0143 * 0144 */ 0145 DOMString publicId() const; 0146 0147 /** 0148 * The system identifier associated with the entity, if specified. 0149 * If the system identifier was not specified, this is \c null . 0150 * 0151 */ 0152 DOMString systemId() const; 0153 0154 /** 0155 * For unparsed entities, the name of the notation for the entity. 0156 * For parsed entities, this is \c null . 0157 * 0158 */ 0159 DOMString notationName() const; 0160 protected: 0161 Entity(EntityImpl *i); 0162 }; 0163 0164 /** 0165 * \c EntityReference objects may be inserted into the 0166 * structure model when an entity reference is in the source document, 0167 * or when the user wishes to insert an entity reference. Note that 0168 * character references and references to predefined entities are 0169 * considered to be expanded by the HTML or XML processor so that 0170 * characters are represented by their Unicode equivalent rather than 0171 * by an entity reference. Moreover, the XML processor may completely 0172 * expand references to entities while building the structure model, 0173 * instead of providing \c EntityReference objects. If it 0174 * does provide such objects, then for a given \c EntityReference 0175 * node, it may be that there is no \c Entity node 0176 * representing the referenced entity; but if such an \c Entity 0177 * exists, then the child list of the \c EntityReference 0178 * node is the same as that of the \c Entity node. 0179 * As with the \c Entity node, all descendants of the 0180 * \c EntityReference are readonly. 0181 * 0182 * The resolution of the children of the \c EntityReference 0183 * (the replacement value of the referenced \c Entity 0184 * ) may be lazily evaluated; actions by the user (such as 0185 * calling the \c childNodes method on the 0186 * \c EntityReference node) are assumed to trigger the 0187 * evaluation. 0188 * 0189 */ 0190 class KHTML_EXPORT EntityReference : public Node 0191 { 0192 friend class Document; 0193 public: 0194 EntityReference(); 0195 EntityReference(const EntityReference &other); 0196 EntityReference(const Node &other) : Node() 0197 { 0198 (*this) = other; 0199 } 0200 0201 EntityReference &operator = (const Node &other); 0202 EntityReference &operator = (const EntityReference &other); 0203 0204 ~EntityReference(); 0205 protected: 0206 EntityReference(EntityReferenceImpl *i); 0207 }; 0208 0209 class DOMString; 0210 0211 /** 0212 * This interface represents a notation declared in the DTD. A 0213 * notation either declares, by name, the format of an unparsed entity 0214 * (see section 4.7 of the XML 1.0 specification), or is used for 0215 * formal declaration of Processing Instruction targets (see section 0216 * 2.6 of the XML 1.0 specification). The \c nodeName 0217 * attribute inherited from \c Node is set to the declared 0218 * name of the notation. 0219 * 0220 * The DOM Level 1 does not support editing \c Notation 0221 * nodes; they are therefore readonly. 0222 * 0223 * A \c Notation node does not have any parent. 0224 * 0225 */ 0226 class KHTML_EXPORT Notation : public Node 0227 { 0228 public: 0229 Notation(); 0230 Notation(const Notation &other); 0231 Notation(const Node &other) : Node() 0232 { 0233 (*this) = other; 0234 } 0235 0236 Notation &operator = (const Node &other); 0237 Notation &operator = (const Notation &other); 0238 0239 ~Notation(); 0240 0241 /** 0242 * The public identifier of this notation. If the public 0243 * identifier was not specified, this is \c null . 0244 * 0245 */ 0246 DOMString publicId() const; 0247 0248 /** 0249 * The system identifier of this notation. If the system 0250 * identifier was not specified, this is \c null . 0251 * 0252 */ 0253 DOMString systemId() const; 0254 protected: 0255 Notation(NotationImpl *i); 0256 }; 0257 0258 /** 0259 * The \c ProcessingInstruction interface represents a 0260 * "processing instruction", used in XML as a way to keep 0261 * processor-specific information in the text of the document. 0262 * 0263 */ 0264 class KHTML_EXPORT ProcessingInstruction : public Node 0265 { 0266 friend class Document; 0267 public: 0268 ProcessingInstruction(); 0269 ProcessingInstruction(const ProcessingInstruction &other); 0270 ProcessingInstruction(const Node &other) : Node() 0271 { 0272 (*this) = other; 0273 } 0274 0275 ProcessingInstruction &operator = (const Node &other); 0276 ProcessingInstruction &operator = (const ProcessingInstruction &other); 0277 0278 ~ProcessingInstruction(); 0279 0280 /** 0281 * The target of this processing instruction. XML defines this as 0282 * being the first token following the markup that begins the 0283 * processing instruction. 0284 * 0285 */ 0286 DOMString target() const; 0287 0288 /** 0289 * The content of this processing instruction. This is from the 0290 * first non white space character after the target to the 0291 * character immediately preceding the \c ?> . 0292 * 0293 */ 0294 DOMString data() const; 0295 0296 /** 0297 * see data 0298 * @exception DOMException 0299 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 0300 * 0301 */ 0302 void setData(const DOMString &); 0303 0304 /** 0305 * Introduced in DOM Level 2 0306 * This method is from the LinkStyle interface 0307 * 0308 * The style sheet. 0309 */ 0310 StyleSheet sheet() const; 0311 0312 protected: 0313 ProcessingInstruction(ProcessingInstructionImpl *i); 0314 }; 0315 0316 } //namespace 0317 #endif