[80] | 1 | // |
---|
| 2 | // Attributes.h |
---|
| 3 | // |
---|
| 4 | // $Id: //poco/1.3/XML/include/Poco/SAX/Attributes.h#2 $ |
---|
| 5 | // |
---|
| 6 | // Library: XML |
---|
| 7 | // Package: SAX |
---|
| 8 | // Module: SAX |
---|
| 9 | // |
---|
| 10 | // SAX2 Attributes Interface. |
---|
| 11 | // |
---|
| 12 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
---|
| 13 | // and Contributors. |
---|
| 14 | // |
---|
| 15 | // Permission is hereby granted, free of charge, to any person or organization |
---|
| 16 | // obtaining a copy of the software and accompanying documentation covered by |
---|
| 17 | // this license (the "Software") to use, reproduce, display, distribute, |
---|
| 18 | // execute, and transmit the Software, and to prepare derivative works of the |
---|
| 19 | // Software, and to permit third-parties to whom the Software is furnished to |
---|
| 20 | // do so, all subject to the following: |
---|
| 21 | // |
---|
| 22 | // The copyright notices in the Software and this entire statement, including |
---|
| 23 | // the above license grant, this restriction and the following disclaimer, |
---|
| 24 | // must be included in all copies of the Software, in whole or in part, and |
---|
| 25 | // all derivative works of the Software, unless such copies or derivative |
---|
| 26 | // works are solely in the form of machine-executable object code generated by |
---|
| 27 | // a source language processor. |
---|
| 28 | // |
---|
| 29 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 30 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 31 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
---|
| 32 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
---|
| 33 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
---|
| 34 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
| 35 | // DEALINGS IN THE SOFTWARE. |
---|
| 36 | // |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #ifndef SAX_Attributes_INCLUDED |
---|
| 40 | #define SAX_Attributes_INCLUDED |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #include "Poco/XML/XML.h" |
---|
| 44 | #include "Poco/XML/XMLString.h" |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | namespace Poco { |
---|
| 48 | namespace XML { |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | class XML_API Attributes |
---|
| 52 | /// Interface for a list of XML attributes. |
---|
| 53 | /// This interface allows access to a list of attributes in three different ways: |
---|
| 54 | /// 1.by attribute index; |
---|
| 55 | /// 2.by Namespace-qualified name; or |
---|
| 56 | /// 3.by qualified (prefixed) name. |
---|
| 57 | /// |
---|
| 58 | /// The list will not contain attributes that were declared #IMPLIED but not |
---|
| 59 | /// specified in the start tag. It will also not contain |
---|
| 60 | /// attributes used as Namespace declarations (xmlns*) unless the |
---|
| 61 | /// http://xml.org/sax/features/namespace-prefixes |
---|
| 62 | /// feature is set to true (it is false by default). |
---|
| 63 | /// |
---|
| 64 | /// If the namespace-prefixes feature (see above) is false, access by |
---|
| 65 | /// qualified name may not be available; if the |
---|
| 66 | /// http://xml.org/sax/features/namespaces feature is false, access by |
---|
| 67 | /// Namespace-qualified names may not be available. |
---|
| 68 | /// This interface replaces the now-deprecated SAX1 AttributeList interface, |
---|
| 69 | /// which does not contain Namespace support. In |
---|
| 70 | /// addition to Namespace support, it adds the getIndex methods (below). |
---|
| 71 | /// The order of attributes in the list is unspecified, and will vary from |
---|
| 72 | /// implementation to implementation. |
---|
| 73 | { |
---|
| 74 | public: |
---|
| 75 | virtual int getIndex(const XMLString& name) const = 0; |
---|
| 76 | /// Look up the index of an attribute by a qualified name. |
---|
| 77 | |
---|
| 78 | virtual int getIndex(const XMLString& namespaceURI, const XMLString& localName) const = 0; |
---|
| 79 | /// Look up the index of an attribute by a namspace name. |
---|
| 80 | |
---|
| 81 | virtual int getLength() const = 0; |
---|
| 82 | /// Return the number of attributes in the list. |
---|
| 83 | /// |
---|
| 84 | /// Once you know the number of attributes, you can iterate through the list. |
---|
| 85 | |
---|
| 86 | virtual const XMLString& getLocalName(int i) const = 0; |
---|
| 87 | /// Look up a local attribute name by index. |
---|
| 88 | |
---|
| 89 | virtual const XMLString& getQName(int i) const = 0; |
---|
| 90 | /// Look up a qualified attribute name by index. |
---|
| 91 | |
---|
| 92 | virtual const XMLString& getType(int i) const = 0; |
---|
| 93 | /// Look up an attribute type by index. |
---|
| 94 | /// |
---|
| 95 | /// The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", |
---|
| 96 | /// "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case). |
---|
| 97 | /// |
---|
| 98 | /// If the parser has not read a declaration for the attribute, or if the parser does not |
---|
| 99 | /// report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 |
---|
| 100 | /// Recommendation (clause 3.3.3, "Attribute-Value Normalization"). |
---|
| 101 | /// |
---|
| 102 | /// For an enumerated attribute that is not a notation, the parser will report the type |
---|
| 103 | /// as "NMTOKEN". |
---|
| 104 | |
---|
| 105 | virtual const XMLString& getType(const XMLString& qname) const = 0; |
---|
| 106 | /// Look up an attribute type by a qualified name. |
---|
| 107 | /// |
---|
| 108 | /// See getType(int) for a description of the possible types. |
---|
| 109 | |
---|
| 110 | virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0; |
---|
| 111 | /// Look up an attribute type by a namespace name. |
---|
| 112 | /// |
---|
| 113 | /// See getType(int) for a description of the possible types. |
---|
| 114 | |
---|
| 115 | virtual const XMLString& getValue(int i) const = 0; |
---|
| 116 | /// Look up an attribute value by index. |
---|
| 117 | /// |
---|
| 118 | /// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens |
---|
| 119 | /// will be concatenated into a single string with each token separated by a single space. |
---|
| 120 | |
---|
| 121 | virtual const XMLString& getValue(const XMLString& qname) const = 0; |
---|
| 122 | /// Look up an attribute value by a qualified name. |
---|
| 123 | /// |
---|
| 124 | /// See getValue(int) for a description of the possible values. |
---|
| 125 | |
---|
| 126 | virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0; |
---|
| 127 | /// Look up an attribute value by a namespace name. |
---|
| 128 | /// |
---|
| 129 | /// See getValue(int) for a description of the possible values. |
---|
| 130 | |
---|
| 131 | virtual const XMLString& getURI(int i) const = 0; |
---|
| 132 | /// Look up a namespace URI by index. |
---|
| 133 | |
---|
| 134 | protected: |
---|
| 135 | virtual ~Attributes(); |
---|
| 136 | }; |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | } } // namespace Poco::XML |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | #endif // SAX_Attributes_INCLUDED |
---|