1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: DOMParser.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | #if !defined(DOMPARSER_HPP) |
---|
24 | #define DOMPARSER_HPP |
---|
25 | |
---|
26 | #include <xercesc/framework/XMLDocumentHandler.hpp> |
---|
27 | #include <xercesc/framework/XMLErrorReporter.hpp> |
---|
28 | #include <xercesc/framework/XMLEntityHandler.hpp> |
---|
29 | #include <xercesc/util/ValueStackOf.hpp> |
---|
30 | #include <xercesc/validators/DTD/DocTypeHandler.hpp> |
---|
31 | #include <xercesc/validators/DTD/DTDElementDecl.hpp> |
---|
32 | #include "DOM_Document.hpp" |
---|
33 | #include "DOM_DocumentType.hpp" |
---|
34 | |
---|
35 | XERCES_CPP_NAMESPACE_BEGIN |
---|
36 | |
---|
37 | |
---|
38 | class EntityResolver; |
---|
39 | class ErrorHandler; |
---|
40 | class XMLPScanToken; |
---|
41 | class XMLScanner; |
---|
42 | class XMLValidator; |
---|
43 | class Grammar; |
---|
44 | class GrammarResolver; |
---|
45 | class XMLGrammarPool; |
---|
46 | class XMLEntityResolver; |
---|
47 | class PSVIHandler; |
---|
48 | |
---|
49 | /** |
---|
50 | * This class implements the Document Object Model (DOM) interface. |
---|
51 | * It should be used by applications which choose to parse and |
---|
52 | * process the XML document using the DOM api's. This implementation |
---|
53 | * also allows the applications to install an error and an entitty |
---|
54 | * handler (useful extensions to the DOM specification). |
---|
55 | * |
---|
56 | * <p>It can be used to instantiate a validating or non-validating |
---|
57 | * parser, by setting a member flag.</p> |
---|
58 | */ |
---|
59 | class DEPRECATED_DOM_EXPORT DOMParser : |
---|
60 | |
---|
61 | public XMLDocumentHandler |
---|
62 | , public XMLErrorReporter |
---|
63 | , public XMLEntityHandler |
---|
64 | , public DocTypeHandler |
---|
65 | , public XMemory |
---|
66 | { |
---|
67 | public : |
---|
68 | // ----------------------------------------------------------------------- |
---|
69 | // Class types |
---|
70 | // ----------------------------------------------------------------------- |
---|
71 | enum ValSchemes |
---|
72 | { |
---|
73 | Val_Never |
---|
74 | , Val_Always |
---|
75 | , Val_Auto |
---|
76 | }; |
---|
77 | |
---|
78 | |
---|
79 | // ----------------------------------------------------------------------- |
---|
80 | // Constructors and Detructor |
---|
81 | // ----------------------------------------------------------------------- |
---|
82 | |
---|
83 | /** @name Constructors and Destructor */ |
---|
84 | //@{ |
---|
85 | /** Construct a DOMParser, with an optional validator |
---|
86 | * |
---|
87 | * Constructor with an instance of validator class to use for |
---|
88 | * validation. If you don't provide a validator, a default one will |
---|
89 | * be created for you in the scanner. |
---|
90 | * |
---|
91 | * @param valToAdopt Pointer to the validator instance to use. The |
---|
92 | * parser is responsible for freeing the memory. |
---|
93 | */ |
---|
94 | DOMParser |
---|
95 | ( |
---|
96 | XMLValidator* const valToAdopt = 0 |
---|
97 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
98 | , XMLGrammarPool* const gramPool = 0 |
---|
99 | ); |
---|
100 | |
---|
101 | /** |
---|
102 | * Destructor |
---|
103 | */ |
---|
104 | ~DOMParser(); |
---|
105 | |
---|
106 | //@} |
---|
107 | |
---|
108 | /** Reset the parser |
---|
109 | * |
---|
110 | * This method resets the state of the DOM driver and makes |
---|
111 | * it ready for a fresh parse run. |
---|
112 | */ |
---|
113 | void reset(); |
---|
114 | |
---|
115 | |
---|
116 | // ----------------------------------------------------------------------- |
---|
117 | // Getter methods |
---|
118 | // ----------------------------------------------------------------------- |
---|
119 | |
---|
120 | /** @name Getter methods */ |
---|
121 | //@{ |
---|
122 | |
---|
123 | /** Get the DOM document |
---|
124 | * |
---|
125 | * This method returns the DOM_Document object representing the |
---|
126 | * root of the document tree. This object provides the primary |
---|
127 | * access to the document's data. |
---|
128 | * |
---|
129 | * @return The DOM_Document object which represents the entire |
---|
130 | * XML document. |
---|
131 | */ |
---|
132 | DOM_Document getDocument(); |
---|
133 | |
---|
134 | /** Get a pointer to the error handler |
---|
135 | * |
---|
136 | * This method returns the installed error handler. If no handler |
---|
137 | * has been installed, then it will be a zero pointer. |
---|
138 | * |
---|
139 | * @return The pointer to the installed error handler object. |
---|
140 | */ |
---|
141 | ErrorHandler* getErrorHandler(); |
---|
142 | |
---|
143 | /** Get a const pointer to the error handler |
---|
144 | * |
---|
145 | * This method returns the installed error handler. If no handler |
---|
146 | * has been installed, then it will be a zero pointer. |
---|
147 | * |
---|
148 | * @return A const pointer to the installed error handler object. |
---|
149 | */ |
---|
150 | const ErrorHandler* getErrorHandler() const; |
---|
151 | |
---|
152 | /** Get a pointer to the PSVI handler |
---|
153 | * |
---|
154 | * This method returns the installed PSVI handler. If no handler |
---|
155 | * has been installed, then it will be a zero pointer. |
---|
156 | * |
---|
157 | * @return The pointer to the installed PSVI handler object. |
---|
158 | */ |
---|
159 | PSVIHandler* getPSVIHandler(); |
---|
160 | |
---|
161 | /** Get a const pointer to the error handler |
---|
162 | * |
---|
163 | * This method returns the installed error handler. If no handler |
---|
164 | * has been installed, then it will be a zero pointer. |
---|
165 | * |
---|
166 | * @return A const pointer to the installed error handler object. |
---|
167 | */ |
---|
168 | const PSVIHandler* getPSVIHandler() const; |
---|
169 | |
---|
170 | /** Get a pointer to the entity resolver |
---|
171 | * |
---|
172 | * This method returns the installed entity resolver. If no resolver |
---|
173 | * has been installed, then it will be a zero pointer. |
---|
174 | * |
---|
175 | * @return The pointer to the installed entity resolver object. |
---|
176 | */ |
---|
177 | EntityResolver* getEntityResolver(); |
---|
178 | |
---|
179 | /** Get a const pointer to the entity resolver |
---|
180 | * |
---|
181 | * This method returns the installed entity resolver. If no resolver |
---|
182 | * has been installed, then it will be a zero pointer. |
---|
183 | * |
---|
184 | * @return A const pointer to the installed entity resolver object. |
---|
185 | */ |
---|
186 | const EntityResolver* getEntityResolver() const; |
---|
187 | |
---|
188 | /** Get a pointer to the entity resolver |
---|
189 | * |
---|
190 | * This method returns the installed entity resolver. If no resolver |
---|
191 | * has been installed, then it will be a zero pointer. |
---|
192 | * |
---|
193 | * @return The pointer to the installed entity resolver object. |
---|
194 | */ |
---|
195 | XMLEntityResolver* getXMLEntityResolver(); |
---|
196 | |
---|
197 | /** Get a const pointer to the entity resolver |
---|
198 | * |
---|
199 | * This method returns the installed entity resolver. If no resolver |
---|
200 | * has been installed, then it will be a zero pointer. |
---|
201 | * |
---|
202 | * @return A const pointer to the installed entity resolver object. |
---|
203 | */ |
---|
204 | const XMLEntityResolver* getXMLEntityResolver() const; |
---|
205 | |
---|
206 | /** Get a const reference to the underlying scanner |
---|
207 | * |
---|
208 | * This method returns a reference to the underlying scanner object. |
---|
209 | * It allows read only access to data maintained in the scanner. |
---|
210 | * |
---|
211 | * @return A const reference to the underlying scanner object. |
---|
212 | */ |
---|
213 | const XMLScanner& getScanner() const; |
---|
214 | |
---|
215 | /** Get a const reference to the validator |
---|
216 | * |
---|
217 | * This method returns a reference to the parser's installed |
---|
218 | * validator. |
---|
219 | * |
---|
220 | * @return A const reference to the installed validator object. |
---|
221 | */ |
---|
222 | const XMLValidator& getValidator() const; |
---|
223 | |
---|
224 | /** |
---|
225 | * This method returns an enumerated value that indicates the current |
---|
226 | * validation scheme set on this parser. |
---|
227 | * |
---|
228 | * @return The ValSchemes value current set on this parser. |
---|
229 | * @see #setValidationScheme |
---|
230 | */ |
---|
231 | ValSchemes getValidationScheme() const; |
---|
232 | |
---|
233 | /** Get the 'do schema' flag |
---|
234 | * |
---|
235 | * This method returns the state of the parser's schema processing |
---|
236 | * flag. |
---|
237 | * |
---|
238 | * @return true, if the parser is currently configured to |
---|
239 | * understand schema, false otherwise. |
---|
240 | * |
---|
241 | * @see #setDoSchema |
---|
242 | */ |
---|
243 | bool getDoSchema() const; |
---|
244 | |
---|
245 | /** Get the 'full schema constraint checking' flag |
---|
246 | * |
---|
247 | * This method returns the state of the parser's full schema constraint |
---|
248 | * checking flag. |
---|
249 | * |
---|
250 | * @return true, if the parser is currently configured to |
---|
251 | * have full schema constraint checking, false otherwise. |
---|
252 | * |
---|
253 | * @see #setValidationSchemaFullChecking |
---|
254 | */ |
---|
255 | bool getValidationSchemaFullChecking() const; |
---|
256 | |
---|
257 | bool getIdentityConstraintChecking() const; |
---|
258 | |
---|
259 | /** Get error count from the last parse operation. |
---|
260 | * |
---|
261 | * This method returns the error count from the last parse |
---|
262 | * operation. Note that this count is actually stored in the |
---|
263 | * scanner, so this method simply returns what the |
---|
264 | * scanner reports. |
---|
265 | * |
---|
266 | * @return number of errors encountered during the latest |
---|
267 | * parse operation. |
---|
268 | * |
---|
269 | */ |
---|
270 | int getErrorCount() const; |
---|
271 | |
---|
272 | /** Get the 'do namespaces' flag |
---|
273 | * |
---|
274 | * This method returns the state of the parser's namespace processing |
---|
275 | * flag. |
---|
276 | * |
---|
277 | * @return true, if the parser is currently configured to |
---|
278 | * understand namespaces, false otherwise. |
---|
279 | * |
---|
280 | * @see #setDoNamespaces |
---|
281 | */ |
---|
282 | bool getDoNamespaces() const; |
---|
283 | |
---|
284 | /** Get the 'exit on first error' flag |
---|
285 | * |
---|
286 | * This method returns the state of the parser's |
---|
287 | * exit-on-First-Fatal-Error flag. If this flag is true, then the |
---|
288 | * parse will exit the first time it sees any non-wellformed XML or |
---|
289 | * any validity error. The default state is true. |
---|
290 | * |
---|
291 | * @return true, if the parser is currently configured to |
---|
292 | * exit on the first fatal error, false otherwise. |
---|
293 | * |
---|
294 | * @see #setExitOnFirstFatalError |
---|
295 | */ |
---|
296 | bool getExitOnFirstFatalError() const; |
---|
297 | |
---|
298 | /** |
---|
299 | * This method returns the state of the parser's |
---|
300 | * validation-constraint-fatal flag. |
---|
301 | * |
---|
302 | * @return true, if the parser is currently configured to |
---|
303 | * set validation constraint errors as fatal, false |
---|
304 | * otherwise. |
---|
305 | * |
---|
306 | * @see #setValidationContraintFatal |
---|
307 | */ |
---|
308 | bool getValidationConstraintFatal() const; |
---|
309 | |
---|
310 | /** Get the 'include entity references' flag |
---|
311 | * |
---|
312 | * This method returns the flag that specifies whether the parser is |
---|
313 | * creating entity reference nodes in the DOM tree being produced. |
---|
314 | * |
---|
315 | * @return The state of the create entity reference node |
---|
316 | * flag. |
---|
317 | * @see #setCreateEntityReferenceNodes |
---|
318 | */ |
---|
319 | bool getCreateEntityReferenceNodes()const; |
---|
320 | |
---|
321 | /** Get the 'include ignorable whitespace' flag. |
---|
322 | * |
---|
323 | * This method returns the state of the parser's include ignorable |
---|
324 | * whitespace flag. |
---|
325 | * |
---|
326 | * @return 'true' if the include ignorable whitespace flag is set on |
---|
327 | * the parser, 'false' otherwise. |
---|
328 | * |
---|
329 | * @see #setIncludeIgnorableWhitespace |
---|
330 | */ |
---|
331 | bool getIncludeIgnorableWhitespace() const; |
---|
332 | |
---|
333 | /** Get the 'to create MXLDecl node' flag. |
---|
334 | * |
---|
335 | * This method returns the state of the parser's to create XMLDecl |
---|
336 | * DOM Node flag. |
---|
337 | * |
---|
338 | * @return 'true' if the toCreateXMLDeclTypeNode flag is set on |
---|
339 | * the parser, 'false' otherwise. |
---|
340 | * |
---|
341 | */ |
---|
342 | bool getToCreateXMLDeclTypeNode() const; |
---|
343 | |
---|
344 | /** Get the set of Namespace/SchemaLocation that is specified externaly. |
---|
345 | * |
---|
346 | * This method returns the list of Namespace/SchemaLocation that was |
---|
347 | * specified using setExternalSchemaLocation. |
---|
348 | * |
---|
349 | * The parser owns the returned string, and the memory allocated for |
---|
350 | * the returned string will be destroyed when the parser is deleted. |
---|
351 | * |
---|
352 | * To ensure assessiblity of the returned information after the parser |
---|
353 | * is deleted, callers need to copy and store the returned information |
---|
354 | * somewhere else. |
---|
355 | * |
---|
356 | * @return a pointer to the list of Namespace/SchemaLocation that was |
---|
357 | * specified externally. The pointer spans the same life-time as |
---|
358 | * the parser. A null pointer is returned if nothing |
---|
359 | * was specified externally. |
---|
360 | * |
---|
361 | * @see #setExternalSchemaLocation(const XMLCh* const) |
---|
362 | */ |
---|
363 | XMLCh* getExternalSchemaLocation() const; |
---|
364 | |
---|
365 | /** Get the noNamespace SchemaLocation that is specified externaly. |
---|
366 | * |
---|
367 | * This method returns the no target namespace XML Schema Location |
---|
368 | * that was specified using setExternalNoNamespaceSchemaLocation. |
---|
369 | * |
---|
370 | * The parser owns the returned string, and the memory allocated for |
---|
371 | * the returned string will be destroyed when the parser is deleted. |
---|
372 | * |
---|
373 | * To ensure assessiblity of the returned information after the parser |
---|
374 | * is deleted, callers need to copy and store the returned information |
---|
375 | * somewhere else. |
---|
376 | * |
---|
377 | * @return a pointer to the no target namespace Schema Location that was |
---|
378 | * specified externally. The pointer spans the same life-time as |
---|
379 | * the parser. A null pointer is returned if nothing |
---|
380 | * was specified externally. |
---|
381 | * |
---|
382 | * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const) |
---|
383 | */ |
---|
384 | XMLCh* getExternalNoNamespaceSchemaLocation() const; |
---|
385 | |
---|
386 | /** Get the 'Grammar caching' flag |
---|
387 | * |
---|
388 | * This method returns the state of the parser's grammar caching when |
---|
389 | * parsing an XML document. |
---|
390 | * |
---|
391 | * @return true, if the parser is currently configured to |
---|
392 | * cache grammars, false otherwise. |
---|
393 | * |
---|
394 | * @see #cacheGrammarFromParse |
---|
395 | */ |
---|
396 | bool isCachingGrammarFromParse() const; |
---|
397 | |
---|
398 | /** Get the 'Use cached grammar' flag |
---|
399 | * |
---|
400 | * This method returns the state of the parser's use of cached grammar |
---|
401 | * when parsing an XML document. |
---|
402 | * |
---|
403 | * @return true, if the parser is currently configured to |
---|
404 | * use cached grammars, false otherwise. |
---|
405 | * |
---|
406 | * @see #useCachedGrammarInParse |
---|
407 | */ |
---|
408 | bool isUsingCachedGrammarInParse() const; |
---|
409 | |
---|
410 | /** |
---|
411 | * Get the 'calculate src offset flag' |
---|
412 | * |
---|
413 | * This method returns the state of the parser's src offset calculation |
---|
414 | * when parsing an XML document. |
---|
415 | * |
---|
416 | * @return true, if the parser is currently configured to |
---|
417 | * calculate src offsets, false otherwise. |
---|
418 | * |
---|
419 | * @see #setCalculateSrcOfs |
---|
420 | */ |
---|
421 | bool getCalculateSrcOfs() const; |
---|
422 | |
---|
423 | /** |
---|
424 | * Get the 'force standard uri flag' |
---|
425 | * |
---|
426 | * This method returns the state if the parser forces standard uri |
---|
427 | * |
---|
428 | * @return true, if the parser is currently configured to |
---|
429 | * force standard uri, i.e. malformed uri will be rejected. |
---|
430 | * |
---|
431 | * @see #setStandardUriConformant |
---|
432 | */ |
---|
433 | bool getStandardUriConformant() const; |
---|
434 | |
---|
435 | /** |
---|
436 | * Retrieve the grammar that is associated with the specified namespace key |
---|
437 | * |
---|
438 | * @param nameSpaceKey Namespace key |
---|
439 | * @return Grammar associated with the Namespace key. |
---|
440 | */ |
---|
441 | Grammar* getGrammar(const XMLCh* const nameSpaceKey); |
---|
442 | |
---|
443 | /** |
---|
444 | * Retrieve the grammar where the root element is declared. |
---|
445 | * |
---|
446 | * @return Grammar where root element declared |
---|
447 | */ |
---|
448 | Grammar* getRootGrammar(); |
---|
449 | |
---|
450 | /** |
---|
451 | * Returns the string corresponding to a URI id from the URI string pool. |
---|
452 | * |
---|
453 | * @param uriId id of the string in the URI string pool. |
---|
454 | * @return URI string corresponding to the URI id. |
---|
455 | */ |
---|
456 | const XMLCh* getURIText(unsigned int uriId) const; |
---|
457 | |
---|
458 | /** |
---|
459 | * Returns the current src offset within the input source. |
---|
460 | * |
---|
461 | * @return offset within the input source |
---|
462 | */ |
---|
463 | unsigned int getSrcOffset() const; |
---|
464 | |
---|
465 | //@} |
---|
466 | |
---|
467 | |
---|
468 | // ----------------------------------------------------------------------- |
---|
469 | // Setter methods |
---|
470 | // ----------------------------------------------------------------------- |
---|
471 | |
---|
472 | /** @name Setter methods */ |
---|
473 | //@{ |
---|
474 | |
---|
475 | /** Set the error handler |
---|
476 | * |
---|
477 | * This method allows applications to install their own error handler |
---|
478 | * to trap error and warning messages. |
---|
479 | * |
---|
480 | * <i>Any previously set handler is merely dropped, since the parser |
---|
481 | * does not own them.</i> |
---|
482 | * |
---|
483 | * @param handler A const pointer to the user supplied error |
---|
484 | * handler. |
---|
485 | * |
---|
486 | * @see #getErrorHandler |
---|
487 | */ |
---|
488 | void setErrorHandler(ErrorHandler* const handler); |
---|
489 | |
---|
490 | /** Set the PSVI handler |
---|
491 | * |
---|
492 | * This method allows applications to install their own PSVI handler. |
---|
493 | * |
---|
494 | * <i>Any previously set handler is merely dropped, since the parser |
---|
495 | * does not own them.</i> |
---|
496 | * |
---|
497 | * @param handler A const pointer to the user supplied PSVI |
---|
498 | * handler. |
---|
499 | * |
---|
500 | * @see #getPSVIHandler |
---|
501 | */ |
---|
502 | void setPSVIHandler(PSVIHandler* const handler); |
---|
503 | |
---|
504 | |
---|
505 | /** Set the entity resolver |
---|
506 | * |
---|
507 | * This method allows applications to install their own entity |
---|
508 | * resolver. By installing an entity resolver, the applications |
---|
509 | * can trap and potentially redirect references to external |
---|
510 | * entities. |
---|
511 | * |
---|
512 | * <i>Any previously set entity resolver is merely dropped, since the parser |
---|
513 | * does not own them. If both setEntityResolver and setXMLEntityResolver |
---|
514 | * are called, then the last one is used.</i> |
---|
515 | * |
---|
516 | * @param handler A const pointer to the user supplied entity |
---|
517 | * resolver. |
---|
518 | * |
---|
519 | * @see #getEntityResolver |
---|
520 | */ |
---|
521 | void setEntityResolver(EntityResolver* const handler); |
---|
522 | |
---|
523 | /** Set the entity resolver |
---|
524 | * |
---|
525 | * This method allows applications to install their own entity |
---|
526 | * resolver. By installing an entity resolver, the applications |
---|
527 | * can trap and potentially redirect references to external |
---|
528 | * entities. |
---|
529 | * |
---|
530 | * <i>Any previously set entity resolver is merely dropped, since the parser |
---|
531 | * does not own them. If both setEntityResolver and setXMLEntityResolver |
---|
532 | * are called, then the last one is used.</i> |
---|
533 | * |
---|
534 | * @param handler A const pointer to the user supplied entity |
---|
535 | * resolver. |
---|
536 | * |
---|
537 | * @see #getXMLEntityResolver |
---|
538 | */ |
---|
539 | void setXMLEntityResolver(XMLEntityResolver* const handler); |
---|
540 | |
---|
541 | /** Set the 'do namespaces' flag |
---|
542 | * |
---|
543 | * This method allows users to enable or disable the parser's |
---|
544 | * namespace processing. When set to true, parser starts enforcing |
---|
545 | * all the constraints and rules specified by the NameSpace |
---|
546 | * specification. |
---|
547 | * |
---|
548 | * The parser's default state is: false. |
---|
549 | * |
---|
550 | * @param newState The value specifying whether NameSpace rules should |
---|
551 | * be enforced or not. |
---|
552 | * |
---|
553 | * @see #getDoNamespaces |
---|
554 | */ |
---|
555 | void setDoNamespaces(const bool newState); |
---|
556 | |
---|
557 | /** Set the 'exit on first error' flag |
---|
558 | * |
---|
559 | * This method allows users to set the parser's behaviour when it |
---|
560 | * encounters the first fatal error. If set to true, the parser |
---|
561 | * will exit at the first fatal error. If false, then it will |
---|
562 | * report the error and continue processing. |
---|
563 | * |
---|
564 | * The default value is 'true' and the parser exits on the |
---|
565 | * first fatal error. |
---|
566 | * |
---|
567 | * @param newState The value specifying whether the parser should |
---|
568 | * continue or exit when it encounters the first |
---|
569 | * fatal error. |
---|
570 | * |
---|
571 | * @see #getExitOnFirstFatalError |
---|
572 | */ |
---|
573 | void setExitOnFirstFatalError(const bool newState); |
---|
574 | |
---|
575 | /** |
---|
576 | * This method allows users to set the parser's behaviour when it |
---|
577 | * encounters a validtion constraint error. If set to true, and the |
---|
578 | * the parser will treat validation error as fatal and will exit depends on the |
---|
579 | * state of "getExitOnFirstFatalError". If false, then it will |
---|
580 | * report the error and continue processing. |
---|
581 | * |
---|
582 | * Note: setting this true does not mean the validation error will be printed with |
---|
583 | * the word "Fatal Error". It is still printed as "Error", but the parser |
---|
584 | * will exit if "setExitOnFirstFatalError" is set to true. |
---|
585 | * |
---|
586 | * <p>The default value is 'false'.</p> |
---|
587 | * |
---|
588 | * @param newState If true, the parser will exit if "setExitOnFirstFatalError" |
---|
589 | * is set to true. |
---|
590 | * |
---|
591 | * @see #getValidationConstraintFatal |
---|
592 | * @see #setExitOnFirstFatalError |
---|
593 | */ |
---|
594 | void setValidationConstraintFatal(const bool newState); |
---|
595 | |
---|
596 | /** Set the 'include entity references' flag |
---|
597 | * |
---|
598 | * This method allows the user to specify whether the parser should |
---|
599 | * create entity reference nodes in the DOM tree being produced. |
---|
600 | * When the 'create' flag is |
---|
601 | * true, the parser will create EntityReference nodes in the DOM tree. |
---|
602 | * The EntityReference nodes and their child nodes will be read-only. |
---|
603 | * When the 'create' flag is false, no EntityReference nodes will be created. |
---|
604 | * <p>The replacement text |
---|
605 | * of the entity is included in either case, either as a |
---|
606 | * child of the Entity Reference node or in place at the location |
---|
607 | * of the reference. |
---|
608 | * <p>The default value is 'true'. |
---|
609 | * |
---|
610 | * @param create The new state of the create entity reference nodes |
---|
611 | * flag. |
---|
612 | * @see #getCreateEntityReferenceNodes |
---|
613 | */ |
---|
614 | void setCreateEntityReferenceNodes(const bool create); |
---|
615 | |
---|
616 | /** Set the 'include ignorable whitespace' flag |
---|
617 | * |
---|
618 | * This method allows the user to specify whether a validating parser |
---|
619 | * should include ignorable whitespaces as text nodes. It has no effect |
---|
620 | * on non-validating parsers which always include non-markup text. |
---|
621 | * <p>When set to true (also the default), ignorable whitespaces will be |
---|
622 | * added to the DOM tree as text nodes. The method |
---|
623 | * DOM_Text::isIgnorableWhitespace() will return true for those text |
---|
624 | * nodes only. |
---|
625 | * <p>When set to false, all ignorable whitespace will be discarded and |
---|
626 | * no text node is added to the DOM tree. Note: applications intended |
---|
627 | * to process the "xml:space" attribute should not set this flag to false. |
---|
628 | * And this flag also overrides any schema datateye whitespace facets, |
---|
629 | * that is, all ignorable whitespace will be discarded even though |
---|
630 | * 'preserve' is set in schema datatype whitespace facets. |
---|
631 | * |
---|
632 | * @param include The new state of the include ignorable whitespace |
---|
633 | * flag. |
---|
634 | * |
---|
635 | * @see #getIncludeIgnorableWhitespace |
---|
636 | */ |
---|
637 | void setIncludeIgnorableWhitespace(const bool include); |
---|
638 | |
---|
639 | /** |
---|
640 | * This method allows users to set the validation scheme to be used |
---|
641 | * by this parser. The value is one of the ValSchemes enumerated values |
---|
642 | * defined by this class: |
---|
643 | * |
---|
644 | * <br> Val_Never - turn off validation |
---|
645 | * <br> Val_Always - turn on validation |
---|
646 | * <br> Val_Auto - turn on validation if any internal/external |
---|
647 | * DTD subset have been seen |
---|
648 | * |
---|
649 | * <p>The parser's default state is: Val_Never.</p> |
---|
650 | * |
---|
651 | * @param newScheme The new validation scheme to use. |
---|
652 | * |
---|
653 | * @see #getValidationScheme |
---|
654 | */ |
---|
655 | void setValidationScheme(const ValSchemes newScheme); |
---|
656 | |
---|
657 | /** Set the 'do schema' flag |
---|
658 | * |
---|
659 | * This method allows users to enable or disable the parser's |
---|
660 | * schema processing. When set to false, parser will not process |
---|
661 | * any schema found. |
---|
662 | * |
---|
663 | * The parser's default state is: false. |
---|
664 | * |
---|
665 | * Note: If set to true, namespace processing must also be turned on. |
---|
666 | * |
---|
667 | * @param newState The value specifying whether schema support should |
---|
668 | * be enforced or not. |
---|
669 | * |
---|
670 | * @see #getDoSchema |
---|
671 | */ |
---|
672 | void setDoSchema(const bool newState); |
---|
673 | |
---|
674 | /** |
---|
675 | * This method allows the user to turn full Schema constraint checking on/off. |
---|
676 | * Only takes effect if Schema validation is enabled. |
---|
677 | * If turned off, partial constraint checking is done. |
---|
678 | * |
---|
679 | * Full schema constraint checking includes those checking that may |
---|
680 | * be time-consuming or memory intensive. Currently, particle unique |
---|
681 | * attribution constraint checking and particle derivation resriction checking |
---|
682 | * are controlled by this option. |
---|
683 | * |
---|
684 | * The parser's default state is: false. |
---|
685 | * |
---|
686 | * @param schemaFullChecking True to turn on full schema constraint checking. |
---|
687 | * |
---|
688 | * @see #getValidationSchemaFullChecking |
---|
689 | */ |
---|
690 | void setValidationSchemaFullChecking(const bool schemaFullChecking); |
---|
691 | |
---|
692 | void setIdentityConstraintChecking(const bool identityConstraintChecking); |
---|
693 | |
---|
694 | /** |
---|
695 | * This method allows users to set the toCreateXMLDeclTypeNode flag |
---|
696 | * by this parser. By setting it to 'true' user can have XMLDecl type |
---|
697 | * nodes attached to the DOM tree. |
---|
698 | * |
---|
699 | * <p>The parser's default state is: false </p> |
---|
700 | * |
---|
701 | * @param create The new to create XMLDecl type node flag |
---|
702 | * |
---|
703 | */ |
---|
704 | void setToCreateXMLDeclTypeNode(const bool create); |
---|
705 | |
---|
706 | /** |
---|
707 | * This method allows the user to specify a list of schemas to use. |
---|
708 | * If the targetNamespace of a schema specified using this method matches |
---|
709 | * the targetNamespace of a schema occuring in the instance document in |
---|
710 | * the schemaLocation attribute, or if the targetNamespace matches the |
---|
711 | * namespace attribute of the "import" element, the schema specified by the |
---|
712 | * user using this method will be used (i.e., the schemaLocation attribute |
---|
713 | * in the instance document or on the "import" element will be effectively ignored). |
---|
714 | * |
---|
715 | * If this method is called more than once, only the last one takes effect. |
---|
716 | * |
---|
717 | * The syntax is the same as for schemaLocation attributes in instance |
---|
718 | * documents: e.g, "http://www.example.com file_name.xsd". The user can |
---|
719 | * specify more than one XML Schema in the list. |
---|
720 | * |
---|
721 | * @param schemaLocation the list of schemas to use |
---|
722 | * |
---|
723 | * @see #getExternalSchemaLocation |
---|
724 | */ |
---|
725 | |
---|
726 | void setExternalSchemaLocation(const XMLCh* const schemaLocation); |
---|
727 | |
---|
728 | /** |
---|
729 | * This method is same as setExternalSchemaLocation(const XMLCh* const). |
---|
730 | * It takes native char string as parameter |
---|
731 | * |
---|
732 | * @param schemaLocation the list of schemas to use |
---|
733 | * |
---|
734 | * @see #setExternalSchemaLocation(const XMLCh* const) |
---|
735 | */ |
---|
736 | void setExternalSchemaLocation(const char* const schemaLocation); |
---|
737 | |
---|
738 | /** |
---|
739 | * This method allows the user to specify the no target namespace XML |
---|
740 | * Schema Location externally. If specified, the instance document's |
---|
741 | * noNamespaceSchemaLocation attribute will be effectively ignored. |
---|
742 | * |
---|
743 | * If this method is called more than once, only the last one takes effect. |
---|
744 | * |
---|
745 | * The syntax is the same as for the noNamespaceSchemaLocation attribute |
---|
746 | * that may occur in an instance document: e.g."file_name.xsd". |
---|
747 | * |
---|
748 | * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace |
---|
749 | * |
---|
750 | * @see #getExternalNoNamespaceSchemaLocation |
---|
751 | */ |
---|
752 | void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation); |
---|
753 | |
---|
754 | /** |
---|
755 | * This method is same as setExternalNoNamespaceSchemaLocation(const XMLCh* const). |
---|
756 | * It takes native char string as parameter |
---|
757 | * |
---|
758 | * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace |
---|
759 | * |
---|
760 | * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const) |
---|
761 | */ |
---|
762 | void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation); |
---|
763 | |
---|
764 | /** Set the 'Grammar caching' flag |
---|
765 | * |
---|
766 | * This method allows users to enable or disable caching of grammar when |
---|
767 | * parsing XML documents. When set to true, the parser will cache the |
---|
768 | * resulting grammar for use in subsequent parses. |
---|
769 | * |
---|
770 | * If the flag is set to true, the 'Use cached grammar' flag will also be |
---|
771 | * set to true. |
---|
772 | * |
---|
773 | * The parser's default state is: false. |
---|
774 | * |
---|
775 | * @param newState The value specifying whether we should cache grammars |
---|
776 | * or not. |
---|
777 | * |
---|
778 | * @see #isCachingGrammarFromParse |
---|
779 | * @see #useCachedGrammarInParse |
---|
780 | */ |
---|
781 | void cacheGrammarFromParse(const bool newState); |
---|
782 | |
---|
783 | /** Set the 'Use cached grammar' flag |
---|
784 | * |
---|
785 | * This method allows users to enable or disable the use of cached |
---|
786 | * grammars. When set to true, the parser will use the cached grammar, |
---|
787 | * instead of building the grammar from scratch, to validate XML |
---|
788 | * documents. |
---|
789 | * |
---|
790 | * If the 'Grammar caching' flag is set to true, this mehod ignore the |
---|
791 | * value passed in. |
---|
792 | * |
---|
793 | * The parser's default state is: false. |
---|
794 | * |
---|
795 | * @param newState The value specifying whether we should use the cached |
---|
796 | * grammar or not. |
---|
797 | * |
---|
798 | * @see #isUsingCachedGrammarInParse |
---|
799 | * @see #cacheGrammarFromParse |
---|
800 | */ |
---|
801 | void useCachedGrammarInParse(const bool newState); |
---|
802 | |
---|
803 | /** Enable/disable src offset calculation |
---|
804 | * |
---|
805 | * This method allows users to enable/disable src offset calculation. |
---|
806 | * Disabling the calculation will improve performance. |
---|
807 | * |
---|
808 | * The parser's default state is: false. |
---|
809 | * |
---|
810 | * @param newState The value specifying whether we should enable or |
---|
811 | * disable src offset calculation |
---|
812 | * |
---|
813 | * @see #getCalculateSrcOfs |
---|
814 | */ |
---|
815 | void setCalculateSrcOfs(const bool newState); |
---|
816 | |
---|
817 | /** Force standard uri |
---|
818 | * |
---|
819 | * This method allows users to tell the parser to force standard uri conformance. |
---|
820 | * |
---|
821 | * The parser's default state is: false. |
---|
822 | * |
---|
823 | * @param newState The value specifying whether the parser should reject malformed URI. |
---|
824 | * |
---|
825 | * @see #getStandardUriConformant |
---|
826 | */ |
---|
827 | void setStandardUriConformant(const bool newState); |
---|
828 | |
---|
829 | /** Set the scanner to use when scanning the XML document |
---|
830 | * |
---|
831 | * This method allows users to set the scanner to use |
---|
832 | * when scanning a given XML document. |
---|
833 | * |
---|
834 | * @param scannerName The name of the desired scanner |
---|
835 | */ |
---|
836 | void useScanner(const XMLCh* const scannerName); |
---|
837 | |
---|
838 | //@} |
---|
839 | |
---|
840 | |
---|
841 | // ----------------------------------------------------------------------- |
---|
842 | // Parsing methods |
---|
843 | // ----------------------------------------------------------------------- |
---|
844 | |
---|
845 | /** @name Parsing methods */ |
---|
846 | //@{ |
---|
847 | |
---|
848 | /** Parse via an input source object |
---|
849 | * |
---|
850 | * This method invokes the parsing process on the XML file specified |
---|
851 | * by the InputSource parameter. This API is borrowed from the |
---|
852 | * SAX Parser interface. |
---|
853 | * |
---|
854 | * @param source A const reference to the InputSource object which |
---|
855 | * points to the XML file to be parsed. |
---|
856 | * @exception SAXException Any SAX exception, possibly |
---|
857 | * wrapping another exception. |
---|
858 | * @exception XMLException An exception from the parser or client |
---|
859 | * handler code. |
---|
860 | * @exception DOM_DOMException A DOM exception as per DOM spec. |
---|
861 | * @see InputSource#InputSource |
---|
862 | * @see #setEntityResolver |
---|
863 | * @see #setErrorHandler |
---|
864 | */ |
---|
865 | void parse(const InputSource& source); |
---|
866 | |
---|
867 | /** Parse via a file path or URL |
---|
868 | * |
---|
869 | * This method invokes the parsing process on the XML file specified by |
---|
870 | * the Unicode string parameter 'systemId'. This method is borrowed |
---|
871 | * from the SAX Parser interface. |
---|
872 | * |
---|
873 | * @param systemId A const XMLCh pointer to the Unicode string which |
---|
874 | * contains the path to the XML file to be parsed. |
---|
875 | * |
---|
876 | * @exception SAXException Any SAX exception, possibly |
---|
877 | * wrapping another exception. |
---|
878 | * @exception XMLException An exception from the parser or client |
---|
879 | * handler code. |
---|
880 | * @exception DOM_DOMException A DOM exception as per DOM spec. |
---|
881 | * @see #parse(InputSource,...) |
---|
882 | */ |
---|
883 | void parse(const XMLCh* const systemId); |
---|
884 | |
---|
885 | /** Parse via a file path or URL (in the local code page) |
---|
886 | * |
---|
887 | * This method invokes the parsing process on the XML file specified by |
---|
888 | * the native char* string parameter 'systemId'. |
---|
889 | * |
---|
890 | * @param systemId A const char pointer to a native string which |
---|
891 | * contains the path to the XML file to be parsed. |
---|
892 | * @exception SAXException Any SAX exception, possibly |
---|
893 | * wrapping another exception. |
---|
894 | * @exception XMLException An exception from the parser or client |
---|
895 | * handler code. |
---|
896 | * @exception DOM_DOMException A DOM exception as per DOM spec. |
---|
897 | * @see #parse(InputSource,...) |
---|
898 | */ |
---|
899 | void parse(const char* const systemId); |
---|
900 | |
---|
901 | /** Begin a progressive parse operation |
---|
902 | * |
---|
903 | * This method is used to start a progressive parse on a XML file. |
---|
904 | * To continue parsing, subsequent calls must be to the parseNext |
---|
905 | * method. |
---|
906 | * |
---|
907 | * It scans through the prolog and returns a token to be used on |
---|
908 | * subsequent scanNext() calls. If the return value is true, then the |
---|
909 | * token is legal and ready for further use. If it returns false, then |
---|
910 | * the scan of the prolog failed and the token is not going to work on |
---|
911 | * subsequent scanNext() calls. |
---|
912 | * |
---|
913 | * @param systemId A pointer to a Unicode string represting the path |
---|
914 | * to the XML file to be parsed. |
---|
915 | * @param toFill A token maintaing state information to maintain |
---|
916 | * internal consistency between invocation of 'parseNext' |
---|
917 | * calls. |
---|
918 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
919 | * user can go ahead with parsing the rest of the file. It |
---|
920 | * returns 'false' to indicate that the parser could not parse |
---|
921 | * the prolog. |
---|
922 | * |
---|
923 | * @see #parseNext |
---|
924 | * @see #parseFirst(char*,...) |
---|
925 | * @see #parseFirst(InputSource&,...) |
---|
926 | */ |
---|
927 | bool parseFirst |
---|
928 | ( |
---|
929 | const XMLCh* const systemId |
---|
930 | , XMLPScanToken& toFill |
---|
931 | ); |
---|
932 | |
---|
933 | /** Begin a progressive parse operation |
---|
934 | * |
---|
935 | * This method is used to start a progressive parse on a XML file. |
---|
936 | * To continue parsing, subsequent calls must be to the parseNext |
---|
937 | * method. |
---|
938 | * |
---|
939 | * It scans through the prolog and returns a token to be used on |
---|
940 | * subsequent scanNext() calls. If the return value is true, then the |
---|
941 | * token is legal and ready for further use. If it returns false, then |
---|
942 | * the scan of the prolog failed and the token is not going to work on |
---|
943 | * subsequent scanNext() calls. |
---|
944 | * |
---|
945 | * @param systemId A pointer to a regular native string represting |
---|
946 | * the path to the XML file to be parsed. |
---|
947 | * @param toFill A token maintaing state information to maintain |
---|
948 | * internal consistency between invocation of 'parseNext' |
---|
949 | * calls. |
---|
950 | * |
---|
951 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
952 | * user can go ahead with parsing the rest of the file. It |
---|
953 | * returns 'false' to indicate that the parser could not parse |
---|
954 | * the prolog. |
---|
955 | * |
---|
956 | * @see #parseNext |
---|
957 | * @see #parseFirst(XMLCh*,...) |
---|
958 | * @see #parseFirst(InputSource&,...) |
---|
959 | */ |
---|
960 | bool parseFirst |
---|
961 | ( |
---|
962 | const char* const systemId |
---|
963 | , XMLPScanToken& toFill |
---|
964 | ); |
---|
965 | |
---|
966 | /** Begin a progressive parse operation |
---|
967 | * |
---|
968 | * This method is used to start a progressive parse on a XML file. |
---|
969 | * To continue parsing, subsequent calls must be to the parseNext |
---|
970 | * method. |
---|
971 | * |
---|
972 | * It scans through the prolog and returns a token to be used on |
---|
973 | * subsequent scanNext() calls. If the return value is true, then the |
---|
974 | * token is legal and ready for further use. If it returns false, then |
---|
975 | * the scan of the prolog failed and the token is not going to work on |
---|
976 | * subsequent scanNext() calls. |
---|
977 | * |
---|
978 | * @param source A const reference to the InputSource object which |
---|
979 | * points to the XML file to be parsed. |
---|
980 | * @param toFill A token maintaing state information to maintain |
---|
981 | * internal consistency between invocation of 'parseNext' |
---|
982 | * calls. |
---|
983 | * |
---|
984 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
985 | * user can go ahead with parsing the rest of the file. It |
---|
986 | * returns 'false' to indicate that the parser could not parse |
---|
987 | * the prolog. |
---|
988 | * |
---|
989 | * @see #parseNext |
---|
990 | * @see #parseFirst(XMLCh*,...) |
---|
991 | * @see #parseFirst(char*,...) |
---|
992 | */ |
---|
993 | bool parseFirst |
---|
994 | ( |
---|
995 | const InputSource& source |
---|
996 | , XMLPScanToken& toFill |
---|
997 | ); |
---|
998 | |
---|
999 | /** Continue a progressive parse operation |
---|
1000 | * |
---|
1001 | * This method is used to continue with progressive parsing of |
---|
1002 | * XML files started by a call to 'parseFirst' method. |
---|
1003 | * |
---|
1004 | * It parses the XML file and stops as soon as it comes across |
---|
1005 | * a XML token (as defined in the XML specification). |
---|
1006 | * |
---|
1007 | * @param token A token maintaing state information to maintain |
---|
1008 | * internal consistency between invocation of 'parseNext' |
---|
1009 | * calls. |
---|
1010 | * |
---|
1011 | * @return 'true', if successful in parsing the next XML token. |
---|
1012 | * It indicates the user can go ahead with parsing the rest |
---|
1013 | * of the file. It returns 'false' to indicate that the parser |
---|
1014 | * could not find next token as per the XML specification |
---|
1015 | * production rule. |
---|
1016 | * |
---|
1017 | * @see #parseFirst(XMLCh*,...) |
---|
1018 | * @see #parseFirst(char*,...) |
---|
1019 | * @see #parseFirst(InputSource&,...) |
---|
1020 | */ |
---|
1021 | bool parseNext(XMLPScanToken& token); |
---|
1022 | |
---|
1023 | /** Reset the parser after a progressive parse |
---|
1024 | * |
---|
1025 | * If a progressive parse loop exits before the end of the document |
---|
1026 | * is reached, the parser has no way of knowing this. So it will leave |
---|
1027 | * open any files or sockets or memory buffers that were in use at |
---|
1028 | * the time that the parse loop exited. |
---|
1029 | * |
---|
1030 | * The next parse operation will cause these open files and such to |
---|
1031 | * be closed, but the next parse operation might occur at some unknown |
---|
1032 | * future point. To avoid this problem, you should reset the parser if |
---|
1033 | * you exit the loop early. |
---|
1034 | * |
---|
1035 | * If you exited because of an error, then this cleanup will be done |
---|
1036 | * for you. Its only when you exit the file prematurely of your own |
---|
1037 | * accord, because you've found what you wanted in the file most |
---|
1038 | * likely. |
---|
1039 | * |
---|
1040 | * @param token A token maintaing state information to maintain |
---|
1041 | * internal consistency between invocation of 'parseNext' |
---|
1042 | * calls. |
---|
1043 | * |
---|
1044 | * @see #parseFirst(XMLCh*,...) |
---|
1045 | * @see #parseFirst(char*,...) |
---|
1046 | * @see #parseFirst(InputSource&,...) |
---|
1047 | */ |
---|
1048 | void parseReset(XMLPScanToken& token); |
---|
1049 | |
---|
1050 | //@} |
---|
1051 | |
---|
1052 | // ----------------------------------------------------------------------- |
---|
1053 | // Grammar preparsing interface |
---|
1054 | // ----------------------------------------------------------------------- |
---|
1055 | |
---|
1056 | /** @name Implementation of Grammar preparsing interface's. */ |
---|
1057 | //@{ |
---|
1058 | /** |
---|
1059 | * Preparse schema grammar (XML Schema, DTD, etc.) via an input source |
---|
1060 | * object. |
---|
1061 | * |
---|
1062 | * This method invokes the preparsing process on a schema grammar XML |
---|
1063 | * file specified by the SAX InputSource parameter. If the 'toCache' flag |
---|
1064 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
1065 | * key is found in the pool, no caching of any grammar will take place. |
---|
1066 | * |
---|
1067 | * <p><b>"Experimental - subject to change"</b></p> |
---|
1068 | * |
---|
1069 | * @param source A const reference to the SAX InputSource object which |
---|
1070 | * points to the schema grammar file to be preparsed. |
---|
1071 | * @param grammarType The grammar type (Schema or DTD). |
---|
1072 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
1073 | * otherwise, no chaching. Default is <code>false</code>. |
---|
1074 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
1075 | * DTDGrammar). That grammar object is owned by the parser. |
---|
1076 | * |
---|
1077 | * @exception SAXException Any SAX exception, possibly |
---|
1078 | * wrapping another exception. |
---|
1079 | * @exception XMLException An exception from the parser or client |
---|
1080 | * handler code. |
---|
1081 | * @exception DOMException A DOM exception as per DOM spec. |
---|
1082 | * |
---|
1083 | * @see InputSource#InputSource |
---|
1084 | */ |
---|
1085 | Grammar* loadGrammar(const InputSource& source, |
---|
1086 | const short grammarType, |
---|
1087 | const bool toCache = false); |
---|
1088 | |
---|
1089 | /** |
---|
1090 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
---|
1091 | * |
---|
1092 | * This method invokes the preparsing process on a schema grammar XML |
---|
1093 | * file specified by the file path parameter. If the 'toCache' flag |
---|
1094 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
1095 | * key is found in the pool, no caching of any grammar will take place. |
---|
1096 | * |
---|
1097 | * <p><b>"Experimental - subject to change"</b></p> |
---|
1098 | * |
---|
1099 | * @param systemId A const XMLCh pointer to the Unicode string which |
---|
1100 | * contains the path to the XML grammar file to be |
---|
1101 | * preparsed. |
---|
1102 | * @param grammarType The grammar type (Schema or DTD). |
---|
1103 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
1104 | * otherwise, no chaching. Default is <code>false</code>. |
---|
1105 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
1106 | * DTDGrammar). That grammar object is owned by the parser. |
---|
1107 | * |
---|
1108 | * @exception SAXException Any SAX exception, possibly |
---|
1109 | * wrapping another exception. |
---|
1110 | * @exception XMLException An exception from the parser or client |
---|
1111 | * handler code. |
---|
1112 | * @exception DOMException A DOM exception as per DOM spec. |
---|
1113 | */ |
---|
1114 | Grammar* loadGrammar(const XMLCh* const systemId, |
---|
1115 | const short grammarType, |
---|
1116 | const bool toCache = false); |
---|
1117 | |
---|
1118 | /** |
---|
1119 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
---|
1120 | * |
---|
1121 | * This method invokes the preparsing process on a schema grammar XML |
---|
1122 | * file specified by the file path parameter. If the 'toCache' flag |
---|
1123 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
1124 | * key is found in the pool, no caching of any grammar will take place. |
---|
1125 | * |
---|
1126 | * <p><b>"Experimental - subject to change"</b></p> |
---|
1127 | * |
---|
1128 | * @param systemId A const char pointer to a native string which contains |
---|
1129 | * the path to the XML grammar file to be preparsed. |
---|
1130 | * @param grammarType The grammar type (Schema or DTD). |
---|
1131 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
1132 | * otherwise, no chaching. Default is <code>false</code>. |
---|
1133 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
1134 | * DTDGrammar). That grammar object is owned by the parser. |
---|
1135 | * |
---|
1136 | * @exception SAXException Any SAX exception, possibly |
---|
1137 | * wrapping another exception. |
---|
1138 | * @exception XMLException An exception from the parser or client |
---|
1139 | * handler code. |
---|
1140 | * @exception DOMException A DOM exception as per DOM spec. |
---|
1141 | */ |
---|
1142 | Grammar* loadGrammar(const char* const systemId, |
---|
1143 | const short grammarType, |
---|
1144 | const bool toCache = false); |
---|
1145 | |
---|
1146 | /** |
---|
1147 | * This method allows the user to reset the pool of cached grammars. |
---|
1148 | */ |
---|
1149 | void resetCachedGrammarPool(); |
---|
1150 | |
---|
1151 | //@} |
---|
1152 | |
---|
1153 | |
---|
1154 | |
---|
1155 | // ----------------------------------------------------------------------- |
---|
1156 | // Implementation of the XMLErrorReporter interface. |
---|
1157 | // ----------------------------------------------------------------------- |
---|
1158 | |
---|
1159 | /** @name Implementation of the XMLErrorReporter interface. */ |
---|
1160 | //@{ |
---|
1161 | |
---|
1162 | /** Handle errors reported from the parser |
---|
1163 | * |
---|
1164 | * This method is used to report back errors found while parsing the |
---|
1165 | * XML file. This method is also borrowed from the SAX specification. |
---|
1166 | * It calls the corresponding user installed Error Handler method: |
---|
1167 | * 'fatal', 'error', 'warning' depending on the severity of the error. |
---|
1168 | * This classification is defined by the XML specification. |
---|
1169 | * |
---|
1170 | * @param errCode An integer code for the error. |
---|
1171 | * @param msgDomain A const pointer to an Unicode string representing |
---|
1172 | * the message domain to use. |
---|
1173 | * @param errType An enumeration classifying the severity of the error. |
---|
1174 | * @param errorText A const pointer to an Unicode string representing |
---|
1175 | * the text of the error message. |
---|
1176 | * @param systemId A const pointer to an Unicode string representing |
---|
1177 | * the system id of the XML file where this error |
---|
1178 | * was discovered. |
---|
1179 | * @param publicId A const pointer to an Unicode string representing |
---|
1180 | * the public id of the XML file where this error |
---|
1181 | * was discovered. |
---|
1182 | * @param lineNum The line number where the error occurred. |
---|
1183 | * @param colNum The column number where the error occurred. |
---|
1184 | * @see ErrorHandler |
---|
1185 | */ |
---|
1186 | virtual void error |
---|
1187 | ( |
---|
1188 | const unsigned int errCode |
---|
1189 | , const XMLCh* const msgDomain |
---|
1190 | , const XMLErrorReporter::ErrTypes errType |
---|
1191 | , const XMLCh* const errorText |
---|
1192 | , const XMLCh* const systemId |
---|
1193 | , const XMLCh* const publicId |
---|
1194 | , const XMLSSize_t lineNum |
---|
1195 | , const XMLSSize_t colNum |
---|
1196 | ); |
---|
1197 | |
---|
1198 | /** Reset any error data before a new parse |
---|
1199 | * |
---|
1200 | * This method allows the user installed Error Handler callback to |
---|
1201 | * 'reset' itself. |
---|
1202 | * |
---|
1203 | * <b><font color="#FF0000">This method is a no-op for this DOM |
---|
1204 | * implementation.</font></b> |
---|
1205 | */ |
---|
1206 | virtual void resetErrors(); |
---|
1207 | //@} |
---|
1208 | |
---|
1209 | |
---|
1210 | // ----------------------------------------------------------------------- |
---|
1211 | // Implementation of the XMLEntityHandler interface. |
---|
1212 | // ----------------------------------------------------------------------- |
---|
1213 | |
---|
1214 | /** @name Implementation of the XMLEntityHandler interface. */ |
---|
1215 | //@{ |
---|
1216 | |
---|
1217 | /** Handle an end of input source event |
---|
1218 | * |
---|
1219 | * This method is used to indicate the end of parsing of an external |
---|
1220 | * entity file. |
---|
1221 | * |
---|
1222 | * <b><font color="#FF0000">This method is a no-op for this DOM |
---|
1223 | * implementation.</font></b> |
---|
1224 | * |
---|
1225 | * @param inputSource A const reference to the InputSource object |
---|
1226 | * which points to the XML file being parsed. |
---|
1227 | * @see InputSource |
---|
1228 | */ |
---|
1229 | virtual void endInputSource(const InputSource& inputSource); |
---|
1230 | |
---|
1231 | /** Expand a system id |
---|
1232 | * |
---|
1233 | * This method allows an installed XMLEntityHandler to further |
---|
1234 | * process any system id's of enternal entities encountered in |
---|
1235 | * the XML file being parsed, such as redirection etc. |
---|
1236 | * |
---|
1237 | * <b><font color="#FF0000">This method always returns 'false' |
---|
1238 | * for this DOM implementation.</font></b> |
---|
1239 | * |
---|
1240 | * @param systemId A const pointer to an Unicode string representing |
---|
1241 | * the system id scanned by the parser. |
---|
1242 | * @param toFill A pointer to a buffer in which the application |
---|
1243 | * processed system id is stored. |
---|
1244 | * @return 'true', if any processing is done, 'false' otherwise. |
---|
1245 | */ |
---|
1246 | virtual bool expandSystemId |
---|
1247 | ( |
---|
1248 | const XMLCh* const systemId |
---|
1249 | , XMLBuffer& toFill |
---|
1250 | ); |
---|
1251 | |
---|
1252 | /** Reset any entity handler information |
---|
1253 | * |
---|
1254 | * This method allows the installed XMLEntityHandler to reset |
---|
1255 | * itself. |
---|
1256 | * |
---|
1257 | * <b><font color="#FF0000">This method is a no-op for this DOM |
---|
1258 | * implementation.</font></b> |
---|
1259 | */ |
---|
1260 | virtual void resetEntities(); |
---|
1261 | |
---|
1262 | /** Resolve a public/system id |
---|
1263 | * |
---|
1264 | * This method allows a user installed entity handler to further |
---|
1265 | * process any pointers to external entities. The applications can |
---|
1266 | * implement 'redirection' via this callback. This method is also |
---|
1267 | * borrowed from the SAX specification. |
---|
1268 | * |
---|
1269 | * @deprecated This method is no longer called (the other resolveEntity one is). |
---|
1270 | * |
---|
1271 | * @param publicId A const pointer to a Unicode string representing the |
---|
1272 | * public id of the entity just parsed. |
---|
1273 | * @param systemId A const pointer to a Unicode string representing the |
---|
1274 | * system id of the entity just parsed. |
---|
1275 | * @param baseURI A const pointer to a Unicode string representing the |
---|
1276 | * base URI of the entity just parsed, |
---|
1277 | * or <code>null</code> if there is no base URI. |
---|
1278 | * @return The value returned by the user installed resolveEntity |
---|
1279 | * method or NULL otherwise to indicate no processing was done. |
---|
1280 | * The returned InputSource is owned by the parser which is |
---|
1281 | * responsible to clean up the memory. |
---|
1282 | * @see EntityResolver |
---|
1283 | * @see XMLEntityHandler |
---|
1284 | */ |
---|
1285 | virtual InputSource* resolveEntity |
---|
1286 | ( |
---|
1287 | const XMLCh* const publicId |
---|
1288 | , const XMLCh* const systemId |
---|
1289 | , const XMLCh* const baseURI = 0 |
---|
1290 | ); |
---|
1291 | |
---|
1292 | /** Resolve a public/system id |
---|
1293 | * |
---|
1294 | * This method allows a user installed entity handler to further |
---|
1295 | * process any pointers to external entities. The applications can |
---|
1296 | * implement 'redirection' via this callback. |
---|
1297 | * |
---|
1298 | * @param resourceIdentifier An object containing the type of |
---|
1299 | * resource to be resolved and the associated data members |
---|
1300 | * corresponding to this type. |
---|
1301 | * @return The value returned by the user installed resolveEntity |
---|
1302 | * method or NULL otherwise to indicate no processing was done. |
---|
1303 | * The returned InputSource is owned by the parser which is |
---|
1304 | * responsible to clean up the memory. |
---|
1305 | * @see XMLEntityHandler |
---|
1306 | * @see XMLEntityResolver |
---|
1307 | */ |
---|
1308 | virtual InputSource* resolveEntity |
---|
1309 | ( |
---|
1310 | XMLResourceIdentifier* resourceIdentifier |
---|
1311 | ); |
---|
1312 | |
---|
1313 | /** Handle a 'start input source' event |
---|
1314 | * |
---|
1315 | * This method is used to indicate the start of parsing an external |
---|
1316 | * entity file. |
---|
1317 | * |
---|
1318 | * <b><font color="#FF0000">This method is a no-op for this DOM parse |
---|
1319 | * implementation.</font></b> |
---|
1320 | * |
---|
1321 | * @param inputSource A const reference to the InputSource object |
---|
1322 | * which points to the external entity |
---|
1323 | * being parsed. |
---|
1324 | */ |
---|
1325 | virtual void startInputSource(const InputSource& inputSource); |
---|
1326 | |
---|
1327 | //@} |
---|
1328 | |
---|
1329 | |
---|
1330 | |
---|
1331 | // ----------------------------------------------------------------------- |
---|
1332 | // Implementation of the XMLDocumentHandler interface. |
---|
1333 | // ----------------------------------------------------------------------- |
---|
1334 | |
---|
1335 | /** @name Implementation of the XMLDocumentHandler interface. */ |
---|
1336 | //@{ |
---|
1337 | |
---|
1338 | /** Handle document character events |
---|
1339 | * |
---|
1340 | * This method is used to report all the characters scanned by the |
---|
1341 | * parser. This DOM implementation stores this data in the appropriate |
---|
1342 | * DOM node, creating one if necessary. |
---|
1343 | * |
---|
1344 | * @param chars A const pointer to a Unicode string representing the |
---|
1345 | * character data. |
---|
1346 | * @param length The length of the Unicode string returned in 'chars'. |
---|
1347 | * @param cdataSection A flag indicating if the characters represent |
---|
1348 | * content from the CDATA section. |
---|
1349 | */ |
---|
1350 | virtual void docCharacters |
---|
1351 | ( |
---|
1352 | const XMLCh* const chars |
---|
1353 | , const unsigned int length |
---|
1354 | , const bool cdataSection |
---|
1355 | ); |
---|
1356 | |
---|
1357 | /** Handle a document comment event |
---|
1358 | * |
---|
1359 | * This method is used to report any comments scanned by the parser. |
---|
1360 | * A new comment node is created which stores this data. |
---|
1361 | * |
---|
1362 | * @param comment A const pointer to a null terminated Unicode |
---|
1363 | * string representing the comment text. |
---|
1364 | */ |
---|
1365 | virtual void docComment |
---|
1366 | ( |
---|
1367 | const XMLCh* const comment |
---|
1368 | ); |
---|
1369 | |
---|
1370 | /** Handle a document PI event |
---|
1371 | * |
---|
1372 | * This method is used to report any PI scanned by the parser. A new |
---|
1373 | * PI node is created and appended as a child of the current node in |
---|
1374 | * the tree. |
---|
1375 | * |
---|
1376 | * @param target A const pointer to a Unicode string representing the |
---|
1377 | * target of the PI declaration. |
---|
1378 | * @param data A const pointer to a Unicode string representing the |
---|
1379 | * data of the PI declaration. See the PI production rule |
---|
1380 | * in the XML specification for details. |
---|
1381 | */ |
---|
1382 | virtual void docPI |
---|
1383 | ( |
---|
1384 | const XMLCh* const target |
---|
1385 | , const XMLCh* const data |
---|
1386 | ); |
---|
1387 | |
---|
1388 | /** Handle the end of document event |
---|
1389 | * |
---|
1390 | * This method is used to indicate the end of the current document. |
---|
1391 | */ |
---|
1392 | virtual void endDocument(); |
---|
1393 | |
---|
1394 | /** Handle and end of element event |
---|
1395 | * |
---|
1396 | * This method is used to indicate the end tag of an element. The |
---|
1397 | * DOMParse pops the current element off the top of the element |
---|
1398 | * stack, and make it the new current element. |
---|
1399 | * |
---|
1400 | * @param elemDecl A const reference to the object containing element |
---|
1401 | * declaration information. |
---|
1402 | * @param urlId An id referring to the namespace prefix, if |
---|
1403 | * namespaces setting is switched on. |
---|
1404 | * @param isRoot A flag indicating whether this element was the |
---|
1405 | * root element. |
---|
1406 | * @param elemPrefix A const pointer to a Unicode string containing |
---|
1407 | * the namespace prefix for this element. Applicable |
---|
1408 | * only when namespace processing is enabled. |
---|
1409 | */ |
---|
1410 | virtual void endElement |
---|
1411 | ( |
---|
1412 | const XMLElementDecl& elemDecl |
---|
1413 | , const unsigned int urlId |
---|
1414 | , const bool isRoot |
---|
1415 | , const XMLCh* const elemPrefix=0 |
---|
1416 | ); |
---|
1417 | |
---|
1418 | /** Handle and end of entity reference event |
---|
1419 | * |
---|
1420 | * This method is used to indicate that an end of an entity reference |
---|
1421 | * was just scanned. |
---|
1422 | * |
---|
1423 | * @param entDecl A const reference to the object containing the |
---|
1424 | * entity declaration information. |
---|
1425 | */ |
---|
1426 | virtual void endEntityReference |
---|
1427 | ( |
---|
1428 | const XMLEntityDecl& entDecl |
---|
1429 | ); |
---|
1430 | |
---|
1431 | /** Handle an ignorable whitespace vent |
---|
1432 | * |
---|
1433 | * This method is used to report all the whitespace characters, which |
---|
1434 | * are determined to be 'ignorable'. This distinction between characters |
---|
1435 | * is only made, if validation is enabled. |
---|
1436 | * |
---|
1437 | * Any whitespace before content is ignored. If the current node is |
---|
1438 | * already of type DOM_Node::TEXT_NODE, then these whitespaces are |
---|
1439 | * appended, otherwise a new Text node is created which stores this |
---|
1440 | * data. Essentially all contiguous ignorable characters are collected |
---|
1441 | * in one node. |
---|
1442 | * |
---|
1443 | * @param chars A const pointer to a Unicode string representing the |
---|
1444 | * ignorable whitespace character data. |
---|
1445 | * @param length The length of the Unicode string 'chars'. |
---|
1446 | * @param cdataSection A flag indicating if the characters represent |
---|
1447 | * content from the CDATA section. |
---|
1448 | */ |
---|
1449 | virtual void ignorableWhitespace |
---|
1450 | ( |
---|
1451 | const XMLCh* const chars |
---|
1452 | , const unsigned int length |
---|
1453 | , const bool cdataSection |
---|
1454 | ); |
---|
1455 | |
---|
1456 | /** Handle a document reset event |
---|
1457 | * |
---|
1458 | * This method allows the user installed Document Handler to 'reset' |
---|
1459 | * itself, freeing all the memory resources. The scanner calls this |
---|
1460 | * method before starting a new parse event. |
---|
1461 | */ |
---|
1462 | virtual void resetDocument(); |
---|
1463 | |
---|
1464 | /** Handle a start document event |
---|
1465 | * |
---|
1466 | * This method is used to report the start of the parsing process. |
---|
1467 | */ |
---|
1468 | virtual void startDocument(); |
---|
1469 | |
---|
1470 | /** Handle a start element event |
---|
1471 | * |
---|
1472 | * This method is used to report the start of an element. It is |
---|
1473 | * called at the end of the element, by which time all attributes |
---|
1474 | * specified are also parsed. A new DOM Element node is created |
---|
1475 | * along with as many attribute nodes as required. This new element |
---|
1476 | * is added appended as a child of the current node in the tree, and |
---|
1477 | * then replaces it as the current node (if the isEmpty flag is false.) |
---|
1478 | * |
---|
1479 | * @param elemDecl A const reference to the object containing element |
---|
1480 | * declaration information. |
---|
1481 | * @param urlId An id referring to the namespace prefix, if |
---|
1482 | * namespaces setting is switched on. |
---|
1483 | * @param elemPrefix A const pointer to a Unicode string containing |
---|
1484 | * the namespace prefix for this element. Applicable |
---|
1485 | * only when namespace processing is enabled. |
---|
1486 | * @param attrList A const reference to the object containing the |
---|
1487 | * list of attributes just scanned for this element. |
---|
1488 | * @param attrCount A count of number of attributes in the list |
---|
1489 | * specified by the parameter 'attrList'. |
---|
1490 | * @param isEmpty A flag indicating whether this is an empty element |
---|
1491 | * or not. If empty, then no endElement() call will |
---|
1492 | * be made. |
---|
1493 | * @param isRoot A flag indicating whether this element was the |
---|
1494 | * root element. |
---|
1495 | * @see DocumentHandler#startElement |
---|
1496 | */ |
---|
1497 | virtual void startElement |
---|
1498 | ( |
---|
1499 | const XMLElementDecl& elemDecl |
---|
1500 | , const unsigned int urlId |
---|
1501 | , const XMLCh* const elemPrefix |
---|
1502 | , const RefVectorOf<XMLAttr>& attrList |
---|
1503 | , const unsigned int attrCount |
---|
1504 | , const bool isEmpty |
---|
1505 | , const bool isRoot |
---|
1506 | ); |
---|
1507 | |
---|
1508 | /** Handle a start entity reference event |
---|
1509 | * |
---|
1510 | * This method is used to indicate the start of an entity reference. |
---|
1511 | * If the expand entity reference flag is true, then a new |
---|
1512 | * DOM Entity reference node is created. |
---|
1513 | * |
---|
1514 | * @param entDecl A const reference to the object containing the |
---|
1515 | * entity declaration information. |
---|
1516 | */ |
---|
1517 | virtual void startEntityReference |
---|
1518 | ( |
---|
1519 | const XMLEntityDecl& entDecl |
---|
1520 | ); |
---|
1521 | |
---|
1522 | /** Handle an XMLDecl event |
---|
1523 | * |
---|
1524 | * This method is used to report the XML decl scanned by the parser. |
---|
1525 | * Refer to the XML specification to see the meaning of parameters. |
---|
1526 | * |
---|
1527 | * <b><font color="#FF0000">This method is a no-op for this DOM |
---|
1528 | * implementation.</font></b> |
---|
1529 | * |
---|
1530 | * @param versionStr A const pointer to a Unicode string representing |
---|
1531 | * version string value. |
---|
1532 | * @param encodingStr A const pointer to a Unicode string representing |
---|
1533 | * the encoding string value. |
---|
1534 | * @param standaloneStr A const pointer to a Unicode string |
---|
1535 | * representing the standalone string value. |
---|
1536 | * @param actualEncStr A const pointer to a Unicode string |
---|
1537 | * representing the actual encoding string |
---|
1538 | * value. |
---|
1539 | */ |
---|
1540 | virtual void XMLDecl |
---|
1541 | ( |
---|
1542 | const XMLCh* const versionStr |
---|
1543 | , const XMLCh* const encodingStr |
---|
1544 | , const XMLCh* const standaloneStr |
---|
1545 | , const XMLCh* const actualEncStr |
---|
1546 | ); |
---|
1547 | //@} |
---|
1548 | |
---|
1549 | |
---|
1550 | /** @name Deprecated Methods */ |
---|
1551 | //@{ |
---|
1552 | /** Set the 'expand entity references' flag |
---|
1553 | * |
---|
1554 | * DEPRECATED. USE setCreateEntityReferenceNodes instead. |
---|
1555 | * This method allows the user to specify whether the parser should |
---|
1556 | * expand all entity reference nodes. When the 'do expansion' flag is |
---|
1557 | * true, the DOM tree does not have any entity reference nodes. It is |
---|
1558 | * replaced by the sub-tree representing the replacement text of the |
---|
1559 | * entity. When the 'do expansion' flag is false, the DOM tree |
---|
1560 | * contains an extra entity reference node, whose children is the |
---|
1561 | * sub tree of the replacement text. |
---|
1562 | * <p>The default value is 'false'. |
---|
1563 | * |
---|
1564 | * @param expand The new state of the expand entity reference |
---|
1565 | * flag. |
---|
1566 | * @see #setCreateEntityReferenceNodes |
---|
1567 | */ |
---|
1568 | void setExpandEntityReferences(const bool expand); |
---|
1569 | |
---|
1570 | /** Get the 'expand entity references' flag. |
---|
1571 | * DEPRECATED Use getCreateEntityReferenceNodes() instead. |
---|
1572 | * |
---|
1573 | * This method returns the state of the parser's expand entity |
---|
1574 | * references flag. |
---|
1575 | * |
---|
1576 | * @return 'true' if the expand entity reference flag is set on |
---|
1577 | * the parser, 'false' otherwise. |
---|
1578 | * |
---|
1579 | * @see #setExpandEntityReferences |
---|
1580 | * @see #setCreateEntityReferenceNodes |
---|
1581 | * @see #getCreateEntityReferenceNodes |
---|
1582 | */ |
---|
1583 | bool getExpandEntityReferences() const; |
---|
1584 | |
---|
1585 | /** |
---|
1586 | * DEPRECATED Use getValidationScheme() instead |
---|
1587 | * |
---|
1588 | * This method returns the state of the parser's validation |
---|
1589 | * handling flag which controls whether validation checks |
---|
1590 | * are enforced or not. |
---|
1591 | * |
---|
1592 | * @return true, if the parser is currently configured to |
---|
1593 | * do validation, false otherwise. |
---|
1594 | * |
---|
1595 | * @see #setDoValidation |
---|
1596 | * @see #getValidationScheme |
---|
1597 | */ |
---|
1598 | bool getDoValidation() const; |
---|
1599 | |
---|
1600 | /** |
---|
1601 | * DEPRECATED Use setValidationScheme(const ValSchemes newScheme) instead |
---|
1602 | * |
---|
1603 | * This method allows users to enable or disable the parser's validation |
---|
1604 | * checks. |
---|
1605 | * |
---|
1606 | * <p>By default, the parser does not to any validation. The default |
---|
1607 | * value is false.</p> |
---|
1608 | * |
---|
1609 | * @param newState The value specifying whether the parser should |
---|
1610 | * do validity checks or not against the DTD in the |
---|
1611 | * input XML document. |
---|
1612 | * |
---|
1613 | * @see #getDoValidation |
---|
1614 | * @see #setValidationScheme |
---|
1615 | */ |
---|
1616 | void setDoValidation(const bool newState); |
---|
1617 | |
---|
1618 | /** |
---|
1619 | * Deprecated doctypehandler interfaces |
---|
1620 | */ |
---|
1621 | virtual void attDef |
---|
1622 | ( |
---|
1623 | const DTDElementDecl& elemDecl |
---|
1624 | , const DTDAttDef& attDef |
---|
1625 | , const bool ignoring |
---|
1626 | ); |
---|
1627 | |
---|
1628 | virtual void doctypeComment |
---|
1629 | ( |
---|
1630 | const XMLCh* const comment |
---|
1631 | ); |
---|
1632 | |
---|
1633 | virtual void doctypeDecl |
---|
1634 | ( |
---|
1635 | const DTDElementDecl& elemDecl |
---|
1636 | , const XMLCh* const publicId |
---|
1637 | , const XMLCh* const systemId |
---|
1638 | , const bool hasIntSubset |
---|
1639 | , const bool hasExtSubset = false |
---|
1640 | ); |
---|
1641 | |
---|
1642 | virtual void doctypePI |
---|
1643 | ( |
---|
1644 | const XMLCh* const target |
---|
1645 | , const XMLCh* const data |
---|
1646 | ); |
---|
1647 | |
---|
1648 | virtual void doctypeWhitespace |
---|
1649 | ( |
---|
1650 | const XMLCh* const chars |
---|
1651 | , const unsigned int length |
---|
1652 | ); |
---|
1653 | |
---|
1654 | virtual void elementDecl |
---|
1655 | ( |
---|
1656 | const DTDElementDecl& decl |
---|
1657 | , const bool isIgnored |
---|
1658 | ); |
---|
1659 | |
---|
1660 | virtual void endAttList |
---|
1661 | ( |
---|
1662 | const DTDElementDecl& elemDecl |
---|
1663 | ); |
---|
1664 | |
---|
1665 | virtual void endIntSubset(); |
---|
1666 | |
---|
1667 | virtual void endExtSubset(); |
---|
1668 | |
---|
1669 | virtual void entityDecl |
---|
1670 | ( |
---|
1671 | const DTDEntityDecl& entityDecl |
---|
1672 | , const bool isPEDecl |
---|
1673 | , const bool isIgnored |
---|
1674 | ); |
---|
1675 | |
---|
1676 | virtual void resetDocType(); |
---|
1677 | |
---|
1678 | virtual void notationDecl |
---|
1679 | ( |
---|
1680 | const XMLNotationDecl& notDecl |
---|
1681 | , const bool isIgnored |
---|
1682 | ); |
---|
1683 | |
---|
1684 | virtual void startAttList |
---|
1685 | ( |
---|
1686 | const DTDElementDecl& elemDecl |
---|
1687 | ); |
---|
1688 | |
---|
1689 | virtual void startIntSubset(); |
---|
1690 | |
---|
1691 | virtual void startExtSubset(); |
---|
1692 | |
---|
1693 | virtual void TextDecl |
---|
1694 | ( |
---|
1695 | const XMLCh* const versionStr |
---|
1696 | , const XMLCh* const encodingStr |
---|
1697 | ); |
---|
1698 | |
---|
1699 | |
---|
1700 | //@} |
---|
1701 | |
---|
1702 | |
---|
1703 | protected : |
---|
1704 | // ----------------------------------------------------------------------- |
---|
1705 | // Protected getter methods |
---|
1706 | // ----------------------------------------------------------------------- |
---|
1707 | |
---|
1708 | /** @name Protected getter methods */ |
---|
1709 | //@{ |
---|
1710 | /** Get the current DOM node |
---|
1711 | * |
---|
1712 | * This provides derived classes with access to the current node, i.e. |
---|
1713 | * the node to which new nodes are being added. |
---|
1714 | */ |
---|
1715 | DOM_Node getCurrentNode(); |
---|
1716 | |
---|
1717 | //@} |
---|
1718 | |
---|
1719 | |
---|
1720 | // ----------------------------------------------------------------------- |
---|
1721 | // Protected setter methods |
---|
1722 | // ----------------------------------------------------------------------- |
---|
1723 | |
---|
1724 | /** @name Protected setter methods */ |
---|
1725 | //@{ |
---|
1726 | |
---|
1727 | /** Set the current DOM node |
---|
1728 | * |
---|
1729 | * This method sets the current node maintained inside the parser to |
---|
1730 | * the one specified. |
---|
1731 | * |
---|
1732 | * @param toSet The DOM node which will be the current node. |
---|
1733 | */ |
---|
1734 | void setCurrentNode(DOM_Node toSet); |
---|
1735 | |
---|
1736 | /** Set the document node |
---|
1737 | * |
---|
1738 | * This method sets the DOM Document node to the one specified. |
---|
1739 | * |
---|
1740 | * @param toSet The new DOM Document node for this XML document. |
---|
1741 | */ |
---|
1742 | void setDocument(DOM_Document toSet); |
---|
1743 | //@} |
---|
1744 | |
---|
1745 | |
---|
1746 | private : |
---|
1747 | // ----------------------------------------------------------------------- |
---|
1748 | // Protected setter methods |
---|
1749 | // ----------------------------------------------------------------------- |
---|
1750 | void initialize(); |
---|
1751 | void cleanUp(); |
---|
1752 | |
---|
1753 | // unimplemented |
---|
1754 | DOMParser ( const DOMParser& toCopy); |
---|
1755 | DOMParser& operator= (const DOMParser& other); |
---|
1756 | |
---|
1757 | // ----------------------------------------------------------------------- |
---|
1758 | // Private data members |
---|
1759 | // |
---|
1760 | // fCurrentNode |
---|
1761 | // fCurrentParent |
---|
1762 | // Used to track the current node during nested element events. Since |
---|
1763 | // the tree must be built from a set of disjoint callbacks, we need |
---|
1764 | // these to keep up with where we currently are. |
---|
1765 | // |
---|
1766 | // fDocument |
---|
1767 | // The root document object, filled with the document contents. |
---|
1768 | // |
---|
1769 | // fEntityResolver |
---|
1770 | // The installed SAX entity resolver, if any. Null if none. |
---|
1771 | // |
---|
1772 | // fErrorHandler |
---|
1773 | // The installed SAX error handler, if any. Null if none. |
---|
1774 | // |
---|
1775 | // fCreateEntityReferenceNode |
---|
1776 | // Indicates whether entity reference nodes should be created. |
---|
1777 | // |
---|
1778 | // fIncludeIgnorableWhitespace |
---|
1779 | // Indicates whether ignorable whiltespace should be added to |
---|
1780 | // the DOM tree for validating parsers. |
---|
1781 | // |
---|
1782 | // fNodeStack |
---|
1783 | // Used to track previous parent nodes during nested element events. |
---|
1784 | // |
---|
1785 | // fParseInProgress |
---|
1786 | // Used to prevent multiple entrance to the parser while its doing |
---|
1787 | // a parse. |
---|
1788 | // |
---|
1789 | // fScanner |
---|
1790 | // The scanner used for this parser. This is created during the |
---|
1791 | // constructor. |
---|
1792 | // |
---|
1793 | // fWithinElement |
---|
1794 | // A flag to indicate that the parser is within at least one level |
---|
1795 | // of element processing. |
---|
1796 | // |
---|
1797 | // fDocumentType |
---|
1798 | // Used to store and update the documentType variable information |
---|
1799 | // in fDocument |
---|
1800 | // |
---|
1801 | // fToCreateXMLDecTypeNode |
---|
1802 | // A flag to create a DOM_XMLDecl node in the ODM tree if it exists |
---|
1803 | // This is an extension to xerces implementation |
---|
1804 | // |
---|
1805 | // fGrammarPool |
---|
1806 | // The grammar pool passed from external application (through derivatives). |
---|
1807 | // which could be 0, not owned. |
---|
1808 | // |
---|
1809 | // ----------------------------------------------------------------------- |
---|
1810 | bool fToCreateXMLDeclTypeNode; |
---|
1811 | bool fCreateEntityReferenceNodes; |
---|
1812 | bool fIncludeIgnorableWhitespace; |
---|
1813 | bool fParseInProgress; |
---|
1814 | bool fWithinElement; |
---|
1815 | DOM_Node fCurrentParent; |
---|
1816 | DOM_Node fCurrentNode; |
---|
1817 | DOM_Document fDocument; |
---|
1818 | EntityResolver* fEntityResolver; |
---|
1819 | XMLEntityResolver* fXMLEntityResolver; |
---|
1820 | ErrorHandler* fErrorHandler; |
---|
1821 | PSVIHandler* fPSVIHandler; |
---|
1822 | ValueStackOf<DOM_Node>* fNodeStack; |
---|
1823 | XMLScanner* fScanner; |
---|
1824 | DocumentTypeImpl* fDocumentType; |
---|
1825 | GrammarResolver* fGrammarResolver; |
---|
1826 | XMLStringPool* fURIStringPool; |
---|
1827 | XMLValidator* fValidator; |
---|
1828 | MemoryManager* fMemoryManager; |
---|
1829 | XMLGrammarPool* fGrammarPool; |
---|
1830 | }; |
---|
1831 | |
---|
1832 | |
---|
1833 | // --------------------------------------------------------------------------- |
---|
1834 | // DOMParser: Handlers for the XMLEntityHandler interface |
---|
1835 | // --------------------------------------------------------------------------- |
---|
1836 | inline void DOMParser::endInputSource(const InputSource&) |
---|
1837 | { |
---|
1838 | // The DOM entity resolver doesn't handle this |
---|
1839 | } |
---|
1840 | |
---|
1841 | inline bool DOMParser::expandSystemId(const XMLCh* const, XMLBuffer&) |
---|
1842 | { |
---|
1843 | // The DOM entity resolver doesn't handle this |
---|
1844 | return false; |
---|
1845 | } |
---|
1846 | |
---|
1847 | inline void DOMParser::resetEntities() |
---|
1848 | { |
---|
1849 | // Nothing to do on this one |
---|
1850 | } |
---|
1851 | |
---|
1852 | inline void DOMParser::startInputSource(const InputSource&) |
---|
1853 | { |
---|
1854 | // The DOM entity resolver doesn't handle this |
---|
1855 | } |
---|
1856 | |
---|
1857 | |
---|
1858 | // --------------------------------------------------------------------------- |
---|
1859 | // DOMParser: Getter methods |
---|
1860 | // --------------------------------------------------------------------------- |
---|
1861 | inline DOM_Document DOMParser::getDocument() |
---|
1862 | { |
---|
1863 | return fDocument; |
---|
1864 | } |
---|
1865 | |
---|
1866 | inline ErrorHandler* DOMParser::getErrorHandler() |
---|
1867 | { |
---|
1868 | return fErrorHandler; |
---|
1869 | } |
---|
1870 | |
---|
1871 | inline const ErrorHandler* DOMParser::getErrorHandler() const |
---|
1872 | { |
---|
1873 | return fErrorHandler; |
---|
1874 | } |
---|
1875 | |
---|
1876 | inline PSVIHandler* DOMParser::getPSVIHandler() |
---|
1877 | { |
---|
1878 | return fPSVIHandler; |
---|
1879 | } |
---|
1880 | |
---|
1881 | inline const PSVIHandler* DOMParser::getPSVIHandler() const |
---|
1882 | { |
---|
1883 | return fPSVIHandler; |
---|
1884 | } |
---|
1885 | |
---|
1886 | inline EntityResolver* DOMParser::getEntityResolver() |
---|
1887 | { |
---|
1888 | return fEntityResolver; |
---|
1889 | } |
---|
1890 | |
---|
1891 | inline XMLEntityResolver* DOMParser::getXMLEntityResolver() |
---|
1892 | { |
---|
1893 | return fXMLEntityResolver; |
---|
1894 | } |
---|
1895 | |
---|
1896 | inline const XMLEntityResolver* DOMParser::getXMLEntityResolver() const |
---|
1897 | { |
---|
1898 | return fXMLEntityResolver; |
---|
1899 | } |
---|
1900 | |
---|
1901 | inline const EntityResolver* DOMParser::getEntityResolver() const |
---|
1902 | { |
---|
1903 | return fEntityResolver; |
---|
1904 | } |
---|
1905 | |
---|
1906 | inline bool DOMParser::getExpandEntityReferences() const |
---|
1907 | { |
---|
1908 | return !fCreateEntityReferenceNodes; |
---|
1909 | } |
---|
1910 | inline bool DOMParser::getCreateEntityReferenceNodes() const |
---|
1911 | { |
---|
1912 | return fCreateEntityReferenceNodes; |
---|
1913 | } |
---|
1914 | |
---|
1915 | inline bool DOMParser::getIncludeIgnorableWhitespace() const |
---|
1916 | { |
---|
1917 | return fIncludeIgnorableWhitespace; |
---|
1918 | } |
---|
1919 | |
---|
1920 | inline const XMLScanner& DOMParser::getScanner() const |
---|
1921 | { |
---|
1922 | return *fScanner; |
---|
1923 | } |
---|
1924 | |
---|
1925 | inline bool DOMParser::getToCreateXMLDeclTypeNode() const |
---|
1926 | { |
---|
1927 | return fToCreateXMLDeclTypeNode; |
---|
1928 | } |
---|
1929 | |
---|
1930 | |
---|
1931 | // --------------------------------------------------------------------------- |
---|
1932 | // DOMParser: Setter methods |
---|
1933 | // --------------------------------------------------------------------------- |
---|
1934 | inline void DOMParser::setExpandEntityReferences(const bool expand) |
---|
1935 | { |
---|
1936 | fCreateEntityReferenceNodes = !expand; |
---|
1937 | } |
---|
1938 | |
---|
1939 | inline void DOMParser::setCreateEntityReferenceNodes(const bool create) |
---|
1940 | { |
---|
1941 | fCreateEntityReferenceNodes = create; |
---|
1942 | } |
---|
1943 | |
---|
1944 | inline void DOMParser::setIncludeIgnorableWhitespace(const bool include) |
---|
1945 | { |
---|
1946 | fIncludeIgnorableWhitespace = include; |
---|
1947 | } |
---|
1948 | |
---|
1949 | inline void DOMParser::setToCreateXMLDeclTypeNode(const bool create) |
---|
1950 | { |
---|
1951 | fToCreateXMLDeclTypeNode = create; |
---|
1952 | } |
---|
1953 | |
---|
1954 | |
---|
1955 | // --------------------------------------------------------------------------- |
---|
1956 | // DOMParser: Protected getter methods |
---|
1957 | // --------------------------------------------------------------------------- |
---|
1958 | inline DOM_Node DOMParser::getCurrentNode() |
---|
1959 | { |
---|
1960 | return fCurrentNode; |
---|
1961 | } |
---|
1962 | |
---|
1963 | // --------------------------------------------------------------------------- |
---|
1964 | // DOMParser: Protected setter methods |
---|
1965 | // --------------------------------------------------------------------------- |
---|
1966 | inline void DOMParser::setCurrentNode(DOM_Node toSet) |
---|
1967 | { |
---|
1968 | fCurrentNode = toSet; |
---|
1969 | } |
---|
1970 | |
---|
1971 | inline void DOMParser::setDocument(DOM_Document toSet) |
---|
1972 | { |
---|
1973 | fDocument = toSet; |
---|
1974 | } |
---|
1975 | |
---|
1976 | XERCES_CPP_NAMESPACE_END |
---|
1977 | |
---|
1978 | #endif |
---|