source: icXML/icXML-devel/src/xercesc/sax/AttributeList.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 7.5 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: AttributeList.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP)
23#define XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP
24
25#include <xercesc/util/XercesDefs.hpp>
26
27XERCES_CPP_NAMESPACE_BEGIN
28
29/**
30  * Interface for an element's attribute specifications.
31  *
32  * The SAX parser implements this interface and passes an instance
33  * to the SAX application as the second argument of each startElement
34  * event.
35  *
36  * The instance provided will return valid results only during the
37  * scope of the startElement invocation (to save it for future
38  * use, the application must make a copy: the AttributeListImpl
39  * helper class provides a convenient constructor for doing so).
40  *
41  * An AttributeList includes only attributes that have been
42  * specified or defaulted: \#IMPLIED attributes will not be included.
43  *
44  * There are two ways for the SAX application to obtain information
45  * from the AttributeList.  First, it can iterate through the entire
46  * list:
47  *
48  * <code>
49  * public void startElement (String name, AttributeList atts) {<br>
50  * &nbsp;for (XMLSize_t i = 0; i < atts.getLength(); i++) {<br>
51  * &nbsp;&nbsp;String name = atts.getName(i);<br>
52  * &nbsp;&nbsp;String type = atts.getType(i);<br>
53  * &nbsp;&nbsp;String value = atts.getValue(i);<br>
54  * &nbsp;&nbsp;[...]<br>
55  * &nbsp;}<br>
56  * }
57  * </code>
58  *
59  * (Note that the result of getLength() will be zero if there
60  * are no attributes.)
61  *
62  * As an alternative, the application can request the value or
63  * type of specific attributes:
64  *
65  * <code>
66  * public void startElement (String name, AttributeList atts) {<br>
67  * &nbsp;String identifier = atts.getValue("id");<br>
68  * &nbsp;String label = atts.getValue("label");<br>
69  * &nbsp;[...]<br>
70  * }
71  * </code>
72  *
73  * The AttributeListImpl helper class provides a convenience
74  * implementation for use by parser or application writers.
75  *
76  * @see DocumentHandler#startElement
77  * @see AttributeListImpl#AttributeListImpl
78  */
79
80class SAX_EXPORT AttributeList
81{
82public:
83    // -----------------------------------------------------------------------
84    //  Constructors and Destructor
85    // -----------------------------------------------------------------------
86    /** @name Constructors and Destructor */
87    //@{
88    /** Default constructor */
89    AttributeList()
90    {
91    }
92
93    /** Destructor */
94    virtual ~AttributeList()
95    {
96    }
97    //@}
98
99    /** @name The virtual attribute list interface */
100    //@{
101  /**
102    * Return the number of attributes in this list.
103    *
104    * The SAX parser may provide attributes in any
105    * arbitrary order, regardless of the order in which they were
106    * declared or specified.  The number of attributes may be
107    * zero.
108    *
109    * @return The number of attributes in the list.
110    */
111    virtual XMLSize_t getLength() const = 0;
112
113  /**
114    * Return the name of an attribute in this list (by position).
115    *
116    * The names must be unique: the SAX parser shall not include the
117    * same attribute twice.  Attributes without values (those declared
118    * \#IMPLIED without a value specified in the start tag) will be
119    * omitted from the list.
120    *
121    * If the attribute name has a namespace prefix, the prefix
122    * will still be attached.
123    *
124    * @param index The index of the attribute in the list (starting at 0).
125    * @return The name of the indexed attribute, or null
126    *         if the index is out of range.
127    * @see #getLength
128    */
129    virtual const XMLCh* getName(const XMLSize_t index) const = 0;
130
131  /**
132    * Return the type of an attribute in the list (by position).
133    *
134    * The attribute type is one of the strings "CDATA", "ID",
135    * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
136    * or "NOTATION" (always in upper case).
137    *
138    * If the parser has not read a declaration for the attribute,
139    * or if the parser does not report attribute types, then it must
140    * return the value "CDATA" as stated in the XML 1.0 Recommendation
141    * (clause 3.3.3, "Attribute-Value Normalization").
142    *
143    * For an enumerated attribute that is not a notation, the
144    * parser will report the type as "NMTOKEN".
145    *
146    * @param index The index of the attribute in the list (starting at 0).
147    * @return The attribute type as a string, or
148    *         null if the index is out of range.
149    * @see #getLength
150    * @see #getType
151    */
152    virtual const XMLCh* getType(const XMLSize_t index) const = 0;
153
154  /**
155    * Return the value of an attribute in the list (by position).
156    *
157    * If the attribute value is a list of tokens (IDREFS,
158    * ENTITIES, or NMTOKENS), the tokens will be concatenated
159    * into a single string separated by whitespace.
160    *
161    * @param index The index of the attribute in the list (starting at 0).
162    * @return The attribute value as a string, or
163    *         null if the index is out of range.
164    * @see #getLength
165    * @see #getValue
166    */
167    virtual const XMLCh* getValue(const XMLSize_t index) const = 0;
168
169  /**
170    * Return the type of an attribute in the list (by name).
171    *
172    * The return value is the same as the return value for
173    * getType(XMLSize_t).
174    *
175    * If the attribute name has a namespace prefix in the document,
176    * the application must include the prefix here.
177    *
178    * @param name The name of the attribute.
179    * @return The attribute type as a string, or null if no
180    *         such attribute exists.
181    * @see #getType
182    */
183    virtual const XMLCh* getType(const XMLCh* const name) const = 0;
184
185  /**
186    * Return the value of an attribute in the list (by name).
187    *
188    * The return value is the same as the return value for
189    * getValue(XMLSize_t).
190    *
191    * If the attribute name has a namespace prefix in the document,
192    * the application must include the prefix here.
193    *
194    * @param name The name of the attribute in the list.
195    * @return The attribute value as a string, or null if
196    *         no such attribute exists.
197    * @see #getValue
198    */
199    virtual const XMLCh* getValue(const XMLCh* const name) const = 0;
200
201  /**
202    * Return the value of an attribute in the list (by name).
203    *
204    * The return value is the same as the return value for
205    * getValue(XMLSize_t).
206    *
207    * If the attribute name has a namespace prefix in the document,
208    * the application must include the prefix here.
209    *
210    * @param name The name of the attribute in the list.
211    * @return The attribute value as a string, or null if
212    *         no such attribute exists.
213    * @see #getValue
214    */
215    virtual const XMLCh* getValue(const char* const name) const = 0;
216    //@}
217
218private :
219    /* Constructors and operators */
220    /* Copy constructor */
221    AttributeList(const AttributeList&);
222    /* Assignment operator */
223    AttributeList& operator=(const AttributeList&);
224
225};
226
227XERCES_CPP_NAMESPACE_END
228
229#endif
Note: See TracBrowser for help on using the repository browser.