source: NonGTP/Xerces/xercesc/sax2/Attributes.hpp @ 188

Revision 188, 13.4 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: Attributes.hpp,v $
59 * Revision 1.4  2003/03/07 18:10:30  tng
60 * Return a reference instead of void for operator=
61 *
62 * Revision 1.3  2002/11/04 14:55:45  tng
63 * C++ Namespace Support.
64 *
65 * Revision 1.2  2002/02/20 18:17:02  tng
66 * [Bug 5977] Warnings on generating apiDocs.
67 *
68 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
69 * sane_include
70 *
71 * Revision 1.5  2001/05/11 13:26:25  tng
72 * Copyright update.
73 *
74 * Revision 1.4  2001/02/26 19:44:19  tng
75 * Schema: add utility class QName, by Pei Yong Zhang.
76 *
77 * Revision 1.3  2000/08/09 22:19:28  jpolast
78 * many conformance & stability changes:
79 *   - ContentHandler::resetDocument() removed
80 *   - attrs param of ContentHandler::startDocument() made const
81 *   - SAXExceptions thrown now have msgs
82 *   - removed duplicate function signatures that had 'const'
83 *       [ eg: getContentHander() ]
84 *   - changed getFeature and getProperty to apply to const objs
85 *   - setProperty now takes a void* instead of const void*
86 *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
87 *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
88 *   - Features & Properties now read-only during parse
89 *
90 * Revision 1.2  2000/08/07 18:21:26  jpolast
91 * change SAX_EXPORT module to SAX2_EXPORT
92 *
93 * Revision 1.1  2000/08/02 18:02:34  jpolast
94 * initial checkin of sax2 implementation
95 * submitted by Simon Fell (simon@fell.com)
96 * and Joe Polastre (jpolast@apache.org)
97 *
98 *
99 */
100
101#ifndef ATTRIBUTES_HPP
102#define ATTRIBUTES_HPP
103
104#include <xercesc/util/XercesDefs.hpp>
105
106XERCES_CPP_NAMESPACE_BEGIN
107
108/**
109  * Interface for an element's attribute specifications.
110  *
111  * The SAX2 parser implements this interface and passes an instance
112  * to the SAX2 application as the last argument of each startElement
113  * event.
114  *
115  * The instance provided will return valid results only during the
116  * scope of the startElement invocation (to save it for future
117  * use, the application must make a copy: the AttributesImpl
118  * helper class provides a convenient constructor for doing so).
119  *
120  * An Attributes includes only attributes that have been
121  * specified or defaulted: #IMPLIED attributes will not be included.
122  *
123  * There are two ways for the SAX application to obtain information
124  * from the Attributes.  First, it can iterate through the entire
125  * list:
126  *
127  * <pre>
128  * public void startElement (String uri, String localpart, String qName, Attributes atts) {
129  *   for (int i = 0; i < atts.getLength(); i++) {
130  *     String Qname = atts.getQName(i);
131  *             String URI   = atts.getURI(i)
132  *             String local = atts.GetLocalName(i)
133  *     String type  = atts.getType(i);
134  *     String value = atts.getValue(i);
135  *     [...]
136  *   }
137  * }
138  * </pre>
139  *
140  * (Note that the result of getLength() will be zero if there
141  * are no attributes.)
142  *
143  * As an alternative, the application can request the value or
144  * type of specific attributes:
145  *
146  * <pre>
147  * public void startElement (String uri, String localpart, String qName, Attributes atts) {
148  *   String identifier = atts.getValue("id");
149  *   String label = atts.getValue("label");
150  *   [...]
151  * }
152  * </pre>
153  *
154  * The AttributesImpl helper class provides a convenience
155  * implementation for use by parser or application writers.
156  *
157  * @see Sax2DocumentHandler#startElement
158  * @see AttributesImpl#AttributesImpl
159  */
160
161class SAX2_EXPORT Attributes
162{
163public:
164    // -----------------------------------------------------------------------
165    //  Constructors and Destructor
166    // -----------------------------------------------------------------------
167    /** @name Constructors and Destructor */
168    //@{
169    /** Default constructor */
170    Attributes()
171    {
172    }
173
174    /** Destructor */
175    virtual ~Attributes()
176    {
177    }
178    //@}
179
180    /** @name The virtual attribute list interface */
181    //@{
182  /**
183    * Return the number of attributes in this list.
184    *
185    * The SAX parser may provide attributes in any
186    * arbitrary order, regardless of the order in which they were
187    * declared or specified.  The number of attributes may be
188    * zero.
189    *
190    * @return The number of attributes in the list.
191    */
192    virtual unsigned int getLength() const = 0;
193
194  /**
195    * Return the namespace URI of an attribute in this list (by position).
196    *
197    * The QNames must be unique: the SAX parser shall not include the
198    * same attribute twice.  Attributes without values (those declared
199    * #IMPLIED without a value specified in the start tag) will be
200    * omitted from the list.
201    *
202    * @param index The index of the attribute in the list (starting at 0).
203    * @return The URI of the indexed attribute, or null
204    *         if the index is out of range.
205    * @see #getLength
206    */
207        virtual const XMLCh* getURI(const unsigned int index) const = 0;
208
209  /**
210    * Return the local name of an attribute in this list (by position).
211    *
212    * The QNames must be unique: the SAX parser shall not include the
213    * same attribute twice.  Attributes without values (those declared
214    * #IMPLIED without a value specified in the start tag) will be
215    * omitted from the list.
216    *
217    * @param index The index of the attribute in the list (starting at 0).
218    * @return The local name of the indexed attribute, or null
219    *         if the index is out of range.
220    * @see #getLength
221    */
222    virtual const XMLCh* getLocalName(const unsigned int index) const = 0;
223
224  /**
225    * Return the qName of an attribute in this list (by position).
226    *
227    * The QNames must be unique: the SAX parser shall not include the
228    * same attribute twice.  Attributes without values (those declared
229    * #IMPLIED without a value specified in the start tag) will be
230    * omitted from the list.
231    *
232    * @param index The index of the attribute in the list (starting at 0).
233    * @return The qName of the indexed attribute, or null
234    *         if the index is out of range.
235    * @see #getLength
236    */
237    virtual const XMLCh* getQName(const unsigned int index) const = 0;
238
239  /**
240    * Return the type of an attribute in the list (by position).
241    *
242    * The attribute type is one of the strings "CDATA", "ID",
243    * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
244    * or "NOTATION" (always in upper case).
245    *
246    * If the parser has not read a declaration for the attribute,
247    * or if the parser does not report attribute types, then it must
248    * return the value "CDATA" as stated in the XML 1.0 Recommentation
249    * (clause 3.3.3, "Attribute-Value Normalization").
250    *
251    * For an enumerated attribute that is not a notation, the
252    * parser will report the type as "NMTOKEN".
253    *
254    * @param index The index of the attribute in the list (starting at 0).
255    * @return The attribute type as a string, or
256    *         null if the index is out of range.
257    * @see #getLength
258    * @see #getType(String)
259    */
260    virtual const XMLCh* getType(const unsigned int index) const = 0;
261
262  /**
263    * Return the value of an attribute in the list (by position).
264    *
265    * If the attribute value is a list of tokens (IDREFS,
266    * ENTITIES, or NMTOKENS), the tokens will be concatenated
267    * into a single string separated by whitespace.
268    *
269    * @param index The index of the attribute in the list (starting at 0).
270    * @return The attribute value as a string, or
271    *         null if the index is out of range.
272    * @see #getLength
273    * @see #getValue(XMLCh*)
274    */
275    virtual const XMLCh* getValue(const unsigned int index) const = 0;
276
277    ////////////////////////////////////////////////////////////////////
278    // Name-based query.
279    ////////////////////////////////////////////////////////////////////
280
281   /**
282     * Look up the index of an attribute by Namespace name.
283     *
284     * @param uri The Namespace URI, or the empty string if
285     *        the name has no Namespace URI.
286     * @param localPart The attribute's local name.
287     * @return The index of the attribute, or -1 if it does not
288     *         appear in the list.
289     */
290        virtual int getIndex(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
291
292   /**
293     * Look up the index of an attribute by XML 1.0 qualified name.
294     *
295     * @param qName The qualified (prefixed) name.
296     * @return The index of the attribute, or -1 if it does not
297     *         appear in the list.
298     */
299        virtual int getIndex(const XMLCh* const qName ) const = 0 ;
300
301   /**
302     * Look up an attribute's type by Namespace name.
303     *
304     * <p>See #getType for a description of the possible types.</p>
305     *
306     * @param uri The Namespace URI, or the empty String if the
307     *        name has no Namespace URI.
308     * @param localPart The local name of the attribute.
309     * @return The attribute type as a string, or null if the
310     *         attribute is not in the list or if Namespace
311     *         processing is not being performed.
312     */
313        virtual const XMLCh* getType(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
314
315   /**
316     * Look up an attribute's type by XML 1.0 qualified name.
317     *
318     * <p>See #getType for a description of the possible types.</p>
319     *
320     * @param qName The XML 1.0 qualified name.
321     * @return The attribute type as a string, or null if the
322     *         attribute is not in the list or if qualified names
323     *         are not available.
324     */
325    virtual const XMLCh* getType(const XMLCh* const qName) const = 0;
326
327   /**
328     * Look up an attribute's value by Namespace name.
329     *
330     * <p>See #getValue for a description of the possible values.</p>
331     *
332     * @param uri The Namespace URI, or the empty String if the
333     *        name has no Namespace URI.
334     * @param localPart The local name of the attribute.
335     * @return The attribute value as a string, or null if the
336     *         attribute is not in the list.
337     */
338        virtual const XMLCh* getValue(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
339
340   /**
341     * Look up an attribute's value by XML 1.0 qualified name.
342     *
343     * <p>See #getValue for a description of the possible values.</p>
344     *
345     * @param qName The XML 1.0 qualified name.
346     * @return The attribute value as a string, or null if the
347     *         attribute is not in the list or if qualified names
348     *         are not available.
349     */
350    virtual const XMLCh* getValue(const XMLCh* const qName) const = 0;
351
352    //@}
353
354private :
355    /* Constructors and operators */
356    /* Copy constructor */
357    Attributes(const Attributes&);
358    /* Assignment operator */
359    Attributes& operator=(const Attributes&);
360
361};
362
363XERCES_CPP_NAMESPACE_END
364
365#endif
Note: See TracBrowser for help on using the repository browser.