Attributes.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // Attributes.h
  3. //
  4. // Library: XML
  5. // Package: SAX
  6. // Module: SAX
  7. //
  8. // SAX2 Attributes Interface.
  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 SAX_Attributes_INCLUDED
  16. #define SAX_Attributes_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/XML/XMLString.h"
  19. namespace Poco {
  20. namespace XML {
  21. class XML_API Attributes
  22. /// Interface for a list of XML attributes.
  23. /// This interface allows access to a list of attributes in three different ways:
  24. /// 1.by attribute index;
  25. /// 2.by Namespace-qualified name; or
  26. /// 3.by qualified (prefixed) name.
  27. ///
  28. /// The list will not contain attributes that were declared #IMPLIED but not
  29. /// specified in the start tag. It will also not contain
  30. /// attributes used as Namespace declarations (xmlns*) unless the
  31. /// http://xml.org/sax/features/namespace-prefixes
  32. /// feature is set to true (it is false by default).
  33. ///
  34. /// If the namespace-prefixes feature (see above) is false, access by
  35. /// qualified name may not be available; if the
  36. /// http://xml.org/sax/features/namespaces feature is false, access by
  37. /// Namespace-qualified names may not be available.
  38. /// This interface replaces the now-deprecated SAX1 AttributeList interface,
  39. /// which does not contain Namespace support. In
  40. /// addition to Namespace support, it adds the getIndex methods (below).
  41. /// The order of attributes in the list is unspecified, and will vary from
  42. /// implementation to implementation.
  43. {
  44. public:
  45. virtual int getIndex(const XMLString& name) const = 0;
  46. /// Look up the index of an attribute by a qualified name.
  47. virtual int getIndex(const XMLString& namespaceURI, const XMLString& localName) const = 0;
  48. /// Look up the index of an attribute by a namspace name.
  49. virtual int getLength() const = 0;
  50. /// Return the number of attributes in the list.
  51. ///
  52. /// Once you know the number of attributes, you can iterate through the list.
  53. virtual const XMLString& getLocalName(int i) const = 0;
  54. /// Look up a local attribute name by index.
  55. virtual const XMLString& getQName(int i) const = 0;
  56. /// Look up a qualified attribute name by index.
  57. virtual const XMLString& getType(int i) const = 0;
  58. /// Look up an attribute type by index.
  59. ///
  60. /// The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN",
  61. /// "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).
  62. ///
  63. /// If the parser has not read a declaration for the attribute, or if the parser does not
  64. /// report attribute types, then it must return the value "CDATA" as stated in the XML 1.0
  65. /// Recommendation (clause 3.3.3, "Attribute-Value Normalization").
  66. ///
  67. /// For an enumerated attribute that is not a notation, the parser will report the type
  68. /// as "NMTOKEN".
  69. virtual const XMLString& getType(const XMLString& qname) const = 0;
  70. /// Look up an attribute type by a qualified name.
  71. ///
  72. /// See getType(int) for a description of the possible types.
  73. virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0;
  74. /// Look up an attribute type by a namespace name.
  75. ///
  76. /// See getType(int) for a description of the possible types.
  77. virtual const XMLString& getValue(int i) const = 0;
  78. /// Look up an attribute value by index.
  79. ///
  80. /// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens
  81. /// will be concatenated into a single string with each token separated by a single space.
  82. virtual const XMLString& getValue(const XMLString& qname) const = 0;
  83. /// Look up an attribute value by a qualified name.
  84. ///
  85. /// See getValue(int) for a description of the possible values.
  86. virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0;
  87. /// Look up an attribute value by a namespace name.
  88. ///
  89. /// See getValue(int) for a description of the possible values.
  90. virtual const XMLString& getURI(int i) const = 0;
  91. /// Look up a namespace URI by index.
  92. protected:
  93. virtual ~Attributes();
  94. };
  95. } } // namespace Poco::XML
  96. #endif // SAX_Attributes_INCLUDED