KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > parsers > SAXParser


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999,2000 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.parsers;
59
60 import org.enhydra.apache.xerces.framework.XMLAttrList;
61 import org.enhydra.apache.xerces.framework.XMLContentSpec;
62 import org.enhydra.apache.xerces.framework.XMLDocumentHandler;
63 import org.enhydra.apache.xerces.framework.XMLParser;
64 import org.enhydra.apache.xerces.readers.XMLEntityHandler;
65 import org.enhydra.apache.xerces.utils.QName;
66 import org.enhydra.apache.xerces.utils.StringPool;
67 import org.enhydra.apache.xerces.validators.common.XMLAttributeDecl;
68 import org.enhydra.apache.xerces.validators.common.XMLElementDecl;
69 import org.xml.sax.AttributeList JavaDoc;
70 import org.xml.sax.ContentHandler JavaDoc;
71 import org.xml.sax.DocumentHandler JavaDoc;
72 import org.xml.sax.Parser JavaDoc;
73 import org.xml.sax.SAXException JavaDoc;
74 import org.xml.sax.SAXNotRecognizedException JavaDoc;
75 import org.xml.sax.SAXNotSupportedException JavaDoc;
76 import org.xml.sax.XMLReader JavaDoc;
77 import org.xml.sax.ext.DeclHandler JavaDoc;
78 import org.xml.sax.ext.LexicalHandler JavaDoc;
79 import org.xml.sax.helpers.AttributesImpl JavaDoc;
80
81 // REVISIT: [SAX2beta] ContentHandler#skippedEntity(String)
82

83 /**
84  * SAXParser provides a parser which implements the SAX1 and SAX2
85  * parser APIs.
86  *
87  * @version $Id: SAXParser.java,v 1.2 2005/01/26 08:28:44 jkjome Exp $
88  */

89 public class SAXParser
90     extends XMLParser
91     implements XMLDocumentHandler, XMLDocumentHandler.DTDHandler,
92                Parser, XMLReader JavaDoc {
93
94     //
95
// Constants
96
//
97

98     // private
99

100     /** Features recognized by this parser. */
101     private static final String JavaDoc RECOGNIZED_FEATURES[] = {
102         // SAX2 core
103
/*"http://xml.org/sax/features/normalize-text",*/
104         /*"http://xml.org/sax/features/use-locator",*/
105         "http://xml.org/sax/features/namespace-prefixes",
106         "http://xml.org/sax/features/string-interning",
107         // Xerces
108
};
109
110     /** Properties recognized by this parser. */
111     private static final String JavaDoc RECOGNIZED_PROPERTIES[] = {
112         // SAX2 core
113
"http://xml.org/sax/properties/lexical-handler",
114         "http://xml.org/sax/properties/declaration-handler",
115         "http://xml.org/sax/properties/dom-node",
116         // Xerces
117
};
118
119     // debugging
120

121     /** Set to true and recompile to debug callbacks. */
122     private static final boolean DEBUG_CALLBACKS = false;
123
124     //
125
// Data
126
//
127

128     // parser handlers
129

130     /** Document handler. */
131     private DocumentHandler fDocumentHandler;
132
133     // parser/xmlreader handlers
134

135     /** DTD handler. */
136     private org.xml.sax.DTDHandler JavaDoc fDTDHandler;
137
138     // xmlreader handlers
139

140     /** Content handler. */
141     private ContentHandler JavaDoc fContentHandler;
142
143     /** Decl handler. */
144     private DeclHandler JavaDoc fDeclHandler;
145
146     /** Lexical handler. */
147     private LexicalHandler JavaDoc fLexicalHandler;
148     
149     private boolean fNamespacePrefixes = false;
150
151     // temp
152

153     private transient AttributesImpl JavaDoc fAttributes = new AttributesImpl JavaDoc();
154
155     //
156
// Constructors
157
//
158

159     /** Default constructor. */
160     public SAXParser() {
161         initHandlers(true, this, this);
162     }
163
164     protected SAXParser(StringPool stringPool) {
165         super(stringPool);
166         initHandlers(true, this, this);
167     }
168
169     //
170
// Public methods
171
//
172

173     // features and properties
174

175     /**
176      * Returns a list of features that this parser recognizes.
177      * This method will never return null; if no features are
178      * recognized, this method will return a zero length array.
179      *
180      * @see #isFeatureRecognized
181      * @see #setFeature
182      * @see #getFeature
183      */

184     public String JavaDoc[] getFeaturesRecognized() {
185
186         // get features that super/this recognizes
187
String JavaDoc superRecognized[] = super.getFeaturesRecognized();
188         String JavaDoc thisRecognized[] = RECOGNIZED_FEATURES;
189
190         // is one or the other the empty set?
191
int thisLength = thisRecognized.length;
192         if (thisLength == 0) {
193             return superRecognized;
194         }
195         int superLength = superRecognized.length;
196         if (superLength == 0) {
197             return thisRecognized;
198         }
199
200         // combine the two lists and return
201
String JavaDoc recognized[] = new String JavaDoc[superLength + thisLength];
202         System.arraycopy(superRecognized, 0, recognized, 0, superLength);
203         System.arraycopy(thisRecognized, 0, recognized, superLength, thisLength);
204         return recognized;
205
206     } // getFeaturesRecognized():String[]
207

208     /**
209      * Returns a list of properties that this parser recognizes.
210      * This method will never return null; if no properties are
211      * recognized, this method will return a zero length array.
212      *
213      * @see #isPropertyRecognized
214      * @see #setProperty
215      * @see #getProperty
216      */

217     public String JavaDoc[] getPropertiesRecognized() {
218
219         // get properties that super/this recognizes
220
String JavaDoc superRecognized[] = super.getPropertiesRecognized();
221         String JavaDoc thisRecognized[] = RECOGNIZED_PROPERTIES;
222
223         // is one or the other the empty set?
224
int thisLength = thisRecognized.length;
225         if (thisLength == 0) {
226             return superRecognized;
227         }
228         int superLength = superRecognized.length;
229         if (superLength == 0) {
230             return thisRecognized;
231         }
232
233         // combine the two lists and return
234
String JavaDoc recognized[] = new String JavaDoc[superLength + thisLength];
235         System.arraycopy(superRecognized, 0, recognized, 0, superLength);
236         System.arraycopy(thisRecognized, 0, recognized, superLength, thisLength);
237         return recognized;
238
239     }
240
241     //
242
// Protected methods
243
//
244

245     // SAX2 core features
246

247     /**
248      * <b>Note: Currently, the parser does not support this feature.</b>
249      * Setting this feature to true will throw a SAXNotSupportedException.
250      * <p>
251      * Ensures that all consecutive text is returned in a single callback
252      * to the DocumentHandler.characters or DocumentHandler.ignorableWhitespace
253      * methods.
254      * <p>
255      * This method is the equivalent to the feature:
256      * <pre>
257      * http://xml.org/sax/features/normalize-text
258      * <pre>
259      *
260      * @param normalize True to normalize; false not to normalize.
261      *
262      * @see #getNormalizeText
263      * @see #setFeature
264      */

265     /*
266     protected void setNormalizeText(boolean normalize)
267         throws SAXNotRecognizedException, SAXNotSupportedException {
268         if (normalize) {
269             throw new SAXNotSupportedException("http://xml.org/sax/features/normalize-text");
270         }
271     }
272     */

273
274     /**
275      * <b>Note: This feature is always false.</b>
276      * <p>
277      * Returns true if the parser normalizes all consecutive text into
278      * a single callback to the DocumentHandler.characters or
279      * DocumentHandler.ignorableWhitespace methods.
280      *
281      * @see #setNormalizeText
282      */

283     /*
284     protected boolean getNormalizeText()
285         throws SAXNotRecognizedException, SAXNotSupportedException {
286         return false;
287     }
288     */

289
290     /**
291      * <b>Note: Currently, this parser always sets the locator.</b>
292      * Setting this feature to false will throw a SAXNotSupportedException.
293      * <p>
294      * Provide a Locator using the DocumentHandler.setDocumentLocator
295      * callback (true), or explicitly do not provide one (false).
296      * <p>
297      * This method is the equivalent to the feature:
298      * <pre>
299      * http://xml.org/sax/features/use-locator
300      * </pre>
301      *
302      * @see #getUseLocator
303      * @see #setFeature
304      */

305     /*
306     protected void setUseLocator(boolean use)
307         throws SAXNotRecognizedException, SAXNotSupportedException {
308         if (!use) {
309             throw new SAXNotSupportedException("http://xml.org/sax/features/use-locator");
310         }
311     }
312     */

313
314     /**
315      * <b>Note: This feature is always true.</b>
316      * <p>
317      * Returns true if the locator is always set.
318      *
319      * @see #setUseLocator
320      */

321     /*
322     protected boolean getUseLocator()
323         throws SAXNotRecognizedException, SAXNotSupportedException {
324         return true;
325     }
326     */

327
328     // SAX2 core properties
329

330     /**
331      * Set the DTD declaration event handler.
332      * <p>
333      * This method is the equivalent to the property:
334      * <pre>
335      * http://xml.org/sax/properties/declaration-handler
336      * </pre>
337      *
338      * @param handler The new handler.
339      *
340      * @see #getDeclHandler
341      * @see #setProperty
342      */

343     protected void setDeclHandler(DeclHandler JavaDoc handler)
344         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
345         if (fParseInProgress) {
346             throw new SAXNotSupportedException JavaDoc(
347                 "PAR011 Feature: http://xml.org/sax/properties/declaration-handler"
348                 +" is not supported during parse."
349                 +"\nhttp://xml.org/sax/properties/declaration-handler");
350         }
351         fDeclHandler = handler;
352     }
353
354     /**
355      * Returns the DTD declaration event handler.
356      *
357      * @see #setDeclHandler
358      */

359     protected DeclHandler JavaDoc getDeclHandler()
360         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
361         return fDeclHandler;
362     }
363
364     /**
365      * Set the lexical event handler.
366      * <p>
367      * This method is the equivalent to the property:
368      * <pre>
369      * http://xml.org/sax/properties/lexical-handler
370      * </pre>
371      *
372      * @param handler lexical event handler
373      *
374      * @see #getLexicalHandler
375      * @see #setProperty
376      */

377     protected void setLexicalHandler(LexicalHandler JavaDoc handler)
378         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
379         if (fParseInProgress) {
380             throw new SAXNotSupportedException JavaDoc(
381             "PAR011 Feature: http://xml.org/sax/properties/lexical-handler"
382             +" is not supported during parse."
383             +"\nhttp://xml.org/sax/properties/lexical-handler");
384         }
385         fLexicalHandler = handler;
386     }
387
388     /**
389      * Returns the lexical handler.
390      *
391      * @see #setLexicalHandler
392      */

393     protected LexicalHandler JavaDoc getLexicalHandler()
394         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
395         return fLexicalHandler;
396     }
397
398     //
399
// Parser methods
400
//
401

402     /** Sets the document handler. */
403     public void setDocumentHandler(DocumentHandler handler) {
404         fDocumentHandler = handler;
405     }
406
407     //
408
// Parser/XMLReader methods
409
//
410

411     /**
412      * Allow an application to register a DTD event handler.
413      *
414      * <p>If the application does not register a DTD handler, all DTD
415      * events reported by the SAX parser will be silently ignored.</p>
416      *
417      * <p>Applications may register a new or different handler in the
418      * middle of a parse, and the SAX parser must begin using the new
419      * handler immediately.</p>
420      *
421      * @param handler The DTD handler.
422      * @exception java.lang.NullPointerException If the handler
423      * argument is null.
424      * @see #getDTDHandler
425      */

426     public void setDTDHandler(org.xml.sax.DTDHandler JavaDoc handler) {
427         fDTDHandler = handler;
428     }
429
430     /**
431      * Return the current DTD handler.
432      *
433      * @return The current DTD handler, or null if none
434      * has been registered.
435      * @see #setDTDHandler
436      */

437     public org.xml.sax.DTDHandler JavaDoc getDTDHandler() {
438         return fDTDHandler;
439     }
440     
441     /**
442      * Sets how the parser reports raw prefixed names,
443      * and whether xmlns attributes are reported.
444      * <p>
445      * This method is the equivalent to the feature:
446      * <pre>
447      * http://xml.org/sax/features/namespaces-prefixes
448      * <pre>
449      *
450      * @param process True to process namespaces; false to not process.
451      *
452      * @see #getNamespaces
453      * @see #setFeature
454      */

455     protected void setNamespacePrefixes(boolean process)
456         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
457         if (fParseInProgress) {
458             throw new SAXNotSupportedException JavaDoc("PAR004 Cannot setFeature(http://xml.org/sax/features/namespace-prefixes): parse is in progress.\n"+
459                                                "http://xml.org/sax/features/namespace-prefixes");
460         }
461         fNamespacePrefixes = process;
462     }
463
464     /**
465      * Returns the http://xml.org/features/namespace-prefixes
466      * value.
467      *
468      * @see #setNamespacePrefixes
469      */

470     protected boolean getNamespacePrefixes()
471         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
472         return fNamespacePrefixes;
473     }
474     
475
476     //
477
// XMLReader methods
478
//
479

480     /**
481      * Set the state of any feature in a SAX2 parser. The parser
482      * might not recognize the feature, and if it does recognize
483      * it, it might not be able to fulfill the request.
484      *
485      * @param featureId The unique identifier (URI) of the feature.
486      * @param state The requested state of the feature (true or false).
487      *
488      * @exception SAXNotRecognizedException If the
489      * requested feature is not known.
490      * @exception SAXNotSupportedException If the
491      * requested feature is known, but the requested
492      * state is not supported.
493      */

494     public void setFeature(String JavaDoc featureId, boolean state)
495         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
496
497         //
498
// SAX2 Features
499
//
500

501         if (featureId.startsWith(SAX2_FEATURES_PREFIX)) {
502             String JavaDoc feature = featureId.substring(SAX2_FEATURES_PREFIX.length());
503
504             /*
505             //
506             // http://xml.org/sax/features/normalize-text
507             // Ensure that all consecutive text is returned in a single callback to
508             // DocumentHandler.characters or DocumentHandler.ignorableWhitespace
509             // (true) or explicitly do not require it (false).
510             //
511             if (feature.equals("normalize-text")) {
512                 setNormalizeText(state);
513                 return;
514             }
515             */

516             /*
517             //
518             // http://xml.org/sax/features/use-locator
519             // Provide a Locator using the DocumentHandler.setDocumentLocator
520             // callback (true), or explicitly do not provide one (false).
521             //
522             if (feature.equals("use-locator")) {
523                 setUseLocator(state);
524                 return;
525             }
526             */

527
528             // http://xml.org/sax/features/namespace-prefixes
529
// controls the reporting of raw prefixed names and Namespace
530
// declarations (xmlns* attributes): when this feature is false
531
// (the default), raw prefixed names may optionally be reported,
532
// and xmlns* attributes must not be reported.
533
//
534
if (feature.equals("namespace-prefixes")) {
535                 setNamespacePrefixes(state);
536                 return;
537             }
538             // http://xml.org/sax/features/string-interning
539
// controls the use of java.lang.String#intern() for strings
540
// passed to SAX handlers.
541
//
542
if (feature.equals("string-interning")) {
543                 if (state) {
544                     throw new SAXNotSupportedException JavaDoc(
545                         "PAR018 "+state+" state for feature \""+featureId+"\" is not supported.\n"+
546                         state+'\t'+featureId
547                         );
548                 }
549                 return;
550             }
551    
552             //
553
// Drop through and perform default processing
554
//
555
}
556
557         //
558
// Xerces Features
559
//
560

561         /*
562         else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
563             String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
564             //
565             // Drop through and perform default processing
566             //
567         }
568         */

569
570         //
571
// Perform default processing
572
//
573

574         super.setFeature(featureId, state);
575
576     } // setFeature(String,boolean)
577

578     /**
579      * Query the state of a feature.
580      *
581      * Query the current state of any feature in a SAX2 parser. The
582      * parser might not recognize the feature.
583      *
584      * @param featureId The unique identifier (URI) of the feature
585      * being set.
586      * @return The current state of the feature.
587      * @exception org.xml.sax.SAXNotRecognizedException If the
588      * requested feature is not known.
589      * @exception SAXNotSupportedException If the
590      * requested feature is known but not supported.
591      */

592     public boolean getFeature(String JavaDoc featureId)
593         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
594
595         //
596
// SAX2 Features
597
//
598

599         if (featureId.startsWith(SAX2_FEATURES_PREFIX)) {
600             String JavaDoc feature = featureId.substring(SAX2_FEATURES_PREFIX.length());
601
602             /*
603             //
604             // http://xml.org/sax/features/normalize-text
605             // Ensure that all consecutive text is returned in a single callback to
606             // DocumentHandler.characters or DocumentHandler.ignorableWhitespace
607             // (true) or explicitly do not require it (false).
608             //
609             if (feature.equals("normalize-text")) {
610                 return getNormalizeText();
611             }
612             */

613             /*
614             //
615             // http://xml.org/sax/features/use-locator
616             // Provide a Locator using the DocumentHandler.setDocumentLocator
617             // callback (true), or explicitly do not provide one (false).
618             //
619             if (feature.equals("use-locator")) {
620                 return getUseLocator();
621             }
622             */

623
624             // http://xml.org/sax/features/namespace-prefixes
625
// controls the reporting of raw prefixed names and Namespace
626
// declarations (xmlns* attributes): when this feature is false
627
// (the default), raw prefixed names may optionally be reported,
628
// and xmlns* attributes must not be reported.
629
//
630
if (feature.equals("namespace-prefixes")) {
631                 return getNamespacePrefixes();
632             }
633             // http://xml.org/sax/features/string-interning
634
// controls the use of java.lang.String#intern() for strings
635
// passed to SAX handlers.
636
//
637
if (feature.equals("string-interning")) {
638                 return false;
639             }
640
641             //
642
// Drop through and perform default processing
643
//
644
}
645
646         //
647
// Xerces Features
648
//
649

650         /*
651         else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
652             //
653             // Drop through and perform default processing
654             //
655         }
656         */

657
658         //
659
// Perform default processing
660
//
661

662         return super.getFeature(featureId);
663
664     } // getFeature(String):boolean
665

666     /**
667      * Set the value of any property in a SAX2 parser. The parser
668      * might not recognize the property, and if it does recognize
669      * it, it might not support the requested value.
670      *
671      * @param propertyId The unique identifier (URI) of the property
672      * being set.
673      * @param Object The value to which the property is being set.
674      *
675      * @exception SAXNotRecognizedException If the
676      * requested property is not known.
677      * @exception SAXNotSupportedException If the
678      * requested property is known, but the requested
679      * value is not supported.
680      */

681     public void setProperty(String JavaDoc propertyId, Object JavaDoc value)
682         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
683
684         //
685
// SAX2 core properties
686
//
687

688         if (propertyId.startsWith(SAX2_PROPERTIES_PREFIX)) {
689             String JavaDoc property = propertyId.substring(SAX2_PROPERTIES_PREFIX.length());
690             //
691
// http://xml.org/sax/properties/lexical-handler
692
// Value type: org.xml.sax.ext.LexicalHandler
693
// Access: read/write, pre-parse only
694
// Set the lexical event handler.
695
//
696
if (property.equals("lexical-handler")) {
697                 try {
698                     setLexicalHandler((LexicalHandler JavaDoc)value);
699                 }
700                 catch (ClassCastException JavaDoc e) {
701                     throw new SAXNotSupportedException JavaDoc(
702                     "PAR012 For propertyID \""
703                     +propertyId+"\", the value \""
704                     +value+"\" cannot be cast to LexicalHandler."
705                     +'\n'+propertyId+'\t'+value+"\tLexicalHandler");
706                 }
707                 return;
708             }
709             //
710
// http://xml.org/sax/properties/declaration-handler
711
// Value type: org.xml.sax.ext.DeclHandler
712
// Access: read/write, pre-parse only
713
// Set the DTD declaration event handler.
714
//
715
if (property.equals("declaration-handler")) {
716                 try {
717                     setDeclHandler((DeclHandler JavaDoc)value);
718                 }
719                 catch (ClassCastException JavaDoc e) {
720                     throw new SAXNotSupportedException JavaDoc(
721                     "PAR012 For propertyID \""
722                     +propertyId+"\", the value \""
723                     +value+"\" cannot be cast to DeclHandler."
724                     +'\n'+propertyId+'\t'+value+"\tDeclHandler"
725                     );
726                 }
727                 return;
728             }
729             //
730
// http://xml.org/sax/properties/dom-node
731
// Value type: DOM Node
732
// Access: read-only
733
// Get the DOM node currently being visited, if the SAX parser is
734
// iterating over a DOM tree. If the parser recognises and supports
735
// this property but is not currently visiting a DOM node, it should
736
// return null (this is a good way to check for availability before the
737
// parse begins).
738
//
739
if (property.equals("dom-node")) {
740                 throw new SAXNotSupportedException JavaDoc(
741                     "PAR013 Property \""+propertyId+"\" is read only."
742                     +'\n'+propertyId
743                     ); // read-only property
744
}
745             //
746
// Drop through and perform default processing
747
//
748
}
749
750         //
751
// Xerces Properties
752
//
753

754         /*
755         else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
756             //
757             // Drop through and perform default processing
758             //
759         }
760         */

761
762         //
763
// Perform default processing
764
//
765

766         super.setProperty(propertyId, value);
767
768     } // setProperty(String,Object)
769

770     /**
771      * Query the value of a property.
772      *
773      * Return the current value of a property in a SAX2 parser.
774      * The parser might not recognize the property.
775      *
776      * @param propertyId The unique identifier (URI) of the property
777      * being set.
778      * @return The current value of the property.
779      * @exception org.xml.sax.SAXNotRecognizedException If the
780      * requested property is not known.
781      * @exception SAXNotSupportedException If the
782      * requested property is known but not supported.
783      */

784     public Object JavaDoc getProperty(String JavaDoc propertyId)
785         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
786
787         //
788
// SAX2 core properties
789
//
790

791         if (propertyId.startsWith(SAX2_PROPERTIES_PREFIX)) {
792             String JavaDoc property = propertyId.substring(SAX2_PROPERTIES_PREFIX.length());
793             //
794
// http://xml.org/sax/properties/lexical-handler
795
// Value type: org.xml.sax.ext.LexicalHandler
796
// Access: read/write, pre-parse only
797
// Set the lexical event handler.
798
//
799
if (property.equals("lexical-handler")) {
800                 return getLexicalHandler();
801             }
802             //
803
// http://xml.org/sax/properties/declaration-handler
804
// Value type: org.xml.sax.ext.DeclHandler
805
// Access: read/write, pre-parse only
806
// Set the DTD declaration event handler.
807
//
808
if (property.equals("declaration-handler")) {
809                 return getDeclHandler();
810             }
811             //
812
// http://xml.org/sax/properties/dom-node
813
// Value type: DOM Node
814
// Access: read-only
815
// Get the DOM node currently being visited, if the SAX parser is
816
// iterating over a DOM tree. If the parser recognises and supports
817
// this property but is not currently visiting a DOM node, it should
818
// return null (this is a good way to check for availability before the
819
// parse begins).
820
//
821
if (property.equals("dom-node")) {
822                 throw new SAXNotSupportedException JavaDoc(
823                 "PAR014 Cannot getProperty(\""+propertyId
824                 +"\". No DOM Tree exists.\n"+propertyId
825                 ); // we are not iterating a DOM tree
826
}
827             //
828
// Drop through and perform default processing
829
//
830
}
831
832         //
833
// Xerces properties
834
//
835

836         /*
837         else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
838             //
839             // Drop through and perform default processing
840             //
841         }
842         */

843
844         //
845
// Perform default processing
846
//
847

848         return super.getProperty(propertyId);
849
850     } // getProperty(String):Object
851

852     /**
853      * Allow an application to register a content event handler.
854      *
855      * <p>If the application does not register a content handler, all
856      * content events reported by the SAX parser will be silently
857      * ignored.</p>
858      *
859      * <p>Applications may register a new or different handler in the
860      * middle of a parse, and the SAX parser must begin using the new
861      * handler immediately.</p>
862      *
863      * @param handler The content handler.
864      * @exception java.lang.NullPointerException If the handler
865      * argument is null.
866      * @see #getContentHandler
867      */

868     public void setContentHandler(ContentHandler JavaDoc handler) {
869         if (handler == null) {
870             throw new NullPointerException JavaDoc();
871         }
872         fContentHandler = handler;
873     }
874
875     /**
876      * Return the current content handler.
877      *
878      * @return The current content handler, or null if none
879      * has been registered.
880      * @see #setContentHandler
881      */

882     public ContentHandler JavaDoc getContentHandler() {
883         return fContentHandler;
884     }
885
886     //
887
// XMLParser methods
888
//
889

890     /**
891      * This function will be called when a &lt;!DOCTYPE...&gt; declaration is
892      * encountered.
893      */

894     public void startDTD(QName rootElement, int publicId, int systemId) throws Exception JavaDoc {
895         if (fLexicalHandler != null || DEBUG_CALLBACKS) {
896
897             // strings
898
String JavaDoc name = fStringPool.toString(rootElement.rawname);
899             String JavaDoc pubid = fStringPool.toString(publicId);
900             String JavaDoc sysid = fStringPool.toString(systemId);
901
902             // perform callback
903
if (DEBUG_CALLBACKS) {
904                 System.err.println("startDTD(" + name + ", " + pubid + ", " + sysid + ")");
905             }
906             if (fLexicalHandler != null) {
907                 fLexicalHandler.startDTD(name, pubid, sysid);
908             }
909         }
910     }
911
912     /**
913      * This function will be called at the end of the DTD.
914      */

915     public void endDTD() throws Exception JavaDoc {
916         if (DEBUG_CALLBACKS) {
917             System.err.println("endDTD()");
918         }
919         if (fLexicalHandler != null) {
920             fLexicalHandler.endDTD();
921