| 1 | // |
| 2 | // Entity.h |
| 3 | // |
| 4 | // Library: XML |
| 5 | // Package: DOM |
| 6 | // Module: DOM |
| 7 | // |
| 8 | // Definition of the DOM Entity 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_Entity_INCLUDED |
| 18 | #define DOM_Entity_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/XML/XML.h" |
| 22 | #include "Poco/DOM/AbstractContainerNode.h" |
| 23 | #include "Poco/XML/XMLString.h" |
| 24 | |
| 25 | |
| 26 | namespace Poco { |
| 27 | namespace XML { |
| 28 | |
| 29 | |
| 30 | class XML_API Entity: public AbstractContainerNode |
| 31 | /// This interface represents an entity, either parsed or unparsed, in an XML |
| 32 | /// document. Note that this models the entity itself not the entity declaration. |
| 33 | /// Entity declaration modeling has been left for a later Level of the DOM |
| 34 | /// specification. |
| 35 | /// |
| 36 | /// The nodeName attribute that is inherited from Node contains the name of |
| 37 | /// the entity. |
| 38 | /// |
| 39 | /// An XML processor may choose to completely expand entities before the structure |
| 40 | /// model is passed to the DOM; in this case there will be no EntityReference |
| 41 | /// nodes in the document tree. |
| 42 | /// |
| 43 | /// XML does not mandate that a non-validating XML processor read and process |
| 44 | /// entity declarations made in the external subset or declared in external |
| 45 | /// parameter entities. This means that parsed entities declared in the external |
| 46 | /// subset need not be expanded by some classes of applications, and that the |
| 47 | /// replacement value of the entity may not be available. When the replacement |
| 48 | /// value is available, the corresponding Entity node's child list represents |
| 49 | /// the structure of that replacement text. Otherwise, the child list is empty. |
| 50 | /// |
| 51 | /// The resolution of the children of the Entity (the replacement value) may |
| 52 | /// be lazily evaluated; actions by the user (such as calling the childNodes |
| 53 | /// method on the Entity Node) are assumed to trigger the evaluation. |
| 54 | /// |
| 55 | /// The DOM Level 1 does not support editing Entity nodes; if a user wants to |
| 56 | /// make changes to the contents of an Entity, every related EntityReference |
| 57 | /// node has to be replaced in the structure model by a clone of the Entity's |
| 58 | /// contents, and then the desired changes must be made to each of those clones |
| 59 | /// instead. Entity nodes and all their descendants are readonly. |
| 60 | /// |
| 61 | /// An Entity node does not have any parent. |
| 62 | { |
| 63 | public: |
| 64 | const XMLString& publicId() const; |
| 65 | /// Returns the public identifier associated with |
| 66 | /// the entity, if specified. If the public identifier |
| 67 | /// was not specified, this is the empty string. |
| 68 | |
| 69 | const XMLString& systemId() const; |
| 70 | /// Returns the system identifier associated with |
| 71 | /// the entity, if specified. If the system identifier |
| 72 | /// was not specified, this is the empty string. |
| 73 | |
| 74 | const XMLString& notationName() const; |
| 75 | /// Returns, for unparsed entities, the name of the |
| 76 | /// notation for the entity. For parsed entities, this |
| 77 | /// is the empty string. |
| 78 | |
| 79 | // Node |
| 80 | const XMLString& nodeName() const; |
| 81 | unsigned short nodeType() const; |
| 82 | |
| 83 | protected: |
| 84 | Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName); |
| 85 | Entity(Document* pOwnerDocument, const Entity& entity); |
| 86 | ~Entity(); |
| 87 | |
| 88 | Node* copyNode(bool deep, Document* pOwnerDocument) const; |
| 89 | |
| 90 | private: |
| 91 | static const XMLString NODE_NAME; |
| 92 | |
| 93 | XMLString _name; |
| 94 | XMLString _publicId; |
| 95 | XMLString _systemId; |
| 96 | XMLString _notationName; |
| 97 | |
| 98 | friend class Document; |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | // |
| 103 | // inlines |
| 104 | // |
| 105 | inline const XMLString& Entity::publicId() const |
| 106 | { |
| 107 | return _publicId; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | inline const XMLString& Entity::systemId() const |
| 112 | { |
| 113 | return _systemId; |
| 114 | } |
| 115 | |
| 116 | |
| 117 | inline const XMLString& Entity::notationName() const |
| 118 | { |
| 119 | return _notationName; |
| 120 | } |
| 121 | |
| 122 | |
| 123 | } } // namespace Poco::XML |
| 124 | |
| 125 | |
| 126 | #endif // DOM_Entity_INCLUDED |
| 127 | |