|
||||
File indexing completed on 2024-11-16 09:59:11
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP) 0023 #define XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP 0024 0025 #include <xercesc/util/XercesDefs.hpp> 0026 0027 XERCES_CPP_NAMESPACE_BEGIN 0028 0029 /** 0030 * Interface for an element's attribute specifications. 0031 * 0032 * The SAX parser implements this interface and passes an instance 0033 * to the SAX application as the second argument of each startElement 0034 * event. 0035 * 0036 * The instance provided will return valid results only during the 0037 * scope of the startElement invocation (to save it for future 0038 * use, the application must make a copy: the AttributeListImpl 0039 * helper class provides a convenient constructor for doing so). 0040 * 0041 * An AttributeList includes only attributes that have been 0042 * specified or defaulted: \#IMPLIED attributes will not be included. 0043 * 0044 * There are two ways for the SAX application to obtain information 0045 * from the AttributeList. First, it can iterate through the entire 0046 * list: 0047 * 0048 * <code> 0049 * public void startElement (String name, AttributeList atts) {<br> 0050 * for (XMLSize_t i = 0; i < atts.getLength(); i++) {<br> 0051 * String name = atts.getName(i);<br> 0052 * String type = atts.getType(i);<br> 0053 * String value = atts.getValue(i);<br> 0054 * [...]<br> 0055 * }<br> 0056 * } 0057 * </code> 0058 * 0059 * (Note that the result of getLength() will be zero if there 0060 * are no attributes.) 0061 * 0062 * As an alternative, the application can request the value or 0063 * type of specific attributes: 0064 * 0065 * <code> 0066 * public void startElement (String name, AttributeList atts) {<br> 0067 * String identifier = atts.getValue("id");<br> 0068 * String label = atts.getValue("label");<br> 0069 * [...]<br> 0070 * } 0071 * </code> 0072 * 0073 * The AttributeListImpl helper class provides a convenience 0074 * implementation for use by parser or application writers. 0075 * 0076 * @see DocumentHandler#startElement 0077 * @see AttributeListImpl#AttributeListImpl 0078 */ 0079 0080 class SAX_EXPORT AttributeList 0081 { 0082 public: 0083 // ----------------------------------------------------------------------- 0084 // Constructors and Destructor 0085 // ----------------------------------------------------------------------- 0086 /** @name Constructors and Destructor */ 0087 //@{ 0088 /** Default constructor */ 0089 AttributeList() 0090 { 0091 } 0092 0093 /** Destructor */ 0094 virtual ~AttributeList() 0095 { 0096 } 0097 //@} 0098 0099 /** @name The virtual attribute list interface */ 0100 //@{ 0101 /** 0102 * Return the number of attributes in this list. 0103 * 0104 * The SAX parser may provide attributes in any 0105 * arbitrary order, regardless of the order in which they were 0106 * declared or specified. The number of attributes may be 0107 * zero. 0108 * 0109 * @return The number of attributes in the list. 0110 */ 0111 virtual XMLSize_t getLength() const = 0; 0112 0113 /** 0114 * Return the name of an attribute in this list (by position). 0115 * 0116 * The names must be unique: the SAX parser shall not include the 0117 * same attribute twice. Attributes without values (those declared 0118 * \#IMPLIED without a value specified in the start tag) will be 0119 * omitted from the list. 0120 * 0121 * If the attribute name has a namespace prefix, the prefix 0122 * will still be attached. 0123 * 0124 * @param index The index of the attribute in the list (starting at 0). 0125 * @return The name of the indexed attribute, or null 0126 * if the index is out of range. 0127 * @see #getLength 0128 */ 0129 virtual const XMLCh* getName(const XMLSize_t index) const = 0; 0130 0131 /** 0132 * Return the type of an attribute in the list (by position). 0133 * 0134 * The attribute type is one of the strings "CDATA", "ID", 0135 * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", 0136 * or "NOTATION" (always in upper case). 0137 * 0138 * If the parser has not read a declaration for the attribute, 0139 * or if the parser does not report attribute types, then it must 0140 * return the value "CDATA" as stated in the XML 1.0 Recommendation 0141 * (clause 3.3.3, "Attribute-Value Normalization"). 0142 * 0143 * For an enumerated attribute that is not a notation, the 0144 * parser will report the type as "NMTOKEN". 0145 * 0146 * @param index The index of the attribute in the list (starting at 0). 0147 * @return The attribute type as a string, or 0148 * null if the index is out of range. 0149 * @see #getLength 0150 * @see #getType 0151 */ 0152 virtual const XMLCh* getType(const XMLSize_t index) const = 0; 0153 0154 /** 0155 * Return the value of an attribute in the list (by position). 0156 * 0157 * If the attribute value is a list of tokens (IDREFS, 0158 * ENTITIES, or NMTOKENS), the tokens will be concatenated 0159 * into a single string separated by whitespace. 0160 * 0161 * @param index The index of the attribute in the list (starting at 0). 0162 * @return The attribute value as a string, or 0163 * null if the index is out of range. 0164 * @see #getLength 0165 * @see #getValue 0166 */ 0167 virtual const XMLCh* getValue(const XMLSize_t index) const = 0; 0168 0169 /** 0170 * Return the type of an attribute in the list (by name). 0171 * 0172 * The return value is the same as the return value for 0173 * getType(XMLSize_t). 0174 * 0175 * If the attribute name has a namespace prefix in the document, 0176 * the application must include the prefix here. 0177 * 0178 * @param name The name of the attribute. 0179 * @return The attribute type as a string, or null if no 0180 * such attribute exists. 0181 * @see #getType 0182 */ 0183 virtual const XMLCh* getType(const XMLCh* const name) const = 0; 0184 0185 /** 0186 * Return the value of an attribute in the list (by name). 0187 * 0188 * The return value is the same as the return value for 0189 * getValue(XMLSize_t). 0190 * 0191 * If the attribute name has a namespace prefix in the document, 0192 * the application must include the prefix here. 0193 * 0194 * @param name The name of the attribute in the list. 0195 * @return The attribute value as a string, or null if 0196 * no such attribute exists. 0197 * @see #getValue 0198 */ 0199 virtual const XMLCh* getValue(const XMLCh* const name) const = 0; 0200 0201 /** 0202 * Return the value of an attribute in the list (by name). 0203 * 0204 * The return value is the same as the return value for 0205 * getValue(XMLSize_t). 0206 * 0207 * If the attribute name has a namespace prefix in the document, 0208 * the application must include the prefix here. 0209 * 0210 * @param name The name of the attribute in the list. 0211 * @return The attribute value as a string, or null if 0212 * no such attribute exists. 0213 * @see #getValue 0214 */ 0215 virtual const XMLCh* getValue(const char* const name) const = 0; 0216 //@} 0217 0218 private : 0219 /* Constructors and operators */ 0220 /* Copy constructor */ 0221 AttributeList(const AttributeList&); 0222 /* Assignment operator */ 0223 AttributeList& operator=(const AttributeList&); 0224 0225 }; 0226 0227 XERCES_CPP_NAMESPACE_END 0228 0229 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |