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