Entity.h 3.6 KB

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