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