~ubuntu-branches/ubuntu/karmic/libxerces2-java/karmic

« back to all changes in this revision

Viewing changes to src/org/apache/xerces/parsers/DOMParserImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-12-04 17:37:55 UTC
  • mfrom: (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20061204173755-hb6ybrrrk097zhx7
Tags: 2.8.1-1ubuntu1
* Merge with Debian unstable; remaining changes:
  - Build -gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
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/>.
 
2
 * Copyright 2000-2006 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.
56
15
 */
57
16
 
58
17
package org.apache.xerces.parsers;
59
18
 
60
19
import java.io.StringReader;
 
20
import java.util.Locale;
61
21
import java.util.Stack;
62
22
import java.util.StringTokenizer;
63
23
import java.util.Vector;
65
25
import org.apache.xerces.dom.DOMErrorImpl;
66
26
import org.apache.xerces.dom.DOMMessageFormatter;
67
27
import org.apache.xerces.dom.DOMStringListImpl;
68
 
import org.apache.xerces.dom3.DOMConfiguration;
69
 
import org.apache.xerces.dom3.DOMError;
70
 
import org.apache.xerces.dom3.DOMErrorHandler;
71
 
import org.apache.xerces.dom3.DOMStringList;
72
28
import org.apache.xerces.impl.Constants;
73
29
import org.apache.xerces.util.DOMEntityResolverWrapper;
74
30
import org.apache.xerces.util.DOMErrorHandlerWrapper;
 
31
import org.apache.xerces.util.DOMUtil;
75
32
import org.apache.xerces.util.SymbolTable;
 
33
import org.apache.xerces.util.XMLSymbols;
 
34
import org.apache.xerces.xni.Augmentations;
 
35
import org.apache.xerces.xni.NamespaceContext;
 
36
import org.apache.xerces.xni.QName;
 
37
import org.apache.xerces.xni.XMLAttributes;
 
38
import org.apache.xerces.xni.XMLDTDContentModelHandler;
 
39
import org.apache.xerces.xni.XMLDTDHandler;
 
40
import org.apache.xerces.xni.XMLDocumentHandler;
 
41
import org.apache.xerces.xni.XMLLocator;
 
42
import org.apache.xerces.xni.XMLResourceIdentifier;
 
43
import org.apache.xerces.xni.XMLString;
 
44
import org.apache.xerces.xni.XNIException;
76
45
import org.apache.xerces.xni.grammars.XMLGrammarPool;
77
46
import org.apache.xerces.xni.parser.XMLConfigurationException;
 
47
import org.apache.xerces.xni.parser.XMLDTDContentModelSource;
 
48
import org.apache.xerces.xni.parser.XMLDTDSource;
 
49
import org.apache.xerces.xni.parser.XMLDocumentSource;
78
50
import org.apache.xerces.xni.parser.XMLEntityResolver;
79
51
import org.apache.xerces.xni.parser.XMLInputSource;
 
52
import org.apache.xerces.xni.parser.XMLParseException;
80
53
import org.apache.xerces.xni.parser.XMLParserConfiguration;
 
54
import org.w3c.dom.DOMConfiguration;
 
55
import org.w3c.dom.DOMError;
 
56
import org.w3c.dom.DOMErrorHandler;
81
57
import org.w3c.dom.DOMException;
 
58
import org.w3c.dom.DOMStringList;
82
59
import org.w3c.dom.Document;
83
60
import org.w3c.dom.Node;
84
61
import org.w3c.dom.ls.LSException;
 
62
import org.w3c.dom.ls.LSInput;
85
63
import org.w3c.dom.ls.LSParser;
86
64
import org.w3c.dom.ls.LSParserFilter;
87
65
import org.w3c.dom.ls.LSResourceResolver;
88
 
import org.w3c.dom.ls.LSInput;
89
 
 
 
66
import org.xml.sax.SAXException;
90
67
 
91
68
/**
92
69
 * This is Xerces DOM Builder class. It uses the abstract DOM
96
73
 * @author Pavani Mukthipudi, Sun Microsystems Inc.
97
74
 * @author Elena Litani, IBM
98
75
 * @author Rahul Srivastava, Sun Microsystems Inc.
99
 
 * @version $Id: DOMParserImpl.java,v 1.16 2004/02/17 07:14:49 neeraj Exp $
 
76
 * @version $Id: DOMParserImpl.java 443059 2006-09-13 18:26:56Z mrglavas $
100
77
 */
101
 
 
102
 
 
103
78
public class DOMParserImpl
104
 
extends AbstractDOMParser implements LSParser, DOMConfiguration {
105
 
 
106
 
 
 
79
    extends AbstractDOMParser implements LSParser, DOMConfiguration {
107
80
 
108
81
    // SAX & Xerces feature ids
109
82
 
118
91
    /** XML Schema validation */
119
92
    protected static final String XMLSCHEMA =
120
93
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
 
94
    
 
95
    /** XML Schema full checking */
 
96
    protected static final String XMLSCHEMA_FULL_CHECKING =
 
97
    Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;    
121
98
 
122
99
    /** Dynamic validation */
123
100
    protected static final String DYNAMIC_VALIDATION =
143
120
    // Data
144
121
    //
145
122
 
146
 
 
 
123
    /** Include namespace declaration attributes in the document. **/
 
124
    protected boolean fNamespaceDeclarations = true;
 
125
    
147
126
    // REVISIT: this value should be null by default and should be set during creation of
148
127
    //          LSParser
149
128
    protected String fSchemaType = null;
150
129
 
151
130
    protected boolean fBusy = false;
 
131
    
 
132
    private boolean abortNow = false;
 
133
    
 
134
    private Thread currentThread;
152
135
 
153
136
    protected final static boolean DEBUG = false;
154
137
 
155
138
    private Vector fSchemaLocations = new Vector ();
156
139
    private String fSchemaLocation = null;
157
140
        private DOMStringList fRecognizedParameters;
 
141
    
 
142
    private AbortHandler abortHandler = new AbortHandler();
158
143
 
159
144
    //
160
145
    // Constructors
170
155
        configuration));
171
156
        if (schemaType != null) {
172
157
            if (schemaType.equals (Constants.NS_DTD)) {
173
 
                fConfiguration.setFeature (
174
 
                Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE,
175
 
                false);
 
158
                //Schema validation is false by default and hence there is no
 
159
                //need to set it to false here.  Also, schema validation is  
 
160
                //not a recognized feature for DTDConfiguration's and so 
 
161
                //setting this feature here would result in a Configuration 
 
162
                //Exception.            
176
163
                fConfiguration.setProperty (
177
164
                Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
178
165
                Constants.NS_DTD);
201
188
            Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING,
202
189
            Constants.DOM_INFOSET,
203
190
            Constants.DOM_NAMESPACE_DECLARATIONS,
 
191
            Constants.DOM_SPLIT_CDATA,
204
192
            Constants.DOM_SUPPORTED_MEDIATYPES_ONLY,
205
193
            Constants.DOM_CERTIFIED,
206
194
            Constants.DOM_WELLFORMED,
226
214
        fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
227
215
        fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
228
216
        fConfiguration.setFeature(NAMESPACES, true);
229
 
 
 
217
                
230
218
        fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
231
219
        fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
232
 
        fConfiguration.setFeature(NORMALIZE_DATA, false);
233
220
        fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
234
221
 
235
222
        // set other default values
236
223
        fConfiguration.setFeature (Constants.DOM_CANONICAL_FORM, false);
237
224
        fConfiguration.setFeature (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING, true);
 
225
        fConfiguration.setFeature (Constants.DOM_SPLIT_CDATA, true);
238
226
        fConfiguration.setFeature (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY, false);
239
227
        fConfiguration.setFeature (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS, true);
240
228
 
243
231
        fConfiguration.setFeature (Constants.DOM_CERTIFIED, true);
244
232
 
245
233
        // Xerces datatype-normalization feature is on by default
246
 
        fConfiguration.setFeature ( NORMALIZE_DATA, false );
 
234
        // This is a recognized feature only for XML Schemas. If the
 
235
        // configuration doesn't support this feature, ignore it.
 
236
        try {
 
237
            fConfiguration.setFeature ( NORMALIZE_DATA, false );
 
238
        }
 
239
        catch (XMLConfigurationException exc) {}
 
240
    
247
241
    } // <init>(XMLParserConfiguration)
248
242
 
249
243
    /**
253
247
        this (
254
248
        (XMLParserConfiguration) ObjectFactory.createObject (
255
249
        "org.apache.xerces.xni.parser.XMLParserConfiguration",
256
 
        "org.apache.xerces.parsers.XML11Configuration"));
 
250
        "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"));
257
251
        fConfiguration.setProperty (
258
252
        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
259
253
        symbolTable);
268
262
        this (
269
263
        (XMLParserConfiguration) ObjectFactory.createObject (
270
264
        "org.apache.xerces.xni.parser.XMLParserConfiguration",
271
 
        "org.apache.xerces.parsers.XML11Configuration"));
 
265
        "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"));
272
266
        fConfiguration.setProperty (
273
267
        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
274
268
        symbolTable);
285
279
     */
286
280
    public void reset () {
287
281
        super.reset ();
 
282
        
 
283
        // get state of namespace-declarations parameter.
 
284
        fNamespaceDeclarations = 
 
285
            fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
 
286
                
288
287
        // DOM Filter
289
288
        if (fSkippedElemStack!=null) {
290
289
            fSkippedElemStack.removeAllElements ();
339
338
     */
340
339
    public void setParameter (String name, Object value) throws DOMException {
341
340
        // set features
 
341
        
342
342
        if(value instanceof Boolean){
343
343
            boolean state = ((Boolean)value).booleanValue ();
344
344
            try {
345
 
                if (name.equals (Constants.DOM_COMMENTS)) {
 
345
                if (name.equalsIgnoreCase (Constants.DOM_COMMENTS)) {
346
346
                    fConfiguration.setFeature (INCLUDE_COMMENTS_FEATURE, state);
347
347
                }
348
 
                else if (name.equals (Constants.DOM_DATATYPE_NORMALIZATION)) {
 
348
                else if (name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)) {
349
349
                    fConfiguration.setFeature (NORMALIZE_DATA, state);
350
350
                }
351
 
                else if (name.equals (Constants.DOM_ENTITIES)) {
 
351
                else if (name.equalsIgnoreCase (Constants.DOM_ENTITIES)) {
352
352
                    fConfiguration.setFeature (CREATE_ENTITY_REF_NODES, state);
353
353
                }
354
 
                else if (name.equals (Constants.DOM_DISALLOW_DOCTYPE)) {
 
354
                else if (name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)) {
355
355
                    fConfiguration.setFeature (DISALLOW_DOCTYPE_DECL_FEATURE, state);
356
356
                }
357
 
                else if (name.equals (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
358
 
                || name.equals(Constants.DOM_NORMALIZE_CHARACTERS)
359
 
                || name.equals (Constants.DOM_CHECK_CHAR_NORMALIZATION)
360
 
                || name.equals (Constants.DOM_CANONICAL_FORM)) {
 
357
                else if (name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
 
358
                || name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
 
359
                || name.equalsIgnoreCase (Constants.DOM_CHECK_CHAR_NORMALIZATION)
 
360
                || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM)) {
361
361
                    if (state) { // true is not supported
362
362
                        String msg =
363
363
                        DOMMessageFormatter.formatMessage (
368
368
                    }
369
369
                    // setting those features to false is no-op
370
370
                }
371
 
                else if (name.equals (Constants.DOM_NAMESPACES)) {
 
371
                else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACES)) {
372
372
                    fConfiguration.setFeature (NAMESPACES, state);
373
373
                }
374
 
                else if (name.equals (Constants.DOM_INFOSET)) {
 
374
                else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
375
375
                    // Setting false has no effect.
376
376
                    if (state) {
377
 
                        // true: namespaces, comments, element-content-whitespace
 
377
                        // true: namespaces, namespace-declarations, 
 
378
                        // comments, element-content-whitespace
378
379
                        fConfiguration.setFeature(NAMESPACES, true);
 
380
                        fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
379
381
                        fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
380
382
                        fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
381
383
 
387
389
                        fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
388
390
                    }
389
391
                }
390
 
                else if (name.equals(Constants.DOM_CDATA_SECTIONS)) {
 
392
                else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
391
393
                    fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, state);
392
394
                }
393
 
                else if (name.equals (Constants.DOM_NAMESPACE_DECLARATIONS)
394
 
                || name.equals (Constants.DOM_WELLFORMED)
395
 
                || name.equals (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
 
395
                else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)) {
 
396
                    fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, state);
 
397
                }
 
398
                else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
 
399
                || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
396
400
                    if (!state) { // false is not supported
397
401
                        String msg =
398
402
                        DOMMessageFormatter.formatMessage (
404
408
                    // setting these features to true is no-op
405
409
                    // REVISIT: implement "namespace-declaration" feature
406
410
                }
407
 
                else if (name.equals (Constants.DOM_VALIDATE)) {
 
411
                else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE)) {
408
412
                    fConfiguration.setFeature (VALIDATION_FEATURE, state);
409
413
                    if (fSchemaType != Constants.NS_DTD) {
410
414
                        fConfiguration.setFeature (XMLSCHEMA, state);
 
415
                        fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, state);
411
416
                    }
412
417
                    if (state){
413
418
                        fConfiguration.setFeature (DYNAMIC_VALIDATION, false);
414
419
                    }
415
420
                }
416
 
                else if (name.equals (Constants.DOM_VALIDATE_IF_SCHEMA)) {
 
421
                else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)) {
417
422
                    fConfiguration.setFeature (DYNAMIC_VALIDATION, state);
418
423
                    // Note: validation and dynamic validation are mutually exclusive
419
424
                    if (state){
420
425
                        fConfiguration.setFeature (VALIDATION_FEATURE, false);
421
426
                    }
422
427
                }
423
 
                else if (name.equals (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
 
428
                else if (name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
424
429
                    fConfiguration.setFeature (INCLUDE_IGNORABLE_WHITESPACE, state);
425
430
                }
426
 
                else if (name.equals (Constants.DOM_PSVI)){
 
431
                else if (name.equalsIgnoreCase (Constants.DOM_PSVI)){
427
432
                    //XSModel - turn on PSVI augmentation
428
433
                    fConfiguration.setFeature (PSVI_AUGMENT, true);
429
434
                    fConfiguration.setProperty (DOCUMENT_CLASS_NAME,
430
435
                    "org.apache.xerces.dom.PSVIDocumentImpl");
431
436
                }
432
437
                else {
433
 
                    // Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING feature
 
438
                    // Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING feature,
 
439
                    // Constants.DOM_SPLIT_CDATA feature,
434
440
                    // or any Xerces feature
435
 
                    fConfiguration.setFeature (name, state);
 
441
                    fConfiguration.setFeature (name.toLowerCase(Locale.ENGLISH), state);
436
442
                }
437
443
 
438
444
            }
446
452
            }
447
453
        }
448
454
        else { // set properties
449
 
            if (name.equals (Constants.DOM_ERROR_HANDLER)) {
450
 
                // REVISIT: we should probably allow unsetting error-handler
451
 
                if (value == null) return;
452
 
                if (value instanceof DOMErrorHandler) {
 
455
            if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
 
456
                if (value instanceof DOMErrorHandler || value == null) {
453
457
                    try {
454
458
                        fErrorHandler = new DOMErrorHandlerWrapper ((DOMErrorHandler) value);
455
459
                        fConfiguration.setProperty (ERROR_HANDLER, fErrorHandler);
463
467
                    DOMMessageFormatter.DOM_DOMAIN,
464
468
                    "TYPE_MISMATCH_ERR",
465
469
                    new Object[] { name });
466
 
                    throw new DOMException (DOMException.NOT_SUPPORTED_ERR, msg);
 
470
                    throw new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
467
471
                }
468
472
 
469
473
            }
470
 
            else if (name.equals (Constants.DOM_RESOURCE_RESOLVER)) {
471
 
                if (value instanceof LSResourceResolver) {
 
474
            else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
 
475
                if (value instanceof LSResourceResolver || value == null) {
472
476
                    try {
473
477
                        fConfiguration.setProperty (ENTITY_RESOLVER, new DOMEntityResolverWrapper ((LSResourceResolver) value));
474
478
                    }
481
485
                    DOMMessageFormatter.DOM_DOMAIN,
482
486
                    "TYPE_MISMATCH_ERR",
483
487
                    new Object[] { name });
484
 
                    throw new DOMException (DOMException.NOT_SUPPORTED_ERR, msg);
 
488
                    throw new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
485
489
                }
486
490
 
487
491
            }
488
 
            else if (name.equals (Constants.DOM_SCHEMA_LOCATION)) {
489
 
                if (value instanceof String) {
 
492
            else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
 
493
                if (value instanceof String || value == null) {
490
494
                    try {
491
 
                        if (fSchemaType == Constants.NS_XMLSCHEMA) {
 
495
                        if (value == null) {
 
496
                            fSchemaLocation = null;
 
497
                            fConfiguration.setProperty (
 
498
                                Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE,
 
499
                                null);
 
500
                        }
 
501
                        else {
492
502
                            fSchemaLocation = (String)value;
493
503
                            // map DOM schema-location to JAXP schemaSource property
494
504
                            // tokenize location string
509
519
                                value);
510
520
                            }
511
521
                        }
512
 
                        else {
513
 
                            // REVISIT: allow pre-parsing DTD grammars
514
 
                            String msg =
515
 
                            DOMMessageFormatter.formatMessage (
516
 
                            DOMMessageFormatter.DOM_DOMAIN,
517
 
                            "FEATURE_NOT_SUPPORTED",
518
 
                            new Object[] { name });
519
 
                            throw new DOMException (DOMException.NOT_SUPPORTED_ERR, msg);
520
 
                        }
521
 
 
522
522
                    }
523
523
                    catch (XMLConfigurationException e) {}
524
524
                }
529
529
                    DOMMessageFormatter.DOM_DOMAIN,
530
530
                    "TYPE_MISMATCH_ERR",
531
531
                    new Object[] { name });
532
 
                    throw new DOMException (DOMException.NOT_SUPPORTED_ERR, msg);
 
532
                    throw new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
533
533
                }
534
534
 
535
535
            }
536
 
            else if (name.equals (Constants.DOM_SCHEMA_TYPE)) {
537
 
                // REVISIT: should null value be supported?
538
 
                if (value instanceof String) {
 
536
            else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
 
537
                if (value instanceof String || value == null) {
539
538
                    try {
540
 
                        if (value.equals (Constants.NS_XMLSCHEMA)) {
541
 
                            // turn on schema feature
542
 
                            fConfiguration.setFeature (Constants.XERCES_FEATURE_PREFIX
543
 
                            + Constants.SCHEMA_VALIDATION_FEATURE,
544
 
                            true);
 
539
                        if (value == null) {
 
540
                            // turn off schema features
 
541
                            fConfiguration.setFeature (XMLSCHEMA, false);
 
542
                            fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, false);
 
543
                            // map to JAXP schemaLanguage
 
544
                            fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
 
545
                            + Constants.SCHEMA_LANGUAGE,
 
546
                            null);
 
547
                            fSchemaType = null;
 
548
                        }
 
549
                        else if (value.equals (Constants.NS_XMLSCHEMA)) {
 
550
                            // turn on schema features
 
551
                            fConfiguration.setFeature (XMLSCHEMA, true);
 
552
                            fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, true);
545
553
                            // map to JAXP schemaLanguage
546
554
                            fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
547
555
                            + Constants.SCHEMA_LANGUAGE,
549
557
                            fSchemaType = Constants.NS_XMLSCHEMA;
550
558
                        }
551
559
                        else if (value.equals (Constants.NS_DTD)) {
552
 
                            fConfiguration.setFeature (
553
 
                            Constants.XERCES_FEATURE_PREFIX
554
 
                            + Constants.SCHEMA_VALIDATION_FEATURE,
555
 
                            false);
 
560
                            // turn off schema features
 
561
                            fConfiguration.setFeature (XMLSCHEMA, false);
 
562
                            fConfiguration.setFeature (XMLSCHEMA_FULL_CHECKING, false);
 
563
                            // map to JAXP schemaLanguage
556
564
                            fConfiguration.setProperty ( Constants.JAXP_PROPERTY_PREFIX
557
565
                            + Constants.SCHEMA_LANGUAGE,
558
566
                            Constants.NS_DTD);
567
575
                    DOMMessageFormatter.DOM_DOMAIN,
568
576
                    "TYPE_MISMATCH_ERR",
569
577
                    new Object[] { name });
570
 
                    throw new DOMException (DOMException.NOT_SUPPORTED_ERR, msg);
 
578
                    throw new DOMException (DOMException.TYPE_MISMATCH_ERR, msg);
571
579
                }
572
580
 
573
581
            }
574
 
            else if (name.equals (DOCUMENT_CLASS_NAME)) {
 
582
            else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)) {
575
583
                fConfiguration.setProperty (DOCUMENT_CLASS_NAME, value);
576
584
            }
577
585
            else {
591
599
     * Look up the value of a feature or a property.
592
600
     */
593
601
    public Object getParameter (String name) throws DOMException {
594
 
        if (name.equals (Constants.DOM_COMMENTS)) {
 
602
        if (name.equalsIgnoreCase (Constants.DOM_COMMENTS)) {
595
603
            return (fConfiguration.getFeature (INCLUDE_COMMENTS_FEATURE))
596
604
            ? Boolean.TRUE
597
605
            : Boolean.FALSE;
598
606
        }
599
 
        else if (name.equals (Constants.DOM_DATATYPE_NORMALIZATION)) {
 
607
        else if (name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)) {
600
608
            return (fConfiguration.getFeature (NORMALIZE_DATA))
601
609
            ? Boolean.TRUE
602
610
            : Boolean.FALSE;
603
611
        }
604
 
        else if (name.equals (Constants.DOM_ENTITIES)) {
 
612
        else if (name.equalsIgnoreCase (Constants.DOM_ENTITIES)) {
605
613
            return (fConfiguration.getFeature (CREATE_ENTITY_REF_NODES))
606
614
            ? Boolean.TRUE
607
615
            : Boolean.FALSE;
608
616
        }
609
 
        else if (name.equals (Constants.DOM_NAMESPACES)) {
 
617
        else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACES)) {
610
618
            return (fConfiguration.getFeature (NAMESPACES))
611
619
            ? Boolean.TRUE
612
620
            : Boolean.FALSE;
613
621
        }
614
 
        else if (name.equals (Constants.DOM_VALIDATE)) {
 
622
        else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE)) {
615
623
            return (fConfiguration.getFeature (VALIDATION_FEATURE))
616
624
            ? Boolean.TRUE
617
625
            : Boolean.FALSE;
618
626
        }
619
 
        else if (name.equals (Constants.DOM_VALIDATE_IF_SCHEMA)) {
 
627
        else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)) {
620
628
            return (fConfiguration.getFeature (DYNAMIC_VALIDATION))
621
629
            ? Boolean.TRUE
622
630
            : Boolean.FALSE;
623
631
        }
624
 
        else if (name.equals (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
 
632
        else if (name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
625
633
            return (fConfiguration.getFeature (INCLUDE_IGNORABLE_WHITESPACE))
626
634
            ? Boolean.TRUE
627
635
            : Boolean.FALSE;
628
636
        }
629
 
        else if (name.equals (Constants.DOM_DISALLOW_DOCTYPE)) {
 
637
        else if (name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)) {
630
638
            return (fConfiguration.getFeature (DISALLOW_DOCTYPE_DECL_FEATURE))
631
639
            ? Boolean.TRUE
632
640
            : Boolean.FALSE;
633
641
        }
634
 
        else if (name.equals (Constants.DOM_INFOSET)) {
 
642
        else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
635
643
            // REVISIT: This is somewhat expensive to compute
636
644
            // but it's possible that the user has a reference
637
645
            // to the configuration and is changing the values
638
646
            // of these features directly on it.
639
647
            boolean infoset = fConfiguration.getFeature(NAMESPACES) &&
 
648
                fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS) &&
640
649
                fConfiguration.getFeature(INCLUDE_COMMENTS_FEATURE) &&
641
650
                fConfiguration.getFeature(INCLUDE_IGNORABLE_WHITESPACE) &&
642
651
                !fConfiguration.getFeature(DYNAMIC_VALIDATION) &&
645
654
                !fConfiguration.getFeature(CREATE_CDATA_NODES_FEATURE);
646
655
            return (infoset) ? Boolean.TRUE : Boolean.FALSE;
647
656
        }
648
 
        else if (name.equals(Constants.DOM_CDATA_SECTIONS)) {
 
657
        else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
649
658
            return (fConfiguration.getFeature(CREATE_CDATA_NODES_FEATURE))
650
659
                ? Boolean.TRUE : Boolean.FALSE;
651
660
        }
652
 
        else if (name.equals(Constants.DOM_CHECK_CHAR_NORMALIZATION ) ||
653
 
                 name.equals(Constants.DOM_NORMALIZE_CHARACTERS)){
 
661
        else if (name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION ) ||
 
662
                 name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)){
654
663
            return Boolean.FALSE;
655
664
        }
656
 
        else if (name.equals(Constants.DOM_NAMESPACE_DECLARATIONS)
657
 
        || name.equals (Constants.DOM_WELLFORMED)
658
 
        || name.equals (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)
659
 
        || name.equals (Constants.DOM_CANONICAL_FORM)
660
 
        || name.equals (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
661
 
        || name.equals (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)) {
662
 
            return (fConfiguration.getFeature (name))
 
665
        else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
 
666
        || name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
 
667
        || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)
 
668
        || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM)
 
669
        || name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
 
670
        || name.equalsIgnoreCase (Constants.DOM_SPLIT_CDATA)
 
671
        || name.equalsIgnoreCase (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)) {
 
672
            return (fConfiguration.getFeature (name.toLowerCase(Locale.ENGLISH)))
663
673
            ? Boolean.TRUE
664
674
            : Boolean.FALSE;
665
675
        }
666
 
        else if (name.equals (Constants.DOM_ERROR_HANDLER)) {
 
676
        else if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
667
677
            if (fErrorHandler != null) {
668
678
                return fErrorHandler.getErrorHandler ();
669
679
            }
670
680
            return null;
671
681
        }
672
 
        else if (name.equals (Constants.DOM_RESOURCE_RESOLVER)) {
 
682
        else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
673
683
            try {
674
684
                XMLEntityResolver entityResolver =
675
685
                (XMLEntityResolver) fConfiguration.getProperty (ENTITY_RESOLVER);
681
691
            }
682
692
            catch (XMLConfigurationException e) {}
683
693
        }
684
 
        else if (name.equals (Constants.DOM_SCHEMA_TYPE)) {
 
694
        else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
685
695
            return fConfiguration.getProperty (
686
696
            Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
687
697
        }
688
 
        else if (name.equals (Constants.DOM_SCHEMA_LOCATION)) {
 
698
        else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
689
699
            return fSchemaLocation;
690
700
        }
691
 
        else if (name.equals (SYMBOL_TABLE)){
 
701
        else if (name.equalsIgnoreCase (SYMBOL_TABLE)){
692
702
            return fConfiguration.getProperty (SYMBOL_TABLE);
693
703
        }
694
 
        else if (name.equals (DOCUMENT_CLASS_NAME)) {
 
704
        else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)) {
695
705
            return fConfiguration.getProperty (DOCUMENT_CLASS_NAME);
696
706
        }
697
707
        else {
706
716
    }
707
717
 
708
718
    public boolean canSetParameter (String name, Object value) {
 
719
        if (value == null){
 
720
                return true;
 
721
        }
 
722
        
709
723
        if(value instanceof Boolean){
710
724
            boolean state = ((Boolean)value).booleanValue ();
711
 
            if ( name.equals (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
712
 
            || name.equals(Constants.DOM_NORMALIZE_CHARACTERS)
713
 
            || name.equals(Constants.DOM_CHECK_CHAR_NORMALIZATION )
714
 
            || name.equals (Constants.DOM_CANONICAL_FORM) ) {
 
725
            if ( name.equalsIgnoreCase (Constants.DOM_SUPPORTED_MEDIATYPES_ONLY)
 
726
            || name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
 
727
            || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION )
 
728
            || name.equalsIgnoreCase (Constants.DOM_CANONICAL_FORM) ) {
715
729
                // true is not supported
716
730
                return (state) ? false : true;
717
731
            }
718
 
            else if (name.equals (Constants.DOM_NAMESPACE_DECLARATIONS)
719
 
            || name.equals (Constants.DOM_WELLFORMED)
720
 
            || name.equals (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
 
732
            else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
 
733
            || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
721
734
                // false is not supported
722
735
                return (state) ? true : false;
723
736
            }
724
 
            else if (name.equals (Constants.DOM_CDATA_SECTIONS)
725
 
            || name.equals (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)
726
 
            || name.equals (Constants.DOM_COMMENTS)
727
 
            || name.equals (Constants.DOM_DATATYPE_NORMALIZATION)
728
 
            || name.equals (Constants.DOM_DISALLOW_DOCTYPE)
729
 
            || name.equals (Constants.DOM_ENTITIES)
730
 
            || name.equals (Constants.DOM_INFOSET)
731
 
            || name.equals (Constants.DOM_NAMESPACES)
732
 
            || name.equals (Constants.DOM_VALIDATE)
733
 
            || name.equals (Constants.DOM_VALIDATE_IF_SCHEMA)
734
 
            || name.equals (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
735
 
            || name.equals (Constants.DOM_XMLDECL)) {
 
737
            else if (name.equalsIgnoreCase (Constants.DOM_CDATA_SECTIONS)
 
738
            || name.equalsIgnoreCase (Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING)
 
739
            || name.equalsIgnoreCase (Constants.DOM_COMMENTS)
 
740
            || name.equalsIgnoreCase (Constants.DOM_DATATYPE_NORMALIZATION)
 
741
            || name.equalsIgnoreCase (Constants.DOM_DISALLOW_DOCTYPE)
 
742
            || name.equalsIgnoreCase (Constants.DOM_ENTITIES)
 
743
            || name.equalsIgnoreCase (Constants.DOM_INFOSET)
 
744
            || name.equalsIgnoreCase (Constants.DOM_NAMESPACES)
 
745
            || name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)
 
746
            || name.equalsIgnoreCase (Constants.DOM_VALIDATE)
 
747
            || name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)
 
748
            || name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
 
749
            || name.equalsIgnoreCase (Constants.DOM_XMLDECL)) {
736
750
                return true;
737
751
            }
738
752
 
739
753
            // Recognize Xerces features.
740
754
            try {
741
 
                fConfiguration.getFeature (name);
 
755
                fConfiguration.getFeature(name.toLowerCase(Locale.ENGLISH));
742
756
                return true;
743
757
            }
744
758
            catch (XMLConfigurationException e) {
746
760
            }
747
761
        }
748
762
        else { // check properties
749
 
            if (name.equals (Constants.DOM_ERROR_HANDLER)) {
750
 
                if (value instanceof DOMErrorHandler) {
751
 
                    return true;
752
 
                }
753
 
                return false;
754
 
            }
755
 
            else if (name.equals (Constants.DOM_RESOURCE_RESOLVER)) {
756
 
                if (value instanceof LSResourceResolver) {
757
 
                    return true;
758
 
                }
759
 
                return false;
760
 
            }
761
 
            else if (name.equals (Constants.DOM_SCHEMA_TYPE)) {
762
 
                if (value instanceof String
 
763
            if (name.equalsIgnoreCase (Constants.DOM_ERROR_HANDLER)) {
 
764
                if (value instanceof DOMErrorHandler || value == null) {
 
765
                    return true;
 
766
                }
 
767
                return false;
 
768
            }
 
769
            else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
 
770
                if (value instanceof LSResourceResolver || value == null) {
 
771
                    return true;
 
772
                }
 
773
                return false;
 
774
            }
 
775
            else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_TYPE)) {
 
776
                if ((value instanceof String
763
777
                && (value.equals (Constants.NS_XMLSCHEMA)
764
 
                || value.equals (Constants.NS_DTD))) {
 
778
                || value.equals (Constants.NS_DTD))) || value == null) {
765
779
                    return true;
766
780
                }
767
781
                return false;
768
782
            }
769
 
            else if (name.equals (Constants.DOM_SCHEMA_LOCATION)) {
770
 
                if (value instanceof String)
 
783
            else if (name.equalsIgnoreCase (Constants.DOM_SCHEMA_LOCATION)) {
 
784
                if (value instanceof String || value == null)
771
785
                    return true;
772
786
                return false;
773
787
            }
774
 
            else if (name.equals (DOCUMENT_CLASS_NAME)){
 
788
            else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)){
775
789
                return true;
776
790
            }
777
791
            return false;
787
801
     * parameter names defined outside this specification.
788
802
     */
789
803
    public DOMStringList getParameterNames () {
790
 
                if (fRecognizedParameters == null){
791
 
                        Vector parameters = new Vector();
792
 
 
793
 
                        // REVISIT: add Xerces recognized properties/features
794
 
                        parameters.add(Constants.DOM_NAMESPACES);
795
 
                        parameters.add(Constants.DOM_CDATA_SECTIONS);
796
 
                        parameters.add(Constants.DOM_CANONICAL_FORM);
797
 
                        parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
798
 
 
799
 
                        parameters.add(Constants.DOM_ENTITIES);
800
 
                        parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
801
 
                        parameters.add(Constants.DOM_VALIDATE);
802
 
                        parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
803
 
 
804
 
                        parameters.add(Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING);
805
 
                        parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
806
 
                        parameters.add(Constants.DOM_SUPPORTED_MEDIATYPES_ONLY);
807
 
                        parameters.add(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS);
808
 
 
809
 
                        parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
810
 
                        parameters.add(Constants.DOM_WELLFORMED);
811
 
                        parameters.add(Constants.DOM_INFOSET);
812
 
                        parameters.add(Constants.DOM_DISALLOW_DOCTYPE);
813
 
                        parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
814
 
 
815
 
                        parameters.add(Constants.DOM_ENTITIES);
816
 
                        parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
817
 
                        parameters.add(Constants.DOM_COMMENTS);
818
 
 
819
 
                        parameters.add(Constants.DOM_ERROR_HANDLER);
820
 
                        parameters.add(Constants.DOM_RESOURCE_RESOLVER);
821
 
                        parameters.add(Constants.DOM_SCHEMA_LOCATION);
822
 
                        parameters.add(Constants.DOM_SCHEMA_TYPE);
823
 
 
824
 
                        fRecognizedParameters = new DOMStringListImpl(parameters);
825
 
 
826
 
                }
827
 
 
828
 
                return fRecognizedParameters;
 
804
        if (fRecognizedParameters == null){
 
805
            Vector parameters = new Vector();
 
806
            
 
807
            // REVISIT: add Xerces recognized properties/features
 
808
            parameters.add(Constants.DOM_NAMESPACES);
 
809
            parameters.add(Constants.DOM_CDATA_SECTIONS);
 
810
            parameters.add(Constants.DOM_CANONICAL_FORM);
 
811
            parameters.add(Constants.DOM_NAMESPACE_DECLARATIONS);
 
812
            parameters.add(Constants.DOM_SPLIT_CDATA);
 
813
            
 
814
            parameters.add(Constants.DOM_ENTITIES);
 
815
            parameters.add(Constants.DOM_VALIDATE_IF_SCHEMA);
 
816
            parameters.add(Constants.DOM_VALIDATE);
 
817
            parameters.add(Constants.DOM_DATATYPE_NORMALIZATION);
 
818
            
 
819
            parameters.add(Constants.DOM_CHARSET_OVERRIDES_XML_ENCODING);
 
820
            parameters.add(Constants.DOM_CHECK_CHAR_NORMALIZATION);
 
821
            parameters.add(Constants.DOM_SUPPORTED_MEDIATYPES_ONLY);
 
822
            parameters.add(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS);
 
823
            
 
824
            parameters.add(Constants.DOM_NORMALIZE_CHARACTERS);
 
825
            parameters.add(Constants.DOM_WELLFORMED);
 
826
            parameters.add(Constants.DOM_INFOSET);
 
827
            parameters.add(Constants.DOM_DISALLOW_DOCTYPE);
 
828
            parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
 
829
            parameters.add(Constants.DOM_COMMENTS);
 
830
            
 
831
            parameters.add(Constants.DOM_ERROR_HANDLER);
 
832
            parameters.add(Constants.DOM_RESOURCE_RESOLVER);
 
833
            parameters.add(Constants.DOM_SCHEMA_LOCATION);
 
834
            parameters.add(Constants.DOM_SCHEMA_TYPE);
 
835
            
 
836
            fRecognizedParameters = new DOMStringListImpl(parameters);
 
837
            
 
838
        }
 
839
        
 
840
        return fRecognizedParameters;
829
841
    }
830
842
 
831
843
    /**
847
859
 
848
860
        XMLInputSource source = new XMLInputSource (null, uri, null);
849
861
        try {
 
862
            currentThread = Thread.currentThread();
850
863
                        fBusy = true;
851
864
            parse (source);
852
865
            fBusy = false;
 
866
            if (abortNow && currentThread.isInterrupted()) {
 
867
                //reset interrupt state 
 
868
                abortNow = false;
 
869
                Thread.interrupted();
 
870
            }
853
871
        } catch (Exception e){
854
872
            fBusy = false;
 
873
            if (abortNow && currentThread.isInterrupted()) {
 
874
                Thread.interrupted();
 
875
            }
 
876
            if (abortNow) {
 
877
                abortNow = false;
 
878
                restoreHandlers();
 
879
                return null;
 
880
            }
855
881
            // Consume this exception if the user
856
882
            // issued an interrupt or an abort.
857
883
            if (e != abort) {
858
 
                if (fErrorHandler != null) {
 
884
                if (!(e instanceof XMLParseException) && fErrorHandler != null) {
859
885
                    DOMErrorImpl error = new DOMErrorImpl ();
860
886
                    error.fException = e;
861
887
                    error.fMessage = e.getMessage ();
865
891
                if (DEBUG) {
866
892
                    e.printStackTrace ();
867
893
                }
868
 
                throw new LSException(LSException.PARSE_ERR, e.getMessage());
 
894
                throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
869
895
            }
870
896
        }
871
 
        return getDocument ();
 
897
        Document doc = getDocument();
 
898
        dropDocumentReferences();
 
899
        return doc;
872
900
    }
873
901
 
874
902
    /**
888
916
        }
889
917
 
890
918
        try {
 
919
            currentThread = Thread.currentThread();
891
920
                        fBusy = true;
892
921
            parse (xmlInputSource);
893
 
            fBusy = false;
 
922
            fBusy = false;   
 
923
            if (abortNow && currentThread.isInterrupted()) {
 
924
                //reset interrupt state 
 
925
                abortNow = false;
 
926
                Thread.interrupted();
 
927
            }
894
928
        } catch (Exception e) {
895
929
            fBusy = false;
 
930
            if (abortNow && currentThread.isInterrupted()) {
 
931
                Thread.interrupted();
 
932
            }
 
933
            if (abortNow) {
 
934
                abortNow = false;
 
935
                restoreHandlers();
 
936
                return null;
 
937
            }
896
938
            // Consume this exception if the user
897
939
            // issued an interrupt or an abort.
898
940
            if (e != abort) {
899
 
                if (fErrorHandler != null) {
 
941
                if (!(e instanceof XMLParseException) && fErrorHandler != null) {
900
942
                   DOMErrorImpl error = new DOMErrorImpl ();
901
943
                   error.fException = e;
902
944
                   error.fMessage = e.getMessage ();
906
948
                if (DEBUG) {
907
949
                   e.printStackTrace ();
908
950
                }
909
 
                throw new LSException(LSException.PARSE_ERR, e.getMessage());
 
951
                throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
910
952
            }
911
953
        }
912
 
        return getDocument ();
 
954
        Document doc = getDocument();
 
955
        dropDocumentReferences();
 
956
        return doc;
 
957
    }
 
958
 
 
959
 
 
960
    private void restoreHandlers() {
 
961
        fConfiguration.setDocumentHandler(this);
 
962
        fConfiguration.setDTDHandler(this);
 
963
        fConfiguration.setDTDContentModelHandler(this);
913
964
    }
914
965
 
915
966
    /**
947
998
    XMLInputSource dom2xmlInputSource (LSInput is) {
948
999
        // need to wrap the LSInput with an XMLInputSource
949
1000
        XMLInputSource xis = null;
950
 
        // if there is a string data, use a StringReader
951
 
        // according to DOM, we need to treat such data as "UTF-16".
952
 
        if (is.getStringData () != null) {
953
 
            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
954
 
            is.getBaseURI (), new StringReader (is.getStringData ()),
955
 
            "UTF-16");
956
 
        }
957
1001
        // check whether there is a Reader
958
1002
        // according to DOM, we need to treat such reader as "UTF-16".
959
 
        else if (is.getCharacterStream () != null) {
 
1003
        if (is.getCharacterStream () != null) {
960
1004
            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
961
1005
            is.getBaseURI (), is.getCharacterStream (),
962
1006
            "UTF-16");
967
1011
            is.getBaseURI (), is.getByteStream (),
968
1012
            is.getEncoding ());
969
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 (is.getStringData ()),
 
1019
            "UTF-16");
 
1020
        }
970
1021
        // otherwise, just use the public/system/base Ids
971
 
        else {
 
1022
        else if ((is.getSystemId() != null && is.getSystemId().length() > 0) || 
 
1023
            (is.getPublicId() != null && is.getPublicId().length() > 0)) {
972
1024
            xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
973
1025
            is.getBaseURI ());
974
1026
        }
975
 
 
 
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(LSException.PARSE_ERR, "no-input-specified");
 
1037
        }
976
1038
        return xis;
977
1039
    }
978
1040
 
997
1059
        // If parse operation is in progress then reset it
998
1060
        if ( fBusy ) {
999
1061
            fBusy = false;
1000
 
            throw abort;
 
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
            }               
1001
1074
        }
1002
1075
        return; // If not busy then this is noop
1003
1076
    }
1004
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 encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
 
1111
            throw abort;
 
1112
        }
 
1113
 
 
1114
        public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
 
1115
            throw abort;
 
1116
        }
 
1117
 
 
1118
        public void doctypeDecl(String rootElement, String publicId, String 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 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 name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
 
1139
            throw abort;
 
1140
        }
 
1141
 
 
1142
        public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
 
1143
            throw abort;
 
1144
        }
 
1145
 
 
1146
        public void endGeneralEntity(String 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 name, XMLResourceIdentifier identifier, String encoding, Augmentations augmentations) throws XNIException {
 
1187
            throw abort;
 
1188
        }
 
1189
 
 
1190
        public void endParameterEntity(String 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 name, String contentModel, Augmentations augmentations) throws XNIException {
 
1203
            throw abort;
 
1204
        }
 
1205
 
 
1206
        public void startAttlist(String elementName, Augmentations augmentations) throws XNIException {
 
1207
            throw abort;
 
1208
        }
 
1209
 
 
1210
        public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String 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 name, XMLString text, XMLString nonNormalizedText, Augmentations augmentations) throws XNIException {
 
1219
            throw abort;
 
1220
        }
 
1221
 
 
1222
        public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
 
1223
            throw abort;
 
1224
        }
 
1225
 
 
1226
        public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations) throws XNIException {
 
1227
            throw abort;
 
1228
        }
 
1229
 
 
1230
        public void notationDecl(String 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 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 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
        
1005
1308
} // class DOMParserImpl