KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > parsers > DOMParserImpl


1 /*
2  * Copyright 2000-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.parsers;
18
19 import java.io.StringReader JavaDoc;
20 import java.util.Locale JavaDoc;
21 import java.util.Stack JavaDoc;
22 import java.util.StringTokenizer JavaDoc;
23 import java.util.Vector JavaDoc;
24
25 import org.apache.xerces.dom.DOMErrorImpl;
26 import org.apache.xerces.dom.DOMMessageFormatter;
27 import org.apache.xerces.dom.DOMStringListImpl;
28 import org.apache.xerces.impl.Constants;
29 import org.apache.xerces.util.DOMEntityResolverWrapper;
30 import org.apache.xerces.util.DOMErrorHandlerWrapper;
31 import org.apache.xerces.util.SymbolTable;
32 import org.apache.xerces.util.XMLSymbols;
33 import org.apache.xerces.xni.Augmentations;
34 import org.apache.xerces.xni.NamespaceContext;
35 import org.apache.xerces.xni.QName;
36 import org.apache.xerces.xni.XMLAttributes;
37 import org.apache.xerces.xni.XMLDTDContentModelHandler;
38 import org.apache.xerces.xni.XMLDTDHandler;
39 import org.apache.xerces.xni.XMLDocumentHandler;
40 import org.apache.xerces.xni.XMLLocator;
41 import org.apache.xerces.xni.XMLResourceIdentifier;
42 import org.apache.xerces.xni.XMLString;
43 import org.apache.xerces.xni.XNIException;
44 import org.apache.xerces.xni.grammars.XMLGrammarPool;
45 import org.apache.xerces.xni.parser.XMLConfigurationException;
46 import org.apache.xerces.xni.parser.XMLDTDContentModelSource;
47 import org.apache.xerces.xni.parser.XMLDTDSource;
48 import org.apache.xerces.xni.parser.XMLDocumentSource;
49 import org.apache.xerces.xni.parser.XMLEntityResolver;
50 import org.apache.xerces.xni.parser.XMLInputSource;
51 import org.apache.xerces.xni.parser.XMLParseException;
52 import org.apache.xerces.xni.parser.XMLParserConfiguration;
53 import org.w3c.dom.DOMConfiguration JavaDoc;
54 import org.w3c.dom.DOMError JavaDoc;
55 import org.w3c.dom.DOMErrorHandler JavaDoc;
56 import org.w3c.dom.DOMException JavaDoc;
57 import org.w3c.dom.DOMStringList JavaDoc;
58 import org.w3c.dom.Document JavaDoc;
59 import org.w3c.dom.Node JavaDoc;
60 import org.w3c.dom.ls.LSException JavaDoc;
61 import org.w3c.dom.ls.LSInput JavaDoc;
62 import org.w3c.dom.ls.LSParser JavaDoc;
63 import org.w3c.dom.ls.LSParserFilter JavaDoc;
64 import org.w3c.dom.ls.LSResourceResolver JavaDoc;
65 import org.xml.sax.SAXException JavaDoc;
66
67
68 /**
69  * This is Xerces DOM Builder class. It uses the abstract DOM
70  * parser with a document scanner, a dtd scanner, and a validator, as
71  * well as a grammar pool.
72  *
73  * @author Pavani Mukthipudi, Sun Microsystems Inc.
74  * @author Elena Litani, IBM
75  * @author Rahul Srivastava, Sun Microsystems Inc.
76  * @version $Id: DOMParserImpl.java,v 1.35 2005/07/25 04:24:21 mrglavas Exp $
77  */

78
79
80 public class DOMParserImpl
81 extends AbstractDOMParser implements LSParser JavaDoc, DOMConfiguration JavaDoc {
82
83
84
85     // SAX & Xerces feature ids
86

87     /** Feature identifier: namespaces. */
88     protected static final String JavaDoc NAMESPACES =
89     Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
90
91     /** Feature id: validation. */
92     protected static final String JavaDoc VALIDATION_FEATURE =
93     Constants.SAX_FEATURE_PREFIX+Constants.VALIDATION_FEATURE;
94
95     /** XML Schema validation */
96     protected static final String JavaDoc XMLSCHEMA =
97     Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
98     
99     /** XML Schema full checking */
100     protected static final String JavaDoc XMLSCHEMA_FULL_CHECKING =
101     Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
102
103     /** Dynamic validation */
104     protected static final String JavaDoc DYNAMIC_VALIDATION =
105     Constants.XERCES_FEATURE_PREFIX + Constants.DYNAMIC_VALIDATION_FEATURE;
106
107     /** Feature identifier: expose schema normalized value */
108     protected static final String JavaDoc NORMALIZE_DATA =
109     Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;
110
111     /** Feature identifier: disallow docType Decls. */
112     protected static final String JavaDoc DISALLOW_DOCTYPE_DECL_FEATURE =
113         Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
114
115     // internal properties
116
protected static final String JavaDoc SYMBOL_TABLE =
117     Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
118
119     protected static final String JavaDoc PSVI_AUGMENT =
120     Constants.XERCES_FEATURE_PREFIX +Constants.SCHEMA_AUGMENT_PSVI;
121
122
123     //
124
// Data
125
//
126

127     /** Include namespace declaration attributes in the document. **/
128     protected boolean fNamespaceDeclarations = true;
129     
130     // REVISIT: this value should be null by default and should be set during creation of
131
// LSParser
132
protected String JavaDoc fSchemaType = null;
133
134     protected boolean fBusy = false;
135     
136     private boolean abortNow = false;
137     
138     private Thread JavaDoc currentThread;
139
140     protected final static boolean DEBUG = false;
141
142     private Vector JavaDoc fSchemaLocations = new Vector JavaDoc ();
143     private String JavaDoc fSchemaLocation = null;
144     private DOMStringList JavaDoc fRecognizedParameters;
145     
146     private AbortHandler abortHandler = new AbortHandler();
147
148     //
149
// Constructors
150
//
151

152     /**
153      * Constructs a DOM Builder using the standard parser configuration.
154      */

155     public DOMParserImpl (String JavaDoc configuration, String JavaDoc schemaType) {
156         this (
157         (XMLParserConfiguration) ObjectFactory.createObject (
158         "org.apache.xerces.xni.parser.XMLParserConfiguration",
159         configuration));
160         if (schemaType != null) {
161             if (schemaType.equals (Constants.NS_DTD)) {
162                 //Schema validation is false by default and hence there is no
163
//need to set it to false here. Also, schema validation is
164
//not a recognized feature for DTDConfiguration's and so
165
//setting this feature here would result in a Configuration
166
//Exception.
167
fConfiguration.setProperty (
168                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
169                 Constants.NS_DTD);
170                 fSchemaType = Constants.NS_DTD;
171             }
172             else if (schemaType.equals (Constants.NS_XMLSCHEMA)) {
173                 // XML Schem validation
174
fConfiguration.setProperty (
175                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
176                 Constants.NS_XMLSCHEMA);
177             }
178         }
179
180     }
181
182     /**
183      * Constructs a DOM Builder using the specified parser configuration.
184      */

185     public DOMParserImpl (XMLParserConfiguration config) {
186         super (config);
187
188         // add recognized features
189
final String JavaDoc[] domRecognizedFeatures = {
190             Constants.DOM_CANONICAL_FORM,
191             Constants.DOM_CDATA_SECTIONS,
192             Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING,
193             Constants.DOM_INFOSET,
194             Constants.DOM_NAMESPACE_DECLARATIONS,
195             Constants.DOM_SPLIT_CDATA,
196             Constants.DOM_SUPPORTED_MEDIATYPES_ONLY,
197             Constants.DOM_CERTIFIED,
198             Constants.DOM_WELLFORMED,
199             Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS,
200         };
201
202         fConfiguration.addRecognizedFeatures (domRecognizedFeatures);
203
204         // turn off deferred DOM
205
fConfiguration.setFeature (DEFER_NODE_EXPANSION, false);
206
207         // Set values so that the value of the
208
// infoset parameter is true (its default value).
209
//
210
// true: namespace-declarations, well-formed,
211
// element-content-whitespace, comments, namespaces
212
//
213
// false: validate-if-schema, entities,
214
// datatype-normalization, cdata-sections
215

216         fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
217         fConfiguration.setFeature(Constants.DOM_WELLFORMED, true);
218         fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
219         fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
220         fConfiguration.setFeature(NAMESPACES, true);
221         
222         fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
223         fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
224         fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
225
226         // set other default values
227
fConfiguration.setFeature (Constants.DOM_CANONICAL_FORM, false);
228         fConfiguration.setFeature (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING, true);
229         fConfiguration.setFeature (Constants.DOM_SPLIT_CDATA, true);
230         fConfiguration.setFeature (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY, false);
231         fConfiguration.setFeature (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS, true);
232
233         // REVISIT: by default Xerces assumes that input is certified.
234
// default is different from the one specified in the DOM spec
235
fConfiguration.setFeature (Constants.DOM_CERTIFIED, true);
236
237         // Xerces datatype-normalization feature is on by default
238
// This is a recognized feature only for XML Schemas. If the
239
// configuration doesn't support this feature, ignore it.
240
try {
241             fConfiguration.setFeature ( NORMALIZE_DATA, false );
242         }
243         catch (XMLConfigurationException exc) {}
244     
245     } // <init>(XMLParserConfiguration)
246

247     /**
248      * Constructs a DOM Builder using the specified symbol table.
249      */

250     public DOMParserImpl (SymbolTable symbolTable) {
251         this (
252         (XMLParserConfiguration) ObjectFactory.createObject (
253         "org.apache.xerces.xni.parser.XMLParserConfiguration",
254         "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"));
255         fConfiguration.setProperty (
256         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
257         symbolTable);
258     } // <init>(SymbolTable)
259

260
261     /**
262      * Constructs a DOM Builder using the specified symbol table and
263      * grammar pool.
264      */

265     public DOMParserImpl (SymbolTable symbolTable, XMLGrammarPool grammarPool) {
266         this (
267         (XMLParserConfiguration) ObjectFactory.createObject (
268         "org.apache.xerces.xni.parser.XMLParserConfiguration",
269         "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"));
270         fConfiguration.setProperty (
271         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
272         symbolTable);
273         fConfiguration.setProperty (
274         Constants.XERCES_PROPERTY_PREFIX
275         + Constants.XMLGRAMMAR_POOL_PROPERTY,
276         grammarPool);
277     }
278
279     /**
280      * Resets the parser state.
281      *
282      * @throws SAXException Thrown on initialization error.
283      */

284     public void reset () {
285         super.reset ();
286         
287         // get state of namespace-declarations parameter.
288
fNamespaceDeclarations =
289             fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
290                 
291         // DOM Filter
292
if (fSkippedElemStack!=null) {
293             fSkippedElemStack.removeAllElements ();
294         }
295         fSchemaLocations.clear ();
296         fRejectedElement.clear ();
297         fFilterReject = false;
298         fSchemaType = null;
299
300     } // reset()
301

302     //
303
// DOMParser methods
304
//
305

306     public DOMConfiguration JavaDoc getDomConfig (){
307         return this;
308     }
309
310
311     /**
312      * When the application provides a filter, the parser will call out to
313      * the filter at the completion of the construction of each
314      * <code>Element</code> node. The filter implementation can choose to
315      * remove the element from the document being constructed (unless the
316      * element is the document element) or to terminate the parse early. If
317      * the document is being validated when it's loaded the validation
318      * happens before the filter is called.
319      */

320     public LSParserFilter JavaDoc getFilter () {
321         return fDOMFilter;
322     }
323
324     /**
325      * When the application provides a filter, the parser will call out to
326      * the filter at the completion of the construction of each
327      * <code>Element</code> node. The filter implementation can choose to
328      * remove the element from the document being constructed (unless the
329      * element is the document element) or to terminate the parse early. If
330      * the document is being validated when it's loaded the validation
331      * happens before the filter is called.
332      */

333     public void setFilter (LSParserFilter JavaDoc filter) {
334         fDOMFilter = filter;
335         if (fSkippedElemStack == null) {
336             fSkippedElemStack = new Stack JavaDoc ();
337         }
338     }
339
340     /**
341      * Set parameters and properties
342      */

343     public void setParameter (String JavaDoc name, Object JavaDoc value) throws DOMException JavaDoc {
344         // set features
345

346         if(value instanceof Boolean JavaDoc){
347             boolean state = ((Boolean JavaDoc)value).booleanValue ();
348             try {
349                 if (name.equalsIgnoreCase (Constants.DOM_COMMENTS)) {
350                     fConfiguration.setFeature (INCLUDE_COMMENTS_FEATURE, state);
351                 }
352                 else if (name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)) {
353                     fConfiguration.setFeature (NORMALIZE_DATA, state);
354                 }
355                 else if (name.equalsIgnoreCase (Constants.DOM_ENTITIES)) {
356                     fConfiguration.setFeature (CREATE_ENTITY_REF_NODES, state);
357                 }
358                 else if (name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)) {
359                     fConfiguration.setFeature (DISALLOW_DOCTYPE_DECL_FEATURE, state);
360                 }
361                 else if (name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
362                 || name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
363                 || name.equalsIgnoreCase (Constants.DOM_CHECK_CHAR_NORMALIZATION)
364                 || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM)) {
365                     if (state) { // true is not supported
366
String JavaDoc msg =
367                         DOMMessageFormatter.formatMessage (
368                         DOMMessageFormatter.DOM_DOMAIN,
369                         "FEATURE_NOT_SUPPORTED",
370                         new Object JavaDoc[] { name });
371                         throw new DOMException JavaDoc (DOMException.NOT_SUPPORTED_ERR, msg);
372                     }
373                     // setting those features to false is no-op
374
}
375                 else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACES)) {
376                     fConfiguration.setFeature (NAMESPACES, state);
377                 }
378                 else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
379                     // Setting false has no effect.
380
if (state) {
381                         // true: namespaces, namespace-declarations,
382
// comments, element-content-whitespace
383
fConfiguration.setFeature(NAMESPACES, true);
384                         fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
385                         fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
386                         fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
387
388                         // false: validate-if-schema, entities,
389
// datatype-normalization, cdata-sections
390
fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
391                         fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
392                         fConfiguration.setFeature(NORMALIZE_DATA, false);
393                         fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
394                     }
395                 }
396                 else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
397                     fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, state);
398                 }
399                 else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)) {
400                     fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, state);
401                 }
402                 else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
403                 || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
404                     if (!state) { // false is not supported
405
String JavaDoc msg =
406                         DOMMessageFormatter.formatMessage (
407                         DOMMessageFormatter.DOM_DOMAIN,
408                         "FEATURE_NOT_SUPPORTED",
409                         new Object JavaDoc[] { name });
410                         throw new DOMException JavaDoc (DOMException.NOT_SUPPORTED_ERR, msg);
411                     }
412                     // setting these features to true is no-op
413
// REVISIT: implement "namespace-declaration" feature
414
}
415                 else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE)) {
416                     fConfiguration.setFeature (VALIDATION_FEATURE, state);
417                     if (fSchemaType != Constants.NS_DTD) {
418                         fConfiguration.setFeature (XMLSCHEMA, state);
419                         fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, state);
420                     }
421                     if (state){
422                         fConfiguration.setFeature (DYNAMIC_VALIDATION, false);
423                     }
424                 }
425                 else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)) {
426                     fConfiguration.setFeature (DYNAMIC_VALIDATION, state);
427                     // Note: validation and dynamic validation are mutually exclusive
428
if (state){
429                         fConfiguration.setFeature (VALIDATION_FEATURE, false);
430                     }
431                 }
432                 else if (name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
433                     fConfiguration.setFeature (INCLUDE_IGNORABLE_WHITESPACE, state);
434                 }
435                 else if (name.equalsIgnoreCase (Constants.DOM_PSVI)){
436                     //XSModel - turn on PSVI augmentation
437
fConfiguration.setFeature (PSVI_AUGMENT, true);
438                     fConfiguration.setProperty (DOCUMENT_CLASS_NAME,
439                     "org.apache.xerces.dom.PSVIDocumentImpl");
440                 }
441                 else {
442                     // Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING feature,
443
// Constants.DOM_SPLIT_CDATA feature,
444
// or any Xerces feature
445
fConfiguration.setFeature (name.toLowerCase(Locale.ENGLISH), state);
446                 }
447
448             }
449             catch (XMLConfigurationException e) {
450                 String JavaDoc msg =
451                 DOMMessageFormatter.formatMessage (
452                 DOMMessageFormatter.DOM_DOMAIN,
453                 "FEATURE_NOT_FOUND",
454                 new Object JavaDoc[] { name });
455                 throw new DOMException JavaDoc (DOMException.NOT_FOUND_ERR, msg);
456             }
457         }
458         else { // set properties
459
if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
460                 if (value instanceof DOMErrorHandler JavaDoc || value == null) {
461                     try {
462                         fErrorHandler = new DOMErrorHandlerWrapper ((DOMErrorHandler JavaDoc) value);
463                         fConfiguration.setProperty (ERROR_HANDLER, fErrorHandler);
464                     }
465                     catch (XMLConfigurationException e) {}
466                 }
467                 else {
468                     // REVISIT: type mismatch
469
String JavaDoc msg =
470                     DOMMessageFormatter.formatMessage (
471                     DOMMessageFormatter.DOM_DOMAIN,
472                     "TYPE_MISMATCH_ERR",
473                     new Object JavaDoc[] { name });
474                     throw new DOMException JavaDoc (DOMException.TYPE_MISMATCH_ERR, msg);
475                 }
476
477             }
478             else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
479                 if (value instanceof LSResourceResolver JavaDoc || value == null) {
480                     try {
481                         fConfiguration.setProperty (ENTITY_RESOLVER, new DOMEntityResolverWrapper ((LSResourceResolver JavaDoc) value));
482                     }
483                     catch (XMLConfigurationException e) {}
484                 }
485                 else {
486                     // REVISIT: type mismatch
487
String JavaDoc msg =
488                     DOMMessageFormatter.formatMessage (
489                     DOMMessageFormatter.DOM_DOMAIN,
490                     "TYPE_MISMATCH_ERR",
491                     new Object JavaDoc[] { name });
492                     throw new DOMException JavaDoc (DOMException.TYPE_MISMATCH_ERR, msg);
493                 }
494
495             }
496             else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
497                 if (value instanceof String JavaDoc || value == null) {
498                     try {
499                         if (value == null) {
500                             fSchemaLocation = null;
501                             fConfiguration.setProperty (
502                                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
503                                 null);
504                         }
505                         else {
506                             fSchemaLocation = (String JavaDoc)value;
507                             // map DOM schema-location to JAXP schemaSource property
508
// tokenize location string
509
StringTokenizer JavaDoc t = new StringTokenizer JavaDoc (fSchemaLocation, " \n\t\r");
510                             if (t.hasMoreTokens ()){
511                                 fSchemaLocations.clear ();
512                                 fSchemaLocations.add (t.nextToken ());
513                                 while (t.hasMoreTokens ()) {
514                                     fSchemaLocations.add (t.nextToken ());
515                                 }
516                                 fConfiguration.setProperty (
517                                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
518                                 fSchemaLocations.toArray ());
519                             }
520                             else {
521                                 fConfiguration.setProperty (
522                                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
523                                 value);
524                             }
525                         }
526                     }
527                     catch (XMLConfigurationException e) {}
528                 }
529                 else {
530                     // REVISIT: type mismatch
531
String JavaDoc msg =
532                     DOMMessageFormatter.formatMessage (
533                     DOMMessageFormatter.DOM_DOMAIN,
534                     "TYPE_MISMATCH_ERR",
535                     new Object JavaDoc[] { name });
536                     throw new DOMException JavaDoc (DOMException.TYPE_MISMATCH_ERR, msg);
537                 }
538
539             }
540             else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
541                 if (value instanceof String JavaDoc || value == null) {
542                     try {
543                         if (value == null) {
544                             // turn off schema features
545
fConfiguration.setFeature (XMLSCHEMA, false);
546                             fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, false);
547                             // map to JAXP schemaLanguage
548
fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
549                             + Constants.SCHEMA_LANGUAGE,
550                             null);
551                             fSchemaType = null;
552                         }
553                         else if (value.equals (Constants.NS_XMLSCHEMA)) {
554                             // turn on schema features
555
fConfiguration.setFeature (XMLSCHEMA, true);
556                             fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, true);
557                             // map to JAXP schemaLanguage
558
fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
559                             + Constants.SCHEMA_LANGUAGE,
560                             Constants.NS_XMLSCHEMA);
561                             fSchemaType = Constants.NS_XMLSCHEMA;
562                         }
563                         else if (value.equals (Constants.NS_DTD)) {
564                             // turn off schema features
565
fConfiguration.setFeature (XMLSCHEMA, false);
566                             fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, false);
567                             // map to JAXP schemaLanguage
568
fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
569                             + Constants.SCHEMA_LANGUAGE,
570                             Constants.NS_DTD);
571                             fSchemaType = Constants.NS_DTD;
572                         }
573                     }
574                     catch (XMLConfigurationException e) {}
575                 }
576                 else {
577                     String JavaDoc msg =
578                     DOMMessageFormatter.formatMessage (
579                     DOMMessageFormatter.DOM_DOMAIN,
580                     "TYPE_MISMATCH_ERR",
581                     new Object JavaDoc[] { name });
582                     throw new DOMException JavaDoc (DOMException.TYPE_MISMATCH_ERR, msg);
583                 }
584
585             }
586             else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)) {
587                 fConfiguration.setProperty (DOCUMENT_CLASS_NAME, value);
588             }
589             else {
590                 // REVISIT: check if this is a boolean parameter -- type mismatch should be thrown.
591
//parameter is not recognized
592
String JavaDoc msg =
593                 DOMMessageFormatter.formatMessage (
594                 DOMMessageFormatter.DOM_DOMAIN,
595                 "FEATURE_NOT_FOUND",
596                 new Object JavaDoc[] { name });
597                 throw new DOMException JavaDoc (DOMException.NOT_FOUND_ERR, msg);
598             }
599         }
600     }
601
602     /**
603      * Look up the value of a feature or a property.
604      */

605     public Object JavaDoc getParameter (String JavaDoc name) throws DOMException JavaDoc {
606         if (name.equalsIgnoreCase (Constants.DOM_COMMENTS)) {
607             return (fConfiguration.getFeature (INCLUDE_COMMENTS_FEATURE))
608             ? Boolean.TRUE
609             : Boolean.FALSE;
610         }
611         else if (name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)) {
612             return (fConfiguration.getFeature (NORMALIZE_DATA))
613             ? Boolean.TRUE
614             : Boolean.FALSE;
615         }
616         else if (name.equalsIgnoreCase (Constants.DOM_ENTITIES)) {
617             return (fConfiguration.getFeature (CREATE_ENTITY_REF_NODES))
618             ? Boolean.TRUE
619             : Boolean.FALSE;
620         }
621         else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACES)) {
622             return (fConfiguration.getFeature (NAMESPACES))
623             ? Boolean.TRUE
624             : Boolean.FALSE;
625         }
626         else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE)) {
627             return (fConfiguration.getFeature (VALIDATION_FEATURE))
628             ? Boolean.TRUE
629             : Boolean.FALSE;
630         }
631         else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)) {
632             return (fConfiguration.getFeature (DYNAMIC_VALIDATION))
633             ? Boolean.TRUE
634             : Boolean.FALSE;
635         }
636         else if (name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
637             return (fConfiguration.getFeature (INCLUDE_IGNORABLE_WHITESPACE))
638             ? Boolean.TRUE
639             : Boolean.FALSE;
640         }
641         else if (name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)) {
642             return (fConfiguration.getFeature (DISALLOW_DOCTYPE_DECL_FEATURE))
643             ? Boolean.TRUE
644             : Boolean.FALSE;
645         }
646         else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
647             // REVISIT: This is somewhat expensive to compute
648
// but it's possible that the user has a reference
649
// to the configuration and is changing the values
650
// of these features directly on it.
651
boolean infoset = fConfiguration.getFeature(NAMESPACES) &&
652                 fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS) &&
653                 fConfiguration.getFeature(INCLUDE_COMMENTS_FEATURE) &&
654                 fConfiguration.getFeature(INCLUDE_IGNORABLE_WHITESPACE) &&
655                 !fConfiguration.getFeature(DYNAMIC_VALIDATION) &&
656                 !fConfiguration.getFeature(CREATE_ENTITY_REF_NODES) &&
657                 !fConfiguration.getFeature(NORMALIZE_DATA) &&
658                 !fConfiguration.getFeature(CREATE_CDATA_NODES_FEATURE);
659             return (infoset) ? Boolean.TRUE : Boolean.FALSE;
660         }
661         else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
662             return (fConfiguration.getFeature(CREATE_CDATA_NODES_FEATURE))
663                 ? Boolean.TRUE : Boolean.FALSE;
664         }
665         else if (name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION ) ||
666                  name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)){
667             return Boolean.FALSE;
668         }
669         else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
670         || name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
671         || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)
672         || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM)
673         || name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
674         || name.equalsIgnoreCase (Constants.DOM_SPLIT_CDATA)
675         || name.equalsIgnoreCase (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)) {
676             return (fConfiguration.getFeature (name.toLowerCase(Locale.ENGLISH)))
677             ? Boolean.TRUE
678             : Boolean.FALSE;
679         }
680         else if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
681             if (fErrorHandler != null) {
682                 return fErrorHandler.getErrorHandler ();
683             }
684             return null;
685         }
686         else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
687             try {
688                 XMLEntityResolver entityResolver =
689                 (XMLEntityResolver) fConfiguration.getProperty (ENTITY_RESOLVER);
690                 if (entityResolver != null
691                 && entityResolver instanceof DOMEntityResolverWrapper) {
692                     return ((DOMEntityResolverWrapper) entityResolver).getEntityResolver ();
693                 }
694                 return null;
695             }
696             catch (XMLConfigurationException e) {}
697         }
698         else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
699             return fConfiguration.getProperty (
700             Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
701         }
702         else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
703             return fSchemaLocation;
704         }
705         else if (name.equalsIgnoreCase (SYMBOL_TABLE)){
706             return fConfiguration.getProperty (SYMBOL_TABLE);
707         }
708         else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)) {
709             return fConfiguration.getProperty (DOCUMENT_CLASS_NAME);
710         }
711         else {
712             String JavaDoc msg =
713             DOMMessageFormatter.formatMessage (
714             DOMMessageFormatter.DOM_DOMAIN,
715             "FEATURE_NOT_FOUND",
716             new Object JavaDoc[] { name });
717             throw new DOMException JavaDoc (DOMException.NOT_FOUND_ERR, msg);
718         }
719         return null;
720     }
721
722     public boolean canSetParameter (String JavaDoc name, Object JavaDoc value) {
723         if (value == null){
724             return true;
725         }
726         
727         if(value instanceof Boolean JavaDoc){
728             boolean state = ((Boolean JavaDoc)value).booleanValue ();
729             if ( name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
730             || name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
731             || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION )
732             || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM) ) {
733                 // true is not supported
734
return (state) ? false : true;
735             }
736             else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
737             || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
738                 // false is not supported
739
return (state) ? true : false;
740             }
741             else if (name.equalsIgnoreCase (Constants.DOM_CDATA_SECTIONS)
742             || name.equalsIgnoreCase (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)
743             || name.equalsIgnoreCase (Constants.DOM_COMMENTS)
744             || name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)
745             || name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)
746             || name.equalsIgnoreCase (Constants.DOM_ENTITIES)
747             || name.equalsIgnoreCase (Constants.DOM_INFOSET)
748             || name.equalsIgnoreCase (Constants.DOM_NAMESPACES)
749             || name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)
750             || name.equalsIgnoreCase (Constants.DOM_VALIDATE)
751             || name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)
752             || name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
753             || name.equalsIgnoreCase (Constants.DOM_XMLDECL)) {
754                 return true;
755             }
756
757             // Recognize Xerces features.
758
try {
759                 fConfiguration.getFeature(name.toLowerCase(Locale.ENGLISH));
760                 return true;
761             }
762             catch (XMLConfigurationException e) {
763                 return false;
764             }
765         }
766         else { // check properties
767
if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
768                 if (value instanceof DOMErrorHandler JavaDoc || value == null) {
769                     return true;
770                 }
771                 return false;
772             }
773             else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
774                 if (value instanceof LSResourceResolver JavaDoc || value == null) {
775                     return true;
776                 }
777                 return false;
778             }
779             else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
780                 if ((value instanceof String JavaDoc
781                 && (value.equals (Constants.NS_XMLSCHEMA)
782                 || value.equals (Constants.NS_DTD))) || value == null) {
783                     return true;
784                 }
785                 return false;
786             }
787             else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
788                 if (value instanceof String JavaDoc || value == null)
789                     return true;
790                 return false;
791             }
792             else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)){
793                 return true;
794             }
795             return false;
796         }
797     }
798
799     /**
800      * DOM Level 3 CR - Experimental.
801      *
802      * The list of the parameters supported by this
803      * <code>DOMConfiguration</code> object and for which at least one value
804      * can be set by the application. Note that this list can also contain
805      * parameter names defined outside this specification.
806      */

807     public DOMStringList JavaDoc getParameterNames () {
808         if (fRecognizedParameters == null){
809             Vector JavaDoc parameters = new Vector JavaDoc();
810             
811             // REVISIT: add Xerces recognized properties/features
812
parameters.add(Constants.DOM_NAMESPACES);
813             parameters.add(Constants.DOM_CDATA_SECTIONS);
814             parameters.add(Constants.DOM_CANONICAL_FORM);
815             parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
816             parameters.add(Constants.DOM_SPLIT_CDATA);
817             
818             parameters.add(Constants.DOM_ENTITIES);
819             parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
820             parameters.add(Constants.DOM_VALIDATE);
821             parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
822             
823             parameters.add(Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING);
824             parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
825             parameters.add(Constants.DOM_SUPPORTED_MEDIATYPES_ONLY);
826             parameters.add(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS);
827             
828             parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
829             parameters.add(Constants.DOM_WELLFORMED);
830             parameters.add(Constants.DOM_INFOSET);
831             parameters.add(Constants.DOM_DISALLOW_DOCTYPE);
832             parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
833             parameters.add(Constants.DOM_COMMENTS);
834             
835             parameters.add(Constants.DOM_ERROR_HANDLER);
836             parameters.add(Constants.DOM_RESOURCE_RESOLVER);
837             parameters.add(Constants.DOM_SCHEMA_LOCATION);
838             parameters.add(Constants.DOM_SCHEMA_TYPE);
839             
840             fRecognizedParameters = new DOMStringListImpl(parameters);
841             
842         }
843         
844         return fRecognizedParameters;
845     }
846
847     /**
848      * Parse an XML document from a location identified by an URI reference.
849      * If the URI contains a fragment identifier (see section 4.1 in ), the
850      * behavior is not defined by this specification.
851      *
852      */

853     public Document JavaDoc parseURI (String JavaDoc uri) throws LSException JavaDoc {
854
855         //If DOMParser insstance is already busy parsing another document when this
856
// method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
857
if ( fBusy ) {
858             String JavaDoc msg = DOMMessageFormatter.formatMessage (
859             DOMMessageFormatter.DOM_DOMAIN,
860             "INVALID_STATE_ERR",null);
861             throw new DOMException JavaDoc ( DOMException.INVALID_STATE_ERR,msg);
862         }
863
864         XMLInputSource source = new XMLInputSource (null, uri, null);
865         try {
866             currentThread = Thread.currentThread();
867             fBusy = true;
868             parse (source);
869             fBusy = false;
870             if (abortNow && currentThread.isInterrupted()) {
871                 //reset interrupt state
872
abortNow = false;
873                 Thread.interrupted();
874             }
875         } catch (Exception JavaDoc e){
876             fBusy = false;
877             if (abortNow && currentThread.isInterrupted()) {
878                 Thread.interrupted();
879             }
880             if (abortNow) {
881                 abortNow = false;
882                 restoreHandlers();
883                 return null;
884             }
885             // Consume this exception if the user
886
// issued an interrupt or an abort.
887
if (e != abort) {
888                 if (!(e instanceof XMLParseException) && fErrorHandler != null) {
889                     DOMErrorImpl error = new DOMErrorImpl ();
890                     error.fException = e;
891                     error.fMessage = e.getMessage ();
892                     error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
893                     fErrorHandler.getErrorHandler ().handleError (error);
894                 }
895                 if (DEBUG) {
896                     e.printStackTrace ();
897                 }
898                 throw new LSException JavaDoc(LSException.PARSE_ERR, e.getMessage());
899             }
900         }
901         return getDocument ();
902     }
903
904     /**
905      * Parse an XML document from a resource identified by an
906      * <code>LSInput</code>.
907      *
908      */

909     public Document JavaDoc parse (LSInput JavaDoc is) throws LSException JavaDoc {
910
911         // need to wrap the LSInput with an XMLInputSource
912
XMLInputSource xmlInputSource = dom2xmlInputSource (is);
913         if ( fBusy ) {
914             String JavaDoc msg = DOMMessageFormatter.formatMessage (
915             DOMMessageFormatter.DOM_DOMAIN,
916             "INVALID_STATE_ERR",null);
917             throw new DOMException JavaDoc ( DOMException.INVALID_STATE_ERR,msg);
918         }
919
920         try {
921             currentThread = Thread.currentThread();
922             fBusy = true;
923             parse (xmlInputSource);
924             fBusy = false;
925             if (abortNow && currentThread.isInterrupted()) {
926                 //reset interrupt state
927
abortNow = false;
928                 Thread.interrupted();
929             }
930         } catch (Exception JavaDoc e) {
931             fBusy = false;
932             if (abortNow && currentThread.isInterrupted()) {
933                 Thread.interrupted();
934             }
935             if (abortNow) {
936                 abortNow = false;
937                 restoreHandlers();
938                 return null;
939             }
940             // Consume this exception if the user
941
// issued an interrupt or an abort.
942
if (e != abort) {
943                 if (!(e instanceof XMLParseException) && fErrorHandler != null) {
944                    DOMErrorImpl error = new DOMErrorImpl ();
945                    error.fException = e;
946                    error.fMessage = e.getMessage ();
947                    error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
948                    fErrorHandler.getErrorHandler().handleError (error);
949                 }
950                 if (DEBUG) {
951                    e.printStackTrace ();
952                 }
953                 throw new LSException JavaDoc(LSException.PARSE_ERR, e.getMessage());
954             }
955         }
956         return getDocument ();
957     }
958
959
960     private void restoreHandlers() {
961         fConfiguration.setDocumentHandler(this);
962         fConfiguration.setDTDHandler(this);
963         fConfiguration.setDTDContentModelHandler(this);
964     }
965
966     /**
967      * Parse an XML document or fragment from a resource identified by an
968      * <code>LSInput</code> and insert the content into an existing
969      * document at the position epcified with the <code>contextNode</code>
970      * and <code>action</code> arguments. When parsing the input stream the
971      * context node is used for resolving unbound namespace prefixes.
972      *
973      * @param is The <code>LSInput</code> from which the source
974      * document is to be read.
975      * @param cnode The <code>Node</code> that is used as the context for
976      * the data that is being parsed.
977      * @param action This parameter describes which action should be taken
978      * between the new set of node being inserted and the existing
979      * children of the context node. The set of possible actions is
980      * defined above.
981      * @exception DOMException
982      * HIERARCHY_REQUEST_ERR: Thrown if this action results in an invalid
983      * hierarchy (i.e. a Document with more than one document element).
984      */

985     public Node JavaDoc parseWithContext (LSInput JavaDoc is, Node JavaDoc cnode,
986     short action) throws DOMException JavaDoc, LSException JavaDoc {
987         // REVISIT: need to implement.
988
throw new DOMException JavaDoc (DOMException.NOT_SUPPORTED_ERR, "Not supported");
989     }
990
991
992     /**
993      * NON-DOM: convert LSInput to XNIInputSource
994      *
995      * @param is
996      * @return
997      */

998     XMLInputSource dom2xmlInputSource (LSInput JavaDoc is) {
999         // need to wrap the LSInput with an XMLInputSource
1000
XMLInputSource xis = null;
1001        // check whether there is a Reader
1002
// according to DOM, we need to treat such reader as "UTF-16".
1003
if (is.getCharacterStream () != null) {
1004            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
1005            is.getBaseURI (), is.getCharacterStream (),
1006            "UTF-16");
1007        }
1008        // check whether there is an InputStream
1009
else if (is.getByteStream () != null) {
1010            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
1011            is.getBaseURI (), is.getByteStream (),
1012            is.getEncoding ());
1013        }
1014        // if there is a string data, use a StringReader
1015
// according to DOM, we need to treat such data as "UTF-16".
1016
else if (is.getStringData () != null && is.getStringData().length() > 0) {
1017            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
1018            is.getBaseURI (), new StringReader JavaDoc (is.getStringData ()),
1019            "UTF-16");
1020        }
1021        // otherwise, just use the public/system/base Ids
1022
else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
1023            (is.getPublicId() != null && is.getPublicId().length() > 0)) {
1024            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
1025            is.getBaseURI ());
1026        }
1027        else {
1028            // all inputs are null
1029
if (fErrorHandler != null) {
1030                DOMErrorImpl error = new DOMErrorImpl();
1031                error.fType = "no-input-specified";
1032                error.fMessage = "no-input-specified";
1033                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
1034                fErrorHandler.getErrorHandler().handleError(error);
1035            }
1036            throw new LSException JavaDoc(LSException.PARSE_ERR, "no-input-specified");
1037        }
1038        return xis;
1039    }
1040
1041    /**
1042     * @see org.w3c.dom.ls.LSParser#getAsync()
1043     */

1044    public boolean getAsync () {
1045        return false;
1046    }
1047
1048    /**
1049     * @see org.w3c.dom.ls.LSParser#getBusy()
1050     */

1051    public boolean getBusy () {
1052        return fBusy;
1053    }
1054
1055    /**
1056     * @see org.w3c.dom.ls.DOMParser#abort()
1057     */

1058    public void abort () {
1059        // If parse operation is in progress then reset it
1060
if ( fBusy ) {
1061            fBusy = false;
1062            if(currentThread != null) {
1063                abortNow = true;
1064                
1065                fConfiguration.setDocumentHandler(abortHandler);
1066                fConfiguration.setDTDHandler(abortHandler);
1067                fConfiguration.setDTDContentModelHandler(abortHandler);
1068                
1069                if(currentThread == Thread.currentThread())
1070                    throw abort;
1071                
1072                currentThread.interrupt();
1073            }
1074        }
1075        return; // If not busy then this is noop
1076
}
1077
1078    /**
1079     * The start of an element. If the document specifies the start element
1080     * by using an empty tag, then the startElement method will immediately
1081     * be followed by the endElement method, with no intervening methods.
1082     * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
1083     *
1084     * @param element The name of the element.
1085     * @param attributes The element attributes.
1086     * @param augs Additional information that may include infoset augmentations
1087     *
1088     * @throws XNIException Thrown by handler to signal an error.
1089     */

1090    public void startElement (QName element, XMLAttributes attributes, Augmentations augs) {
1091        // namespace declarations parameter has no effect if namespaces is false.
1092
if (!fNamespaceDeclarations && fNamespaceAware) {
1093            int len = attributes.getLength();
1094            for (int i = len - 1; i >= 0; --i) {
1095                if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
1096                    XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
1097                    attributes.removeAttributeAt(i);
1098                }
1099            }
1100        }
1101        super.startElement(element, attributes, augs);
1102    }
1103    
1104    private class AbortHandler implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
1105
1106        private XMLDocumentSource documentSource;
1107        private XMLDTDContentModelSource dtdContentSource;
1108        private XMLDTDSource dtdSource;
1109
1110        public void startDocument(XMLLocator locator, String JavaDoc encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
1111            throw abort;
1112        }
1113
1114        public void xmlDecl(String JavaDoc version, String JavaDoc encoding, String JavaDoc standalone, Augmentations augs) throws XNIException {
1115            throw abort;
1116        }
1117
1118        public void doctypeDecl(String JavaDoc rootElement, String JavaDoc publicId, String JavaDoc systemId, Augmentations augs) throws XNIException {
1119            throw abort;
1120        }
1121
1122        public void comment(XMLString text, Augmentations augs) throws XNIException {
1123            throw abort;
1124        }
1125
1126        public void processingInstruction(String JavaDoc target, XMLString data, Augmentations augs) throws XNIException {
1127            throw abort;
1128        }
1129
1130        public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
1131            throw abort;
1132        }
1133
1134        public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
1135            throw abort;
1136        }
1137
1138        public void startGeneralEntity(String JavaDoc name, XMLResourceIdentifier identifier, String JavaDoc encoding, Augmentations augs) throws XNIException {
1139            throw abort;
1140        }
1141
1142        public void textDecl(String JavaDoc version, String JavaDoc encoding, Augmentations augs) throws XNIException {
1143            throw abort;
1144        }
1145
1146        public void endGeneralEntity(String JavaDoc name, Augmentations augs) throws XNIException {
1147            throw abort;
1148        }
1149
1150        public void characters(XMLString text, Augmentations augs) throws XNIException {
1151            throw abort;
1152        }
1153
1154        public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
1155            throw abort;
1156        }
1157
1158        public void endElement(QName element, Augmentations augs) throws XNIException {
1159            throw abort;
1160        }
1161
1162        public void startCDATA(Augmentations augs) throws XNIException {
1163            throw abort;
1164        }
1165
1166        public void endCDATA(Augmentations augs) throws XNIException {
1167            throw abort;
1168        }
1169
1170        public void endDocument(Augmentations augs) throws XNIException {
1171            throw abort;
1172        }
1173
1174        public void setDocumentSource(XMLDocumentSource source) {
1175            documentSource = source;
1176        }
1177
1178        public XMLDocumentSource getDocumentSource() {
1179            return documentSource;
1180        }
1181
1182        public void startDTD(XMLLocator locator, Augmentations augmentations) throws XNIException {
1183            throw abort;
1184        }
1185
1186        public void startParameterEntity(String JavaDoc name, XMLResourceIdentifier identifier, String JavaDoc encoding, Augmentations augmentations) throws XNIException {
1187            throw abort;
1188        }
1189
1190        public void endParameterEntity(String JavaDoc name, Augmentations augmentations) throws XNIException {
1191            throw abort;
1192        }
1193
1194        public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1195            throw abort;
1196        }
1197
1198        public void endExternalSubset(Augmentations augmentations) throws XNIException {
1199            throw abort;
1200        }
1201
1202        public void elementDecl(String JavaDoc name, String JavaDoc contentModel, Augmentations augmentations) throws XNIException {
1203            throw abort;
1204        }
1205
1206        public void startAttlist(String JavaDoc elementName, Augmentations augmentations) throws XNIException {
1207            throw abort;
1208        }
1209
1210        public void attributeDecl(String JavaDoc elementName, String JavaDoc attributeName, String JavaDoc type, String JavaDoc[] enumeration, String JavaDoc defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augmentations) throws XNIException {
1211            throw abort;
1212        }
1213
1214        public void endAttlist(Augmentations augmentations) throws XNIException {
1215            throw abort;
1216        }
1217
1218        public void internalEntityDecl(String JavaDoc name, XMLString text, XMLString nonNormalizedText, Augmentations augmentations) throws XNIException {
1219            throw abort;
1220        }
1221
1222        public void externalEntityDecl(String JavaDoc name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1223            throw abort;
1224        }
1225
1226        public void unparsedEntityDecl(String JavaDoc name, XMLResourceIdentifier identifier, String JavaDoc notation, Augmentations augmentations) throws XNIException {
1227            throw abort;
1228        }
1229
1230        public void notationDecl(String JavaDoc name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1231            throw abort;
1232        }
1233
1234        public void startConditional(short type, Augmentations augmentations) throws XNIException {
1235            throw abort;
1236        }
1237
1238        public void ignoredCharacters(XMLString text, Augmentations augmentations) throws XNIException {
1239            throw abort;
1240        }
1241
1242        public void endConditional(Augmentations augmentations) throws XNIException {
1243            throw abort;
1244        }
1245
1246        public void endDTD(Augmentations augmentations) throws XNIException {
1247            throw abort;
1248        }
1249
1250        public void setDTDSource(XMLDTDSource source) {
1251            dtdSource = source;
1252        }
1253
1254        public XMLDTDSource getDTDSource() {
1255            return dtdSource;
1256        }
1257
1258        public void startContentModel(String JavaDoc elementName, Augmentations augmentations) throws XNIException {
1259            throw abort;
1260        }
1261
1262        public void any(Augmentations augmentations) throws XNIException {
1263            throw abort;
1264        }
1265
1266        public void empty(Augmentations augmentations) throws XNIException {
1267            throw abort;
1268        }
1269
1270        public void startGroup(Augmentations augmentations) throws XNIException {
1271            throw abort;
1272        }
1273
1274        public void pcdata(Augmentations augmentations) throws XNIException {
1275            throw abort;
1276        }
1277
1278        public void element(String JavaDoc elementName, Augmentations augmentations) throws XNIException {
1279            throw abort;
1280        }
1281
1282        public void separator(short separator, Augmentations augmentations) throws XNIException {
1283            throw abort;
1284        }
1285
1286        public void occurrence(short occurrence, Augmentations augmentations) throws XNIException {
1287            throw abort;
1288        }
1289
1290        public void endGroup(Augmentations augmentations) throws XNIException {
1291            throw abort;
1292        }
1293
1294        public void endContentModel(Augmentations augmentations) throws XNIException {
1295            throw abort;
1296        }
1297
1298        public void setDTDContentModelSource(XMLDTDContentModelSource source) {
1299            dtdContentSource = source;
1300        }
1301
1302        public XMLDTDContentModelSource getDTDContentModelSource() {
1303            return dtdContentSource;
1304        }
1305        
1306    }
1307    
1308} // class DOMParserImpl
1309
Popular Tags