1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2003 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: XMLAttr.hpp,v $
|
---|
59 | * Revision 1.9 2003/12/17 00:18:33 cargilld
|
---|
60 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
61 | *
|
---|
62 | * Revision 1.8 2003/11/24 05:19:37 neilg
|
---|
63 | * update XMLAttr class to carry information needed by DOMTypeInfo
|
---|
64 | *
|
---|
65 | * Revision 1.7 2003/05/22 02:10:51 knoaman
|
---|
66 | * Default the memory manager.
|
---|
67 | *
|
---|
68 | * Revision 1.6 2003/05/16 21:36:55 knoaman
|
---|
69 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
70 | *
|
---|
71 | * Revision 1.5 2003/05/15 18:26:07 knoaman
|
---|
72 | * Partial implementation of the configurable memory manager.
|
---|
73 | *
|
---|
74 | * Revision 1.4 2002/11/28 20:12:45 knoaman
|
---|
75 | * Allow creating/setting of XMLAttr using a rawname (i.e. 'prefix:localpart').
|
---|
76 | *
|
---|
77 | * Revision 1.3 2002/11/04 15:00:21 tng
|
---|
78 | * C++ Namespace Support.
|
---|
79 | *
|
---|
80 | * Revision 1.2 2002/02/20 18:17:01 tng
|
---|
81 | * [Bug 5977] Warnings on generating apiDocs.
|
---|
82 | *
|
---|
83 | * Revision 1.1.1.1 2002/02/01 22:21:50 peiyongz
|
---|
84 | * sane_include
|
---|
85 | *
|
---|
86 | * Revision 1.9 2001/11/02 14:21:18 knoaman
|
---|
87 | * Add support for identity constraints.
|
---|
88 | *
|
---|
89 | * Revision 1.8 2001/05/11 13:25:31 tng
|
---|
90 | * Copyright update.
|
---|
91 | *
|
---|
92 | * Revision 1.7 2001/02/27 18:33:55 tng
|
---|
93 | * Schema: Use QName in XMLAttr.
|
---|
94 | *
|
---|
95 | * Revision 1.6 2000/04/10 22:42:53 roddey
|
---|
96 | * Extended the buffer reuse to the QName field, to further increase
|
---|
97 | * performance of attribute heavy applications.
|
---|
98 | *
|
---|
99 | * Revision 1.5 2000/03/02 19:54:24 roddey
|
---|
100 | * This checkin includes many changes done while waiting for the
|
---|
101 | * 1.1.0 code to be finished. I can't list them all here, but a list is
|
---|
102 | * available elsewhere.
|
---|
103 | *
|
---|
104 | * Revision 1.4 2000/02/24 20:00:22 abagchi
|
---|
105 | * Swat for removing Log from API docs
|
---|
106 | *
|
---|
107 | * Revision 1.3 2000/02/15 01:21:30 roddey
|
---|
108 | * Some initial documentation improvements. More to come...
|
---|
109 | *
|
---|
110 | * Revision 1.2 2000/02/06 07:47:47 rahulj
|
---|
111 | * Year 2K copyright swat.
|
---|
112 | *
|
---|
113 | * Revision 1.1.1.1 1999/11/09 01:08:28 twl
|
---|
114 | * Initial checkin
|
---|
115 | *
|
---|
116 | * Revision 1.2 1999/11/08 20:44:35 rahul
|
---|
117 | * Swat for adding in Product name and CVS comment log variable.
|
---|
118 | *
|
---|
119 | */
|
---|
120 |
|
---|
121 | #if !defined(XMLATTR_HPP)
|
---|
122 | #define XMLATTR_HPP
|
---|
123 |
|
---|
124 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
125 | #include <xercesc/util/QName.hpp>
|
---|
126 | #include <xercesc/framework/XMLAttDef.hpp>
|
---|
127 | #include <xercesc/validators/datatype/DatatypeValidator.hpp>
|
---|
128 |
|
---|
129 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * This class defines the information about an attribute that will come out
|
---|
133 | * of the scanner during parsing. This information does not depend upon the
|
---|
134 | * type of validator because it is not tied to any scheme/DTD type info. Its
|
---|
135 | * just the raw XML 1.0 information that will be reported about an attribute
|
---|
136 | * in the startElement() callback method of the XMLDocumentHandler class.
|
---|
137 | * Hence it is not intended to be extended or derived from. Its designed to
|
---|
138 | * be used as is.
|
---|
139 | *
|
---|
140 | * The 'specified' field of this class indicates whether the attribute was
|
---|
141 | * actually present or whether it was faulted in because it had a fixed or
|
---|
142 | * default value.
|
---|
143 | *
|
---|
144 | * The code receiving this information can ask its validator for more info
|
---|
145 | * about the attribute, i.e. get its declaration from the DTD/Schema info.
|
---|
146 | *
|
---|
147 | * Because of the heavy use (and reuse) of instances of this class, and the
|
---|
148 | * number of string members it has, this class takes pains to not reallocate
|
---|
149 | * string members unless it has to. It keeps up with how long each buffer
|
---|
150 | * is and only reallocates if the new value won't fit.
|
---|
151 | */
|
---|
152 | class XMLPARSER_EXPORT XMLAttr : public XMemory
|
---|
153 | {
|
---|
154 | public:
|
---|
155 | // -----------------------------------------------------------------------
|
---|
156 | // Constructors and Destructor
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | /** @name Constructors */
|
---|
159 | //@{
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * The default constructor just setsup an empty attribute to be filled
|
---|
163 | * in the later. Though the initial state is a reasonable one, it is
|
---|
164 | * not documented because it should not be depended on.
|
---|
165 | *
|
---|
166 | * @param manager The configurable memory manager
|
---|
167 | */
|
---|
168 | XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * This is the primary constructor which takes all of the information
|
---|
172 | * required to construct a complete attribute object.
|
---|
173 | *
|
---|
174 | * @param uriId The id into the validator's URI pool of the URI
|
---|
175 | * that the prefix mapped to. Only used if namespaces
|
---|
176 | * are enabled/supported.
|
---|
177 | *
|
---|
178 | * @param attrName The base name of the attribute, i.e. the part
|
---|
179 | * after any prefix.
|
---|
180 | *
|
---|
181 | * @param attrPrefix The prefix, if any, of this attribute's name. If
|
---|
182 | * this is empty, then uriID is meaningless as well.
|
---|
183 | *
|
---|
184 | * @param attrValue The value string of the attribute, which should
|
---|
185 | * be fully normalized by XML rules!
|
---|
186 | *
|
---|
187 | * @param type The type of the attribute. This will indicate
|
---|
188 | * the type of normalization done and constrains
|
---|
189 | * the value content. Make sure that the value
|
---|
190 | * set meets the constraints!
|
---|
191 | *
|
---|
192 | * @param specified Indicates whether the attribute was explicitly
|
---|
193 | * specified or not. If not, then it was faulted
|
---|
194 | * in from a FIXED or DEFAULT value.
|
---|
195 | *
|
---|
196 | * @param manager The configurable memory manager
|
---|
197 | * @param datatypeValidator type used to validate the attribute,
|
---|
198 | * if it was validated by an XML Schema
|
---|
199 | * @param isSchema true if and only if this attribute was validated
|
---|
200 | * by an XML Schema
|
---|
201 | */
|
---|
202 | XMLAttr
|
---|
203 | (
|
---|
204 | const unsigned int uriId
|
---|
205 | , const XMLCh* const attrName
|
---|
206 | , const XMLCh* const attrPrefix
|
---|
207 | , const XMLCh* const attrValue
|
---|
208 | , const XMLAttDef::AttTypes type = XMLAttDef::CData
|
---|
209 | , const bool specified = true
|
---|
210 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
211 | , DatatypeValidator * datatypeValidator = 0
|
---|
212 | , const bool isSchema = false
|
---|
213 | );
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * This is the primary constructor which takes all of the information
|
---|
217 | * required to construct a complete attribute object.
|
---|
218 | *
|
---|
219 | * @param uriId The id into the validator's URI pool of the URI
|
---|
220 | * that the prefix mapped to. Only used if namespaces
|
---|
221 | * are enabled/supported.
|
---|
222 | *
|
---|
223 | * @param rawName The raw name of the attribute.
|
---|
224 | *
|
---|
225 | * @param attrValue The value string of the attribute, which should
|
---|
226 | * be fully normalized by XML rules!
|
---|
227 | *
|
---|
228 | * @param type The type of the attribute. This will indicate
|
---|
229 | * the type of normalization done and constrains
|
---|
230 | * the value content. Make sure that the value
|
---|
231 | * set meets the constraints!
|
---|
232 | *
|
---|
233 | * @param specified Indicates whether the attribute was explicitly
|
---|
234 | * specified or not. If not, then it was faulted
|
---|
235 | * in from a FIXED or DEFAULT value.
|
---|
236 | *
|
---|
237 | * @param manager The configurable memory manager
|
---|
238 | * @param datatypeValidator type used to validate the attribute,
|
---|
239 | * if it was validated by an XML Schema
|
---|
240 | * @param isSchema true if and only if this attribute was validated
|
---|
241 | * by an XML Schema
|
---|
242 | */
|
---|
243 | XMLAttr
|
---|
244 | (
|
---|
245 | const unsigned int uriId
|
---|
246 | , const XMLCh* const rawName
|
---|
247 | , const XMLCh* const attrValue
|
---|
248 | , const XMLAttDef::AttTypes type = XMLAttDef::CData
|
---|
249 | , const bool specified = true
|
---|
250 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
251 | , DatatypeValidator * datatypeValidator = 0
|
---|
252 | , const bool isSchema = false
|
---|
253 | );
|
---|
254 |
|
---|
255 | //@}
|
---|
256 |
|
---|
257 | /** @name Destructor */
|
---|
258 | //@{
|
---|
259 | ~XMLAttr();
|
---|
260 | //@}
|
---|
261 |
|
---|
262 |
|
---|
263 | // -----------------------------------------------------------------------
|
---|
264 | // Getter methods
|
---|
265 | // -----------------------------------------------------------------------
|
---|
266 |
|
---|
267 | /** @name Getter methods */
|
---|
268 | //@{
|
---|
269 |
|
---|
270 | /**
|
---|
271 | * This methode returns the attribute name in a QName format.
|
---|
272 | */
|
---|
273 | QName* getAttName() const;
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * This method gets a const pointer tot he name of the attribute. The
|
---|
277 | * form of this name is defined by the validator in use.
|
---|
278 | */
|
---|
279 | const XMLCh* getName() const;
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * This method will get a const pointer to the prefix string of this
|
---|
283 | * attribute. Since prefixes are optional, it may be zero.
|
---|
284 | */
|
---|
285 | const XMLCh* getPrefix() const;
|
---|
286 |
|
---|
287 | /**
|
---|
288 | * This method will get the QName of this attribute, which will be the
|
---|
289 | * prefix if any, then a colon, then the base name. If there was no
|
---|
290 | * prefix, its the same as the getName() method.
|
---|
291 | */
|
---|
292 | const XMLCh* getQName() const;
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * This method will get the specified flag, which indicates whether
|
---|
296 | * the attribute was explicitly specified or just faulted in.
|
---|
297 | */
|
---|
298 | bool getSpecified() const;
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * This method will get the type of the attribute. The available types
|
---|
302 | * are defined by the XML specification.
|
---|
303 | */
|
---|
304 | XMLAttDef::AttTypes getType() const;
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * This method will get the value of the attribute. The value can be
|
---|
308 | * be an empty string, but never null if the object is correctly
|
---|
309 | * set up.
|
---|
310 | */
|
---|
311 | const XMLCh* getValue() const;
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * This method will get the id of the URI that this attribute's prefix
|
---|
315 | * mapped to. If namespaces are not on, then its value is meaningless.
|
---|
316 | */
|
---|
317 | unsigned int getURIId() const;
|
---|
318 |
|
---|
319 | /**
|
---|
320 | * @return the uri part of DOM Level 3 TypeInfo
|
---|
321 | */
|
---|
322 | const XMLCh* getValidatingTypeURI() const;
|
---|
323 |
|
---|
324 | /**
|
---|
325 | * @return the name part of DOM Level 3 TypeInfo
|
---|
326 | */
|
---|
327 | const XMLCh* getValidatingTypeName() const;
|
---|
328 |
|
---|
329 | //@}
|
---|
330 |
|
---|
331 |
|
---|
332 | // -----------------------------------------------------------------------
|
---|
333 | // Setter methods
|
---|
334 | // -----------------------------------------------------------------------
|
---|
335 |
|
---|
336 | /** @name Setter methods */
|
---|
337 | //@{
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * This method is called to set up a default constructed object after
|
---|
341 | * the fact, or to reuse a previously used object.
|
---|
342 | *
|
---|
343 | * @param uriId The id into the validator's URI pool of the URI
|
---|
344 | * that the prefix mapped to. Only used if namespaces
|
---|
345 | * are enabled/supported.
|
---|
346 | *
|
---|
347 | * @param attrName The base name of the attribute, i.e. the part
|
---|
348 | * after any prefix.
|
---|
349 | *
|
---|
350 | * @param attrPrefix The prefix, if any, of this attribute's name. If
|
---|
351 | * this is empty, then uriID is meaningless as well.
|
---|
352 | *
|
---|
353 | * @param attrValue The value string of the attribute, which should
|
---|
354 | * be fully normalized by XML rules according to the
|
---|
355 | * attribute type.
|
---|
356 | *
|
---|
357 | * @param type The type of the attribute. This will indicate
|
---|
358 | * the type of normalization done and constrains
|
---|
359 | * the value content. Make sure that the value
|
---|
360 | * set meets the constraints!
|
---|
361 | * @param datatypeValidator type used to validate the attribute,
|
---|
362 | * if it was validated by an XML Schema
|
---|
363 | * @param isSchema true if and only if this attribute was validated
|
---|
364 | * by an XML Schema
|
---|
365 | *
|
---|
366 | */
|
---|
367 | void set
|
---|
368 | (
|
---|
369 | const unsigned int uriId
|
---|
370 | , const XMLCh* const attrName
|
---|
371 | , const XMLCh* const attrPrefix
|
---|
372 | , const XMLCh* const attrValue
|
---|
373 | , const XMLAttDef::AttTypes type = XMLAttDef::CData
|
---|
374 | , DatatypeValidator * datatypeValidator = 0
|
---|
375 | , const bool isSchema = false
|
---|
376 | );
|
---|
377 |
|
---|
378 | /**
|
---|
379 | * This method is called to set up a default constructed object after
|
---|
380 | * the fact, or to reuse a previously used object.
|
---|
381 | *
|
---|
382 | * @param uriId The id into the validator's URI pool of the URI
|
---|
383 | * that the prefix mapped to. Only used if namespaces
|
---|
384 | * are enabled/supported.
|
---|
385 | *
|
---|
386 | * @param attrRawName The raw name of the attribute.
|
---|
387 | *
|
---|
388 | * @param attrValue The value string of the attribute, which should
|
---|
389 | * be fully normalized by XML rules according to the
|
---|
390 | * attribute type.
|
---|
391 | *
|
---|
392 | * @param type The type of the attribute. This will indicate
|
---|
393 | * the type of normalization done and constrains
|
---|
394 | * the value content. Make sure that the value
|
---|
395 | * set meets the constraints!
|
---|
396 | * @param datatypeValidator type used to validate the attribute,
|
---|
397 | * if it was validated by an XML Schema
|
---|
398 | * @param isSchema true if and only if this attribute was validated
|
---|
399 | * by an XML Schema
|
---|
400 | */
|
---|
401 | void set
|
---|
402 | (
|
---|
403 | const unsigned int uriId
|
---|
404 | , const XMLCh* const attrRawName
|
---|
405 | , const XMLCh* const attrValue
|
---|
406 | , const XMLAttDef::AttTypes type = XMLAttDef::CData
|
---|
407 | , DatatypeValidator * datatypeValidator = 0
|
---|
408 | , const bool isSchema = false
|
---|
409 | );
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * This method will update just the name related fields of the
|
---|
413 | * attribute object. The other fields are left as is.
|
---|
414 | *
|
---|
415 | * @param uriId The id into the validator's URI pool of the URI
|
---|
416 | * that the prefix mapped to. Only used if namespaces
|
---|
417 | * are enabled/supported.
|
---|
418 | *
|
---|
419 | * @param attrName The base name of the attribute, i.e. the part
|
---|
420 | * after any prefix.
|
---|
421 | *
|
---|
422 | * @param attrPrefix The prefix, if any, of this attribute's name. If
|
---|
423 | * this is empty, then uriID is meaningless as well.
|
---|
424 | */
|
---|
425 | void setName
|
---|
426 | (
|
---|
427 | const unsigned int uriId
|
---|
428 | , const XMLCh* const attrName
|
---|
429 | , const XMLCh* const attrPrefix
|
---|
430 | );
|
---|
431 |
|
---|
432 | /**
|
---|
433 | * This method will update the specified state of the object.
|
---|
434 | *
|
---|
435 | * @param newValue Indicates whether the attribute was explicitly
|
---|
436 | * specified or not. If not, then it was faulted
|
---|
437 | * in from a FIXED or DEFAULT value.
|
---|
438 | */
|
---|
439 | void setSpecified(const bool newValue);
|
---|
440 |
|
---|
441 | /**
|
---|
442 | * This method will update the attribute type of the object.
|
---|
443 | *
|
---|
444 | * @param newType The type of the attribute. This will indicate
|
---|
445 | * the type of normalization done and constrains
|
---|
446 | * the value content. Make sure that the value
|
---|
447 | * set meets the constraints!
|
---|
448 | */
|
---|
449 | void setType(const XMLAttDef::AttTypes newType);
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * This method will update the value field of the attribute.
|
---|
453 | *
|
---|
454 | * @param newValue The value string of the attribute, which should
|
---|
455 | * be fully normalized by XML rules according to the
|
---|
456 | * attribute type.
|
---|
457 | */
|
---|
458 | void setValue(const XMLCh* const newValue);
|
---|
459 |
|
---|
460 | /**
|
---|
461 | * This method will set the URI id field of this attribute. This is
|
---|
462 | * generally only ever called internally by the parser itself during
|
---|
463 | * the parsing process.
|
---|
464 | *
|
---|
465 | * @param uriId The uriId of the attribute.
|
---|
466 | */
|
---|
467 | void setURIId(const unsigned int uriId);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * This method will update the datatype validator that was used
|
---|
471 | * to assess the validity of the value of this attribute.
|
---|
472 | * @param datatypeValidator DatatypeValidator used to assess the validity
|
---|
473 | * of this attribute's value
|
---|
474 | */
|
---|
475 | void setDatatypeValidator(DatatypeValidator * datatypeValidator);
|
---|
476 |
|
---|
477 | /**
|
---|
478 | * This method will define whether the attribute was
|
---|
479 | * validated by an XML Schema
|
---|
480 | * @param isSchema true indicates that this attribute was validated
|
---|
481 | * by an XML Schema; false indicates otherwise
|
---|
482 | */
|
---|
483 | void setSchemaValidated(const bool isSchema);
|
---|
484 |
|
---|
485 | //@}
|
---|
486 |
|
---|
487 |
|
---|
488 |
|
---|
489 | private :
|
---|
490 | // -----------------------------------------------------------------------
|
---|
491 | // Unimplemented constructors and operators
|
---|
492 | // -----------------------------------------------------------------------
|
---|
493 | XMLAttr(const XMLAttr&);
|
---|
494 | XMLAttr& operator=(const XMLAttr&);
|
---|
495 |
|
---|
496 |
|
---|
497 | // -----------------------------------------------------------------------
|
---|
498 | // Private, helper methods
|
---|
499 | // -----------------------------------------------------------------------
|
---|
500 | void cleanUp();
|
---|
501 |
|
---|
502 |
|
---|
503 | // -----------------------------------------------------------------------
|
---|
504 | // Private instance variables
|
---|
505 | //
|
---|
506 | // fAttName
|
---|
507 | // The Attribute Name;
|
---|
508 | //
|
---|
509 | // fSpecified
|
---|
510 | // True if this attribute appeared in the element; else, false if
|
---|
511 | // it was defaulted from an AttDef.
|
---|
512 | //
|
---|
513 | // fType
|
---|
514 | // The attribute type enum value for this attribute. Indicates what
|
---|
515 | // type of attribute it was.
|
---|
516 | //
|
---|
517 | // fValue
|
---|
518 | // fValueBufSz
|
---|
519 | // The attribute value that was given in the attribute instance, and
|
---|
520 | // its current buffer size (minus one, where the null is.)
|
---|
521 | //
|
---|
522 | // fMemoryManager
|
---|
523 | // The memory manager used for dynamic memory allocation/deallocation
|
---|
524 | // fDatatypeValidator
|
---|
525 | // The validator used to validate the value of this attribute.
|
---|
526 | // The attribute does not own this object, and it is only
|
---|
527 | // used in the calculation of DOMTypeInfo information.
|
---|
528 | // fIsSchemaValidated
|
---|
529 | // whether this attribute was validated by an XML Schema
|
---|
530 | //
|
---|
531 | // -----------------------------------------------------------------------
|
---|
532 | bool fSpecified;
|
---|
533 | XMLAttDef::AttTypes fType;
|
---|
534 | unsigned int fValueBufSz;
|
---|
535 | XMLCh* fValue;
|
---|
536 | QName* fAttName;
|
---|
537 | MemoryManager* fMemoryManager;
|
---|
538 | DatatypeValidator * fDatatypeValidator;
|
---|
539 | bool fIsSchemaValidated;
|
---|
540 | };
|
---|
541 |
|
---|
542 | // ---------------------------------------------------------------------------
|
---|
543 | // XMLAttr: Constructors and Destructor
|
---|
544 | // ---------------------------------------------------------------------------
|
---|
545 | inline XMLAttr::~XMLAttr()
|
---|
546 | {
|
---|
547 | cleanUp();
|
---|
548 | }
|
---|
549 |
|
---|
550 |
|
---|
551 | // ---------------------------------------------------------------------------
|
---|
552 | // XMLAttr: Getter methods
|
---|
553 | // ---------------------------------------------------------------------------
|
---|
554 | inline QName* XMLAttr::getAttName() const
|
---|
555 | {
|
---|
556 | return fAttName;
|
---|
557 | }
|
---|
558 |
|
---|
559 | inline const XMLCh* XMLAttr::getName() const
|
---|
560 | {
|
---|
561 | return fAttName->getLocalPart();
|
---|
562 | }
|
---|
563 |
|
---|
564 | inline const XMLCh* XMLAttr::getPrefix() const
|
---|
565 | {
|
---|
566 | return fAttName->getPrefix();
|
---|
567 | }
|
---|
568 |
|
---|
569 | inline bool XMLAttr::getSpecified() const
|
---|
570 | {
|
---|
571 | return fSpecified;
|
---|
572 | }
|
---|
573 |
|
---|
574 | inline XMLAttDef::AttTypes XMLAttr::getType() const
|
---|
575 | {
|
---|
576 | return fType;
|
---|
577 | }
|
---|
578 |
|
---|
579 | inline const XMLCh* XMLAttr::getValue() const
|
---|
580 | {
|
---|
581 | return fValue;
|
---|
582 | }
|
---|
583 |
|
---|
584 | inline unsigned int XMLAttr::getURIId() const
|
---|
585 | {
|
---|
586 | return fAttName->getURI();
|
---|
587 | }
|
---|
588 |
|
---|
589 | inline const XMLCh* XMLAttr::getValidatingTypeName() const
|
---|
590 | {
|
---|
591 | if(fIsSchemaValidated)
|
---|
592 | {
|
---|
593 | if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
|
---|
594 | return 0;
|
---|
595 | return fDatatypeValidator->getTypeLocalName();
|
---|
596 | }
|
---|
597 | else
|
---|
598 | {
|
---|
599 | return XMLAttDef::getAttTypeString(fType, fMemoryManager);
|
---|
600 | }
|
---|
601 | }
|
---|
602 |
|
---|
603 | inline const XMLCh* XMLAttr::getValidatingTypeURI() const
|
---|
604 | {
|
---|
605 | if(fIsSchemaValidated)
|
---|
606 | {
|
---|
607 | if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
|
---|
608 | return 0;
|
---|
609 | return fDatatypeValidator->getTypeUri();
|
---|
610 | }
|
---|
611 | else
|
---|
612 | {
|
---|
613 | return 0;
|
---|
614 | }
|
---|
615 | }
|
---|
616 |
|
---|
617 | // ---------------------------------------------------------------------------
|
---|
618 | // XMLAttr: Setter methods
|
---|
619 | // ---------------------------------------------------------------------------
|
---|
620 | inline void XMLAttr::set(const unsigned int uriId
|
---|
621 | , const XMLCh* const attrName
|
---|
622 | , const XMLCh* const attrPrefix
|
---|
623 | , const XMLCh* const attrValue
|
---|
624 | , const XMLAttDef::AttTypes type
|
---|
625 | , DatatypeValidator * datatypeValidator
|
---|
626 | , const bool isSchema )
|
---|
627 | {
|
---|
628 | // Set the name info and the value via their respective calls
|
---|
629 | fAttName->setName(attrPrefix, attrName, uriId);
|
---|
630 | setValue(attrValue);
|
---|
631 |
|
---|
632 | // And store the type
|
---|
633 | fType = type;
|
---|
634 |
|
---|
635 | // and set up info for DOM type info
|
---|
636 | fIsSchemaValidated = isSchema;
|
---|
637 | fDatatypeValidator = datatypeValidator;
|
---|
638 | }
|
---|
639 |
|
---|
640 | inline void XMLAttr::set(const unsigned int uriId
|
---|
641 | , const XMLCh* const attrRawName
|
---|
642 | , const XMLCh* const attrValue
|
---|
643 | , const XMLAttDef::AttTypes type
|
---|
644 | , DatatypeValidator * datatypeValidator
|
---|
645 | , const bool isSchema )
|
---|
646 | {
|
---|
647 | // Set the name info and the value via their respective calls
|
---|
648 | fAttName->setName(attrRawName, uriId);
|
---|
649 | setValue(attrValue);
|
---|
650 |
|
---|
651 | // And store the type
|
---|
652 | fType = type;
|
---|
653 |
|
---|
654 | // and set up info for DOM type info
|
---|
655 | fIsSchemaValidated = isSchema;
|
---|
656 | fDatatypeValidator = datatypeValidator;
|
---|
657 | }
|
---|
658 |
|
---|
659 | inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
|
---|
660 | {
|
---|
661 | fType = newValue;
|
---|
662 | }
|
---|
663 |
|
---|
664 | inline void XMLAttr::setSpecified(const bool newValue)
|
---|
665 | {
|
---|
666 | fSpecified = newValue;
|
---|
667 | }
|
---|
668 |
|
---|
669 | inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
|
---|
670 | {
|
---|
671 | fDatatypeValidator = datatypeValidator;
|
---|
672 | }
|
---|
673 |
|
---|
674 | inline void XMLAttr::setSchemaValidated(const bool isSchema)
|
---|
675 | {
|
---|
676 | fIsSchemaValidated = isSchema;
|
---|
677 | }
|
---|
678 |
|
---|
679 | XERCES_CPP_NAMESPACE_END
|
---|
680 |
|
---|
681 | #endif
|
---|