KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > parsers > DOMParserImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2000-2004 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) 2001, 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
59 package com.sun.org.apache.xerces.internal.parsers;
60
61 import java.io.StringReader JavaDoc;
62 import java.util.Locale JavaDoc;
63 import java.util.Stack JavaDoc;
64 import java.util.StringTokenizer JavaDoc;
65 import java.util.Vector JavaDoc;
66 import java.util.Locale JavaDoc;
67
68 import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
69 import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
70 import com.sun.org.apache.xerces.internal.dom.DOMStringListImpl;
71 import org.w3c.dom.DOMError JavaDoc;
72 import com.sun.org.apache.xerces.internal.impl.Constants;
73 import com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper;
74 import com.sun.org.apache.xerces.internal.util.DOMErrorHandlerWrapper;
75 import com.sun.org.apache.xerces.internal.util.SymbolTable;
76 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
77 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
78 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
79 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
80 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
81 import org.w3c.dom.DOMConfiguration JavaDoc;
82 import org.w3c.dom.DOMErrorHandler JavaDoc;
83 import org.w3c.dom.DOMException JavaDoc;
84 import org.w3c.dom.Document JavaDoc;
85 import org.w3c.dom.DOMStringList JavaDoc;
86 import org.w3c.dom.Node JavaDoc;
87 import org.w3c.dom.ls.LSException JavaDoc;
88 import org.w3c.dom.ls.LSParser JavaDoc;
89 import org.w3c.dom.ls.LSParserFilter JavaDoc;
90 import org.w3c.dom.ls.LSResourceResolver JavaDoc;
91 import org.w3c.dom.ls.LSInput JavaDoc;
92
93
94 /**
95  * This is Xerces DOM Builder class. It uses the abstract DOM
96  * parser with a document scanner, a dtd scanner, and a validator, as
97  * well as a grammar pool.
98  *
99  * @author Pavani Mukthipudi, Sun Microsystems Inc.
100  * @author Elena Litani, IBM
101  * @author Rahul Srivastava, Sun Microsystems Inc.
102  * @version $Id: DOMParserImpl.java,v 1.25 2004/04/23 16:06:10 mrglavas Exp $
103  */

104 public class DOMParserImpl
105 extends AbstractDOMParser implements LSParser JavaDoc, DOMConfiguration JavaDoc {
106
107
108
109     // SAX & Xerces feature ids
110

111     /** Feature identifier: namespaces. */
112     protected static final String JavaDoc NAMESPACES =
113     Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
114
115     /** Feature id: validation. */
116     protected static final String JavaDoc VALIDATION_FEATURE =
117     Constants.SAX_FEATURE_PREFIX+Constants.VALIDATION_FEATURE;
118
119     /** XML Schema validation */
120     protected static final String JavaDoc XMLSCHEMA =
121     Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
122
123     /** Dynamic validation */
124     protected static final String JavaDoc DYNAMIC_VALIDATION =
125     Constants.XERCES_FEATURE_PREFIX + Constants.DYNAMIC_VALIDATION_FEATURE;
126
127     /** Feature identifier: expose schema normalized value */
128     protected static final String JavaDoc NORMALIZE_DATA =
129     Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;
130
131     /** Feature identifier: disallow docType Decls. */
132     protected static final String JavaDoc DISALLOW_DOCTYPE_DECL_FEATURE =
133         Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE;
134
135     // internal properties
136
protected static final String JavaDoc SYMBOL_TABLE =
137     Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
138
139     protected static final String JavaDoc PSVI_AUGMENT =
140     Constants.XERCES_FEATURE_PREFIX +Constants.SCHEMA_AUGMENT_PSVI;
141     Thread JavaDoc currentThread = null;
142
143     //
144
// Data
145
//
146

147
148     // REVISIT: this value should be null by default and should be set during creation of
149
// LSParser
150
protected String JavaDoc fSchemaType = null;
151
152     protected boolean fBusy = false;
153
154     protected final static boolean DEBUG = false;
155
156     private Vector JavaDoc fSchemaLocations = new Vector JavaDoc ();
157     private String JavaDoc fSchemaLocation = null;
158     private DOMStringList JavaDoc fRecognizedParameters;
159
160     private boolean abortNow = false;
161
162     //
163
// Constructors
164
//
165

166     /**
167      * Constructs a DOM Builder using the standard parser configuration.
168      */

169     public DOMParserImpl (String JavaDoc configuration, String JavaDoc schemaType) {
170         this (
171         (XMLParserConfiguration) ObjectFactory.createObject (
172         "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration",
173         configuration));
174         if (schemaType != null) {
175             if (schemaType.equals (Constants.NS_DTD)) {
176                 fConfiguration.setFeature (
177                 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE,
178                 false);
179                 fConfiguration.setProperty (
180                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
181                 Constants.NS_DTD);
182                 fSchemaType = Constants.NS_DTD;
183             }
184             else if (schemaType.equals (Constants.NS_XMLSCHEMA)) {
185                 // XML Schem validation
186
fConfiguration.setProperty (
187                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
188                 Constants.NS_XMLSCHEMA);
189             }
190         }
191
192     }
193
194     /**
195      * Constructs a DOM Builder using the specified parser configuration.
196      */

197     public DOMParserImpl (XMLParserConfiguration config) {
198         super (config);
199
200         // add recognized features
201
final String JavaDoc[] domRecognizedFeatures = {
202             Constants.DOM_CANONICAL_FORM,
203             Constants.DOM_CDATA_SECTIONS,
204             Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING,
205             Constants.DOM_INFOSET,
206             Constants.DOM_NAMESPACE_DECLARATIONS,
207             Constants.DOM_SPLIT_CDATA,
208             Constants.DOM_SUPPORTED_MEDIATYPES_ONLY,
209             Constants.DOM_CERTIFIED,
210             Constants.DOM_WELLFORMED,
211             Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS,
212         };
213
214
215         fConfiguration.addRecognizedFeatures (domRecognizedFeatures);
216
217         // turn off deferred DOM
218
fConfiguration.setFeature (DEFER_NODE_EXPANSION, false);
219
220         // Set values so that the value of the
221
// infoset parameter is true (its default value).
222
//
223
// true: namespace-declarations, well-formed,
224
// element-content-whitespace, comments, namespaces
225
//
226
// false: validate-if-schema, entities,
227
// datatype-normalization, cdata-sections
228

229         fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
230         fConfiguration.setFeature(Constants.DOM_WELLFORMED, true);
231         fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
232         fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
233         fConfiguration.setFeature(NAMESPACES, true);
234
235         fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
236         fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
237         fConfiguration.setFeature(NORMALIZE_DATA, false);
238         fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
239
240         // set other default values
241
fConfiguration.setFeature (Constants.DOM_CANONICAL_FORM, false);
242         fConfiguration.setFeature (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING, true);
243         fConfiguration.setFeature (Constants.DOM_SPLIT_CDATA, true);
244         fConfiguration.setFeature (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY, false);
245         fConfiguration.setFeature (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS, true);
246
247         // REVISIT: by default Xerces assumes that input is certified.
248
// default is different from the one specified in the DOM spec
249
fConfiguration.setFeature (Constants.DOM_CERTIFIED, true);
250
251         // Xerces datatype-normalization feature is on by default
252
fConfiguration.setFeature( NORMALIZE_DATA, false );
253     } // <init>(XMLParserConfiguration)
254

255     /**
256      * Constructs a DOM Builder using the specified symbol table.
257      */

258     public DOMParserImpl(SymbolTable symbolTable) {
259         this(
260             (XMLParserConfiguration) ObjectFactory.createObject(
261                 "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration",
262                 "com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration"));
263         fConfiguration.setProperty(
264             Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
265             symbolTable);
266     } // <init>(SymbolTable)
267

268
269     /**
270      * Constructs a DOM Builder using the specified symbol table and
271      * grammar pool.
272      */

273     public DOMParserImpl(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
274         this(
275             (XMLParserConfiguration) ObjectFactory.createObject(
276                 "com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration",
277                 "com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration"));
278         fConfiguration.setProperty(
279             Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
280             symbolTable);
281         fConfiguration.setProperty(
282             Constants.XERCES_PROPERTY_PREFIX
283                 + Constants.XMLGRAMMAR_POOL_PROPERTY,
284             grammarPool);
285     }
286
287     /**
288      * Resets the parser state.
289      *
290      * @throws SAXException Thrown on initialization error.
291      */

292     public void reset() {
293         super.reset();
294         // DOM Filter
295
if (fSkippedElemStack!=null) {
296             fSkippedElemStack.removeAllElements();
297         }
298         fSchemaLocations.clear();
299         fRejectedElement.clear();
300         fFilterReject = false;
301         fSchemaType = null;
302
303     } // reset()
304

305     //
306
// DOMParser methods
307
//
308

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

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

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

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

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

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

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

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

993     public Node JavaDoc parseWithContext (LSInput JavaDoc is, Node JavaDoc cnode,
994     short action) throws DOMException JavaDoc, LSException JavaDoc {
995         // REVISIT: need to implement.
996
throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Not supported");
997     }
998
999
1000    /**
1001     * NON-DOM: convert LSInput to XNIInputSource
1002     *
1003     * @param is
1004     * @return
1005     */

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

1052    public boolean getAsync () {
1053        return false;
1054    }
1055
1056    /**
1057     * @see org.w3c.dom.ls.LSParser#getBusy()
1058     */

1059    public boolean getBusy () {
1060        return fBusy;
1061    }
1062
1063    /**
1064     * @see org.w3c.dom.ls.DOMParser#abort()
1065     */

1066    public void abort () {
1067        // If parse operation is in progress then reset it
1068
if ( fBusy ) {
1069            fBusy = false;
1070            abortNow = true;
1071            try{
1072                //Revisit : Should we also close all opened readers ?
1073
//Work towards other classes supporting abort instead of
1074
//calling reset.
1075

1076                reset();
1077
1078                //interrupt the thread doing the parse operation.
1079
//come out of all block operations.
1080
// current thread could be blocked on read operation.
1081
if(currentThread != null )currentThread.interrupt();
1082            }catch(Exception JavaDoc ex){
1083            }
1084        }
1085        return; // If not busy then this is noop
1086
}
1087
1088} // class DOMParserImpl
1089
Popular Tags