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: XMLElementDecl.hpp,v $
|
---|
59 | * Revision 1.11 2003/12/12 18:34:43 peiyongz
|
---|
60 | * loadElement/storeElement
|
---|
61 | *
|
---|
62 | * Revision 1.10 2003/11/27 06:08:18 neilg
|
---|
63 | * mark DOMTypeInfo-related methods on XMLElementDecl deprecated since they are not thread-safe
|
---|
64 | *
|
---|
65 | * Revision 1.9 2003/11/24 05:19:15 neilg
|
---|
66 | * update method documentation
|
---|
67 | *
|
---|
68 | * Revision 1.8 2003/10/10 16:23:29 peiyongz
|
---|
69 | * Implementation of Serialization/Deserialization
|
---|
70 | *
|
---|
71 | * Revision 1.7 2003/05/16 21:36:55 knoaman
|
---|
72 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
73 | *
|
---|
74 | * Revision 1.6 2003/05/15 18:26:07 knoaman
|
---|
75 | * Partial implementation of the configurable memory manager.
|
---|
76 | *
|
---|
77 | * Revision 1.5 2003/03/07 18:08:10 tng
|
---|
78 | * Return a reference instead of void for operator=
|
---|
79 | *
|
---|
80 | * Revision 1.4 2003/01/29 19:45:35 gareth
|
---|
81 | * added api for DOMTypeInfo
|
---|
82 | *
|
---|
83 | * Revision 1.3 2002/11/04 15:00:21 tng
|
---|
84 | * C++ Namespace Support.
|
---|
85 | *
|
---|
86 | * Revision 1.2 2002/08/20 16:55:33 tng
|
---|
87 | * [Bug 6251] Info during compilation.
|
---|
88 | *
|
---|
89 | * Revision 1.1.1.1 2002/02/01 22:21:51 peiyongz
|
---|
90 | * sane_include
|
---|
91 | *
|
---|
92 | * Revision 1.18 2001/08/21 16:06:10 tng
|
---|
93 | * Schema: Unique Particle Attribution Constraint Checking.
|
---|
94 | *
|
---|
95 | * Revision 1.17 2001/07/24 18:30:47 knoaman
|
---|
96 | * Added support for <group> + extra constraint checking for complexType
|
---|
97 | *
|
---|
98 | * Revision 1.16 2001/06/21 14:25:28 knoaman
|
---|
99 | * Fix for bug 1946
|
---|
100 | *
|
---|
101 | * Revision 1.15 2001/05/11 13:25:32 tng
|
---|
102 | * Copyright update.
|
---|
103 | *
|
---|
104 | * Revision 1.14 2001/05/03 20:34:22 tng
|
---|
105 | * Schema: SchemaValidator update
|
---|
106 | *
|
---|
107 | * Revision 1.13 2001/04/19 18:16:52 tng
|
---|
108 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
109 | *
|
---|
110 | * Revision 1.12 2001/03/21 21:56:02 tng
|
---|
111 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
112 | *
|
---|
113 | * Revision 1.11 2001/03/21 19:29:29 tng
|
---|
114 | * Schema: Content Model Updates, by Pei Yong Zhang.
|
---|
115 | *
|
---|
116 | * Revision 1.10 2001/02/26 19:29:13 tng
|
---|
117 | * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl.
|
---|
118 | *
|
---|
119 | * Revision 1.9 2001/02/26 19:21:30 tng
|
---|
120 | * Schema: add parameter prefix in findElem and findAttr.
|
---|
121 | *
|
---|
122 | * Revision 1.8 2000/12/14 18:49:57 tng
|
---|
123 | * Fix API document generation warning: "Warning: end of member group without matching begin"
|
---|
124 | *
|
---|
125 | * Revision 1.7 2000/11/30 18:22:38 andyh
|
---|
126 | * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
|
---|
127 | * pools already containing some items. Fixed by Tinny Ng.
|
---|
128 | *
|
---|
129 | * Revision 1.6 2000/05/11 23:11:32 andyh
|
---|
130 | * Add missing validity checks for stand-alone documents, character range
|
---|
131 | * and Well-formed parsed entities. Changes contributed by Sean MacRoibeaird
|
---|
132 | * <sean.Macroibeaird@ireland.sun.com>
|
---|
133 | *
|
---|
134 | * Revision 1.5 2000/02/24 20:00:23 abagchi
|
---|
135 | * Swat for removing Log from API docs
|
---|
136 | *
|
---|
137 | * Revision 1.4 2000/02/16 19:48:56 roddey
|
---|
138 | * More documentation updates
|
---|
139 | *
|
---|
140 | * Revision 1.3 2000/02/15 01:21:30 roddey
|
---|
141 | * Some initial documentation improvements. More to come...
|
---|
142 | *
|
---|
143 | * Revision 1.2 2000/02/06 07:47:48 rahulj
|
---|
144 | * Year 2K copyright swat.
|
---|
145 | *
|
---|
146 | * Revision 1.1.1.1 1999/11/09 01:08:32 twl
|
---|
147 | * Initial checkin
|
---|
148 | *
|
---|
149 | * Revision 1.2 1999/11/08 20:44:38 rahul
|
---|
150 | * Swat for adding in Product name and CVS comment log variable.
|
---|
151 | *
|
---|
152 | */
|
---|
153 |
|
---|
154 | #if !defined(XMLELEMENTDECL_HPP)
|
---|
155 | #define XMLELEMENTDECL_HPP
|
---|
156 |
|
---|
157 | #include <xercesc/framework/XMLAttr.hpp>
|
---|
158 | #include <xercesc/framework/XMLAttDefList.hpp>
|
---|
159 | #include <xercesc/util/XMLString.hpp>
|
---|
160 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
161 | #include <xercesc/internal/XSerializable.hpp>
|
---|
162 |
|
---|
163 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
164 |
|
---|
165 | class ContentSpecNode;
|
---|
166 | class XMLContentModel;
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * This class defines the core information of an element declaration. Each
|
---|
170 | * validator (DTD, Schema, etc...) will have its own information that it
|
---|
171 | * associations with the declaration of an element, but they must all share
|
---|
172 | * at least this core information, i.e. they must all derive from this
|
---|
173 | * class. The set of info enforced at this level is driven by the needs of
|
---|
174 | * XML 1.0 spec validation and well formedness checks.
|
---|
175 | *
|
---|
176 | * This class defines some special element id values for invalid elements
|
---|
177 | * and PCDATA elements, as well as a string for the special PCDATA element
|
---|
178 | * name. All validators must honor these special values in order to allow
|
---|
179 | * content models to work generically (i.e. to let code know when its dealing
|
---|
180 | * with invalid or PCDATA element ids without having to know what type of
|
---|
181 | * validator its messing with.)
|
---|
182 | */
|
---|
183 | class XMLPARSER_EXPORT XMLElementDecl : public XSerializable, public XMemory
|
---|
184 | {
|
---|
185 | public:
|
---|
186 | // -----------------------------------------------------------------------
|
---|
187 | // Class specific types
|
---|
188 | //
|
---|
189 | // CreateReasons
|
---|
190 | // This type is used to store how an element declaration got into
|
---|
191 | // the grammar's element pool. They are faulted in for various
|
---|
192 | // reasons.
|
---|
193 | //
|
---|
194 | // LookupOpts
|
---|
195 | // These are the values used by the attribute lookup methods.
|
---|
196 | //
|
---|
197 | // CharDataOpts
|
---|
198 | // This is used to indicate how this type of element reacts to
|
---|
199 | // character data as content.
|
---|
200 | // -----------------------------------------------------------------------
|
---|
201 | enum CreateReasons
|
---|
202 | {
|
---|
203 | NoReason
|
---|
204 | , Declared
|
---|
205 | , AttList
|
---|
206 | , InContentModel
|
---|
207 | , AsRootElem
|
---|
208 | , JustFaultIn
|
---|
209 | };
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * @deprecated Use of addIfNotFound couldl produce undefined
|
---|
213 | * behaviour in multithreaded environments.
|
---|
214 | */
|
---|
215 | enum LookupOpts
|
---|
216 | {
|
---|
217 | AddIfNotFound
|
---|
218 | , FailIfNotFound
|
---|
219 | };
|
---|
220 |
|
---|
221 | enum CharDataOpts
|
---|
222 | {
|
---|
223 | NoCharData
|
---|
224 | , SpacesOk
|
---|
225 | , AllCharData
|
---|
226 | };
|
---|
227 |
|
---|
228 |
|
---|
229 | // -----------------------------------------------------------------------
|
---|
230 | // Public static data
|
---|
231 | //
|
---|
232 | // fgInvalidElemId
|
---|
233 | // A value to represent an invalid element node id.
|
---|
234 | //
|
---|
235 | // fgPCDataElemId
|
---|
236 | // This is the value to use to represent a PCDATA node when an
|
---|
237 | // element id is required.
|
---|
238 | //
|
---|
239 | // fgPCDataElemName
|
---|
240 | // This is the value to use to represent a PCDATA node when an
|
---|
241 | // element name is required.
|
---|
242 | // -----------------------------------------------------------------------
|
---|
243 | static const unsigned int fgInvalidElemId;
|
---|
244 | static const unsigned int fgPCDataElemId;
|
---|
245 | static const XMLCh fgPCDataElemName[];
|
---|
246 |
|
---|
247 |
|
---|
248 |
|
---|
249 | // -----------------------------------------------------------------------
|
---|
250 | // Destructor
|
---|
251 | // -----------------------------------------------------------------------
|
---|
252 | /** @name Destructor */
|
---|
253 | //@{
|
---|
254 | virtual ~XMLElementDecl();
|
---|
255 | //@}
|
---|
256 |
|
---|
257 |
|
---|
258 | // -----------------------------------------------------------------------
|
---|
259 | // The virtual element decl interface
|
---|
260 | // -----------------------------------------------------------------------
|
---|
261 |
|
---|
262 | /** @name Virual ElementDecl interface */
|
---|
263 | //@{
|
---|
264 |
|
---|
265 | /** Find an attribute by name or optionally fault it in.
|
---|
266 | *
|
---|
267 | * The derived class should look up the passed attribute in the list of
|
---|
268 | * of attributes for this element. If namespaces are enabled, then it
|
---|
269 | * should use the uriId/baseName pair, else it should use the qName. The
|
---|
270 | * options allow the caller to indicate whether the attribute should be
|
---|
271 | * defaulted in if not found. If it is defaulted in, then wasAdded should
|
---|
272 | * be set, else it should be cleared. If its not found and the caller does
|
---|
273 | * not want defaulting, then return a null pointer.
|
---|
274 | * Note that, in a multithreaded environment, it is dangerous for a
|
---|
275 | * caller to invoke this method with options set to AddIfNotFound.
|
---|
276 | *
|
---|
277 | * @param qName This is the qName of the attribute, i.e. the actual
|
---|
278 | * lexical name found.
|
---|
279 | *
|
---|
280 | * @param uriId This is the id of the URI of the namespace to which
|
---|
281 | * this attribute mapped. Only valid if namespaces are
|
---|
282 | * enabled.
|
---|
283 | *
|
---|
284 | * @param baseName This is the base part of the name, i.e. after any
|
---|
285 | * prefix.
|
---|
286 | *
|
---|
287 | * @param prefix The prefix, if any, of this attribute's name. If
|
---|
288 | * this is empty, then uriID is meaningless as well.
|
---|
289 | *
|
---|
290 | * @param options Indicates the lookup options.
|
---|
291 | *
|
---|
292 | * @param wasAdded Should be set if the attribute is faulted in, else
|
---|
293 | * cleared.
|
---|
294 | */
|
---|
295 | virtual XMLAttDef* findAttr
|
---|
296 | (
|
---|
297 | const XMLCh* const qName
|
---|
298 | , const unsigned int uriId
|
---|
299 | , const XMLCh* const baseName
|
---|
300 | , const XMLCh* const prefix
|
---|
301 | , const LookupOpts options
|
---|
302 | , bool& wasAdded
|
---|
303 | ) const = 0;
|
---|
304 |
|
---|
305 | /** Get a list of attributes defined for this element.
|
---|
306 | *
|
---|
307 | * The derived class should return a reference to some member object which
|
---|
308 | * implements the XMLAttDefList interface. This object gives the scanner the
|
---|
309 | * ability to look through the attributes defined for this element.
|
---|
310 | *
|
---|
311 | * It is done this way for efficiency, though of course this is not thread
|
---|
312 | * safe. The scanner guarantees that it won't ever call this method in any
|
---|
313 | * nested way, but the outside world must be careful about when it calls
|
---|
314 | * this method, and optimally never would.
|
---|
315 | */
|
---|
316 | virtual XMLAttDefList& getAttDefList() const = 0;
|
---|
317 |
|
---|
318 | /** The character data options for this element type
|
---|
319 | *
|
---|
320 | * The derived class should return an appropriate character data opts value
|
---|
321 | * which correctly represents its tolerance towards whitespace or character
|
---|
322 | * data inside of its instances. This allows the scanner to do all of the
|
---|
323 | * validation of character data.
|
---|
324 | */
|
---|
325 | virtual CharDataOpts getCharDataOpts() const = 0;
|
---|
326 |
|
---|
327 | /** Indicate whether this element type defined any attributes
|
---|
328 | *
|
---|
329 | * The derived class should return a boolean that indicates whether this
|
---|
330 | * element has any attributes defined for it or not. This is an optimization
|
---|
331 | * that allows the scanner to skip some work if no attributes exist.
|
---|
332 | */
|
---|
333 | virtual bool hasAttDefs() const = 0;
|
---|
334 |
|
---|
335 | /** Reset the flags on the attribute definitions.
|
---|
336 | *
|
---|
337 | * This method is called by the scanner at the beginning of each scan
|
---|
338 | * of a start tag, asking this element decl to reset the 'declared' flag
|
---|
339 | * of each of its attribute defs. This allows the scanner to mark each
|
---|
340 | * one as declared yet or not.
|
---|
341 | */
|
---|
342 | virtual bool resetDefs() = 0;
|
---|
343 |
|
---|
344 | /** Get a pointer to the content spec node
|
---|
345 | *
|
---|
346 | * This method will return a const pointer to the content spec node object
|
---|
347 | * of this element.
|
---|
348 | *
|
---|
349 | * @return A const pointer to the element's content spec node
|
---|
350 | */
|
---|
351 | virtual const ContentSpecNode* getContentSpec() const = 0;
|
---|
352 |
|
---|
353 | /** Get a pointer to the content spec node
|
---|
354 | *
|
---|
355 | * This method is identical to the previous one, except that it is non
|
---|
356 | * const.
|
---|
357 | */
|
---|
358 | virtual ContentSpecNode* getContentSpec() = 0;
|
---|
359 |
|
---|
360 | /** Set the content spec node object for this element type
|
---|
361 | *
|
---|
362 | * This method will adopt the based content spec node object. This is called
|
---|
363 | * by the actual validator which is parsing its DTD or Schema or whatever
|
---|
364 | * and store it on the element decl object via this method.
|
---|
365 | *
|
---|
366 | * @param toAdopt This method will adopt the passed content node spec
|
---|
367 | * object. Any previous object is destroyed.
|
---|
368 | */
|
---|
369 | virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
|
---|
370 |
|
---|
371 | /** Get a pointer to the abstract content model
|
---|
372 | *
|
---|
373 | * This method will return a const pointer to the content model object
|
---|
374 | * of this element. This class is a simple abstraction that allows an
|
---|
375 | * element to define and use multiple, specialized content model types
|
---|
376 | * internally but still allow the outside world to do simple stuff with
|
---|
377 | * them.
|
---|
378 | *
|
---|
379 | * @return A pointer to the element's content model, via the basic
|
---|
380 | * abstract content model type.
|
---|
381 | */
|
---|
382 | virtual XMLContentModel* getContentModel() = 0;
|
---|
383 |
|
---|
384 | /** Set the content model object for this element type
|
---|
385 | *
|
---|
386 | * This method will adopt the based content model object. This is called
|
---|
387 | * by the actual validator which is parsing its DTD or Schema or whatever
|
---|
388 | * a creating an element decl. It will build what it feels is the correct
|
---|
389 | * content model type object and store it on the element decl object via
|
---|
390 | * this method.
|
---|
391 | *
|
---|
392 | * @param newModelToAdopt This method will adopt the passed content model
|
---|
393 | * object. Any previous object is destroyed.
|
---|
394 | */
|
---|
395 | virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
|
---|
396 |
|
---|
397 | /** Geta formatted string of the content model
|
---|
398 | *
|
---|
399 | * This method is a convenience method which will create a formatted
|
---|
400 | * representation of the content model of the element. It will not always
|
---|
401 | * exactly recreate the original model, since some normalization or
|
---|
402 | * or reformatting may occur. But, it will be a technically accurate
|
---|
403 | * representation of the original content model.
|
---|
404 | *
|
---|
405 | * @return A pointer to an internal buffer which contains the formatted
|
---|
406 | * content model. The caller does not own this buffer and should
|
---|
407 | * copy it if it needs to be kept around.
|
---|
408 | */
|
---|
409 | virtual const XMLCh* getFormattedContentModel () const = 0;
|
---|
410 |
|
---|
411 | //@}
|
---|
412 |
|
---|
413 |
|
---|
414 | // -----------------------------------------------------------------------
|
---|
415 | // Getter methods
|
---|
416 | // -----------------------------------------------------------------------
|
---|
417 |
|
---|
418 | /** @name Getter methods */
|
---|
419 | //@{
|
---|
420 |
|
---|
421 | /** Get the base name of this element type.
|
---|
422 | *
|
---|
423 | * Return the base name part of the element's name. This is the
|
---|
424 | * same regardless of whether namespaces are enabled or not.
|
---|
425 | *
|
---|
426 | * @return A const pointer to the base name of the element decl.
|
---|
427 | */
|
---|
428 | const XMLCh* getBaseName() const;
|
---|
429 | XMLCh* getBaseName();
|
---|
430 |
|
---|
431 | /** Get the URI id of this element type.
|
---|
432 | *
|
---|
433 | * Return the URI Id of this element.
|
---|
434 | *
|
---|
435 | * @return The URI Id of the element decl, or the emptyNamespaceId if not applicable.
|
---|
436 | */
|
---|
437 | unsigned int getURI() const;
|
---|
438 |
|
---|
439 | /** Get the QName of this element type.
|
---|
440 | *
|
---|
441 | * Return the QName part of the element's name. This is the
|
---|
442 | * same regardless of whether namespaces are enabled or not.
|
---|
443 | *
|
---|
444 | * @return A const pointer to the QName of the element decl.
|
---|
445 | */
|
---|
446 | const QName* getElementName() const;
|
---|
447 | QName* getElementName();
|
---|
448 |
|
---|
449 | /** Get the full name of this element type.
|
---|
450 | *
|
---|
451 | * Return the full name of the element. If namespaces
|
---|
452 | * are not enabled, then this is the qName. Else it is the {uri}baseName
|
---|
453 | * form. For those validators that always require namespace processing, it
|
---|
454 | * will always be in the latter form because namespace processing will always
|
---|
455 | * be on.
|
---|
456 | */
|
---|
457 | const XMLCh* getFullName() const;
|
---|
458 |
|
---|
459 | /** Get the create reason for this element type
|
---|
460 | *
|
---|
461 | * This method returns an enumeration which indicates why this element
|
---|
462 | * declaration exists. Elements can be used before they are actually
|
---|
463 | * declared, so they will often be faulted into the pool and marked as
|
---|
464 | * to why they are there.
|
---|
465 | *
|
---|
466 | * @return An enumerated value that indicates the reason why this element
|
---|
467 | * was added to the element decl pool.
|
---|
468 | */
|
---|
469 |
|
---|
470 | CreateReasons getCreateReason() const;
|
---|
471 |
|
---|
472 | /** Get the element decl pool id for this element type
|
---|
473 | *
|
---|
474 | * This method will return the element decl pool id of this element
|
---|
475 | * declaration. This uniquely identifies this element type within the
|
---|
476 | * parse event that it is declared within. This value is assigned by the
|
---|
477 | * grammar whose decl pool this object belongs to.
|
---|
478 | *
|
---|
479 | * @return The element decl id of this element declaration.
|
---|
480 | */
|
---|
481 | unsigned int getId() const;
|
---|
482 |
|
---|
483 |
|
---|
484 | /**
|
---|
485 | * @return the uri part of DOM Level 3 TypeInfo
|
---|
486 | * @deprecated
|
---|
487 | */
|
---|
488 | virtual const XMLCh* getDOMTypeInfoUri() const = 0;
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * @return the name part of DOM Level 3 TypeInfo
|
---|
492 | * @deprecated
|
---|
493 | */
|
---|
494 | virtual const XMLCh* getDOMTypeInfoName() const = 0;
|
---|
495 |
|
---|
496 |
|
---|
497 | /** Indicate whether this element type has been declared yet
|
---|
498 | *
|
---|
499 | * This method returns a boolean that indicates whether this element
|
---|
500 | * has been declared yet. There are a number of reasons why an element
|
---|
501 | * declaration can be faulted in, but eventually it must be declared or
|
---|
502 | * its an error. See the CreateReasons enumeration.
|
---|
503 | *
|
---|
504 | * @return true if this element has been declared, else false.
|
---|
505 | */
|
---|
506 | bool isDeclared() const;
|
---|
507 |
|
---|
508 | /** Indicate whether this element type has been declared externally
|
---|
509 | *
|
---|
510 | * This method returns a boolean that indicates whether this element
|
---|
511 | * has been declared externally.
|
---|
512 | *
|
---|
513 | * @return true if this element has been declared externally, else false.
|
---|
514 | */
|
---|
515 |
|
---|
516 | bool isExternal() const;
|
---|
517 |
|
---|
518 | /** Get the memory manager
|
---|
519 | *
|
---|
520 | * This method returns the configurable memory manager used by the
|
---|
521 | * element declaration for dynamic allocation/deacllocation.
|
---|
522 | *
|
---|
523 | * @return the memory manager
|
---|
524 | */
|
---|
525 | MemoryManager* getMemoryManager() const;
|
---|
526 |
|
---|
527 | //@}
|
---|
528 |
|
---|
529 |
|
---|
530 | // -----------------------------------------------------------------------
|
---|
531 | // Setter methods
|
---|
532 | // -----------------------------------------------------------------------
|
---|
533 |
|
---|
534 | /** @name Setter methods */
|
---|
535 | //@{
|
---|
536 |
|
---|
537 | /** Set the element name object for this element type
|
---|
538 | *
|
---|
539 | * This method will adopt the based content spec node object. This is called
|
---|
540 | * by the actual validator which is parsing its DTD or Schema or whatever
|
---|
541 | * and store it on the element decl object via this method.
|
---|
542 | *
|
---|
543 | * @param prefix Prefix of the element
|
---|
544 | * @param localPart Base Name of the element
|
---|
545 | * @param uriId The uriId of the element
|
---|
546 | */
|
---|
547 | void setElementName(const XMLCh* const prefix
|
---|
548 | , const XMLCh* const localPart
|
---|
549 | , const int uriId );
|
---|
550 |
|
---|
551 | /** Set the element name object for this element type
|
---|
552 | *
|
---|
553 | * This method will adopt the based content spec node object. This is called
|
---|
554 | * by the actual validator which is parsing its DTD or Schema or whatever
|
---|
555 | * and store it on the element decl object via this method.
|
---|
556 | *
|
---|
557 | * @param rawName Full Name of the element
|
---|
558 | * @param uriId The uriId of the element
|
---|
559 | */
|
---|
560 | void setElementName(const XMLCh* const rawName
|
---|
561 | , const int uriId );
|
---|
562 |
|
---|
563 | /** Set the element name object for this element type
|
---|
564 | *
|
---|
565 | * This method will adopt the based content spec node object. This is called
|
---|
566 | * by the actual validator which is parsing its DTD or Schema or whatever
|
---|
567 | * and store it on the element decl object via this method.
|
---|
568 | *
|
---|
569 | * @param elementName QName of the element
|
---|
570 | */
|
---|
571 | void setElementName(const QName* const elementName);
|
---|
572 |
|
---|
573 | /** Update the create reason for this element type.
|
---|
574 | *
|
---|
575 | * This method will update the 'create reason' field for this element
|
---|
576 | * decl object. As the validator parses its DTD, Schema, etc... it will
|
---|
577 | * encounter various references to an element declaration, which will
|
---|
578 | * cause the element declaration to either be declared or to be faulted
|
---|
579 | * into the pool in preperation for some future declaration. As it does
|
---|
580 | * so,it will update this field to indicate the current satus of the
|
---|
581 | * decl object.
|
---|
582 | */
|
---|
583 | void setCreateReason(const CreateReasons newReason);
|
---|
584 |
|
---|
585 | /** Set the element decl pool id for this element type
|
---|
586 | *
|
---|
587 | * This method will set the pool id of this element decl. This is called
|
---|
588 | * by the grammar which created this object, and will provide this
|
---|
589 | * decl object with a unique id within the parse event that created it.
|
---|
590 | */
|
---|
591 | void setId(const unsigned int newId);
|
---|
592 |
|
---|
593 |
|
---|
594 | /** Set the element decl to indicate external declaration
|
---|
595 | *
|
---|
596 | */
|
---|
597 | void setExternalElemDeclaration(const bool aValue);
|
---|
598 |
|
---|
599 | //@}
|
---|
600 |
|
---|
601 |
|
---|
602 | // -----------------------------------------------------------------------
|
---|
603 | // Miscellaneous methods
|
---|
604 | // -----------------------------------------------------------------------
|
---|
605 |
|
---|
606 | /** @name Miscellenous methods */
|
---|
607 | //@{
|
---|
608 |
|
---|
609 | //@}
|
---|
610 |
|
---|
611 | /***
|
---|
612 | * Support for Serialization/De-serialization
|
---|
613 | ***/
|
---|
614 | DECL_XSERIALIZABLE(XMLElementDecl)
|
---|
615 |
|
---|
616 | enum objectType
|
---|
617 | {
|
---|
618 | Schema
|
---|
619 | , DTD
|
---|
620 | , UnKnown
|
---|
621 | };
|
---|
622 |
|
---|
623 | virtual XMLElementDecl::objectType getObjectType() const = 0;
|
---|
624 |
|
---|
625 | static void storeElementDecl(XSerializeEngine& serEng
|
---|
626 | , XMLElementDecl* const element);
|
---|
627 |
|
---|
628 | static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
|
---|
629 |
|
---|
630 | protected :
|
---|
631 | // -----------------------------------------------------------------------
|
---|
632 | // Hidden constructors
|
---|
633 | // -----------------------------------------------------------------------
|
---|
634 | XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
635 |
|
---|
636 | private :
|
---|
637 | // -----------------------------------------------------------------------
|
---|
638 | // Unimplemented constructors and operators
|
---|
639 | // -----------------------------------------------------------------------
|
---|
640 | XMLElementDecl(const XMLElementDecl&);
|
---|
641 | XMLElementDecl& operator=(const XMLElementDecl&);
|
---|
642 |
|
---|
643 |
|
---|
644 | // -----------------------------------------------------------------------
|
---|
645 | // Data members
|
---|
646 | //
|
---|
647 | // fElementName
|
---|
648 | // This is the name of the element decl.
|
---|
649 | //
|
---|
650 | // fCreateReason
|
---|
651 | // We sometimes have to put an element decl object into the elem
|
---|
652 | // decl pool before the element's declaration is seen, such as when
|
---|
653 | // its used in another element's content model or an att list is
|
---|
654 | // seen for it. This flag tells us whether its been declared, and
|
---|
655 | // if not why it had to be created.
|
---|
656 | //
|
---|
657 | // fId
|
---|
658 | // The unique id of this element. This is created by the derived
|
---|
659 | // class, or more accurately the grammar that owns the objects
|
---|
660 | // of the derived types. But, since they all have to have them, we
|
---|
661 | // let them all store the id here. It is defaulted to have the
|
---|
662 | // value fgInvalidElem until explicitly set.
|
---|
663 | //
|
---|
664 | // fExternalElement
|
---|
665 | // This flag indicates whether or the element was declared externally.
|
---|
666 | // -----------------------------------------------------------------------
|
---|
667 | MemoryManager* fMemoryManager;
|
---|
668 | QName* fElementName;
|
---|
669 | CreateReasons fCreateReason;
|
---|
670 | unsigned int fId;
|
---|
671 | bool fExternalElement;
|
---|
672 | };
|
---|
673 |
|
---|
674 |
|
---|
675 | // ---------------------------------------------------------------------------
|
---|
676 | // XMLElementDecl: Getter methods
|
---|
677 | // ---------------------------------------------------------------------------
|
---|
678 | inline const XMLCh* XMLElementDecl::getBaseName() const
|
---|
679 | {
|
---|
680 | return fElementName->getLocalPart();
|
---|
681 | }
|
---|
682 |
|
---|
683 | inline XMLCh* XMLElementDecl::getBaseName()
|
---|
684 | {
|
---|
685 | return fElementName->getLocalPart();
|
---|
686 | }
|
---|
687 |
|
---|
688 | inline unsigned int XMLElementDecl::getURI() const
|
---|
689 | {
|
---|
690 | return fElementName->getURI();
|
---|
691 | }
|
---|
692 |
|
---|
693 | inline const QName* XMLElementDecl::getElementName() const
|
---|
694 | {
|
---|
695 | return fElementName;
|
---|
696 | }
|
---|
697 |
|
---|
698 | inline QName* XMLElementDecl::getElementName()
|
---|
699 | {
|
---|
700 | return fElementName;
|
---|
701 | }
|
---|
702 |
|
---|
703 | inline const XMLCh* XMLElementDecl::getFullName() const
|
---|
704 | {
|
---|
705 | return fElementName->getRawName();
|
---|
706 | }
|
---|
707 |
|
---|
708 | inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
|
---|
709 | {
|
---|
710 | return fCreateReason;
|
---|
711 | }
|
---|
712 |
|
---|
713 | inline unsigned int XMLElementDecl::getId() const
|
---|
714 | {
|
---|
715 | return fId;
|
---|
716 | }
|
---|
717 |
|
---|
718 | inline bool XMLElementDecl::isDeclared() const
|
---|
719 | {
|
---|
720 | return (fCreateReason == Declared);
|
---|
721 | }
|
---|
722 |
|
---|
723 |
|
---|
724 | inline bool XMLElementDecl::isExternal() const
|
---|
725 | {
|
---|
726 | return fExternalElement;
|
---|
727 | }
|
---|
728 |
|
---|
729 | inline MemoryManager* XMLElementDecl::getMemoryManager() const
|
---|
730 | {
|
---|
731 | return fMemoryManager;
|
---|
732 | }
|
---|
733 |
|
---|
734 |
|
---|
735 | // ---------------------------------------------------------------------------
|
---|
736 | // XMLElementDecl: Setter methods
|
---|
737 | // ---------------------------------------------------------------------------
|
---|
738 | inline void
|
---|
739 | XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
|
---|
740 | {
|
---|
741 | fCreateReason = newReason;
|
---|
742 | }
|
---|
743 |
|
---|
744 | inline void XMLElementDecl::setId(const unsigned int newId)
|
---|
745 | {
|
---|
746 | fId = newId;
|
---|
747 | }
|
---|
748 |
|
---|
749 |
|
---|
750 | inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
|
---|
751 | {
|
---|
752 | fExternalElement = aValue;
|
---|
753 | }
|
---|
754 |
|
---|
755 | XERCES_CPP_NAMESPACE_END
|
---|
756 |
|
---|
757 | #endif
|
---|