2
* The Apache Software License, Version 1.1
5
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
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
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.
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.
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.
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
48
* ====================================================================
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.
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
58
17
package org.apache.xerces.parsers;
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;
66
import org.xml.sax.SAXException;
92
69
* This is Xerces DOM Builder class. It uses the abstract DOM
340
339
public void setParameter (String name, Object value) throws DOMException {
342
342
if(value instanceof Boolean){
343
343
boolean state = ((Boolean)value).booleanValue ();
345
if (name.equals (Constants.DOM_COMMENTS)) {
345
if (name.equalsIgnoreCase (Constants.DOM_COMMENTS)) {
346
346
fConfiguration.setFeature (INCLUDE_COMMENTS_FEATURE, state);
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);
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);
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);
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
363
363
DOMMessageFormatter.formatMessage (
404
408
// setting these features to true is no-op
405
409
// REVISIT: implement "namespace-declaration" feature
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);
413
418
fConfiguration.setFeature (DYNAMIC_VALIDATION, false);
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
420
425
fConfiguration.setFeature (VALIDATION_FEATURE, false);
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);
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");
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);
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);
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) {
540
if (value.equals (Constants.NS_XMLSCHEMA)) {
541
// turn on schema feature
542
fConfiguration.setFeature (Constants.XERCES_FEATURE_PREFIX
543
+ Constants.SCHEMA_VALIDATION_FEATURE,
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,
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,
591
599
* Look up the value of a feature or a property.
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))
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))
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))
609
else if (name.equals (Constants.DOM_NAMESPACES)) {
617
else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACES)) {
610
618
return (fConfiguration.getFeature (NAMESPACES))
614
else if (name.equals (Constants.DOM_VALIDATE)) {
622
else if (name.equalsIgnoreCase (Constants.DOM_VALIDATE)) {
615
623
return (fConfiguration.getFeature (VALIDATION_FEATURE))
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))
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))
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))
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;
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;
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;
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)))
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 ();
672
else if (name.equals (Constants.DOM_RESOURCE_RESOLVER)) {
682
else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
674
684
XMLEntityResolver entityResolver =
675
685
(XMLEntityResolver) fConfiguration.getProperty (ENTITY_RESOLVER);
708
718
public boolean canSetParameter (String name, Object value) {
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;
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;
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)) {
739
753
// Recognize Xerces features.
741
fConfiguration.getFeature (name);
755
fConfiguration.getFeature(name.toLowerCase(Locale.ENGLISH));
744
758
catch (XMLConfigurationException e) {
748
762
else { // check properties
749
if (name.equals (Constants.DOM_ERROR_HANDLER)) {
750
if (value instanceof DOMErrorHandler) {
755
else if (name.equals (Constants.DOM_RESOURCE_RESOLVER)) {
756
if (value instanceof LSResourceResolver) {
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) {
769
else if (name.equalsIgnoreCase (Constants.DOM_RESOURCE_RESOLVER)) {
770
if (value instanceof LSResourceResolver || value == null) {
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) {
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)
774
else if (name.equals (DOCUMENT_CLASS_NAME)){
788
else if (name.equalsIgnoreCase (DOCUMENT_CLASS_NAME)){
787
801
* parameter names defined outside this specification.
789
803
public DOMStringList getParameterNames () {
790
if (fRecognizedParameters == null){
791
Vector parameters = new Vector();
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);
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);
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);
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);
815
parameters.add(Constants.DOM_ENTITIES);
816
parameters.add(Constants.DOM_ELEMENT_CONTENT_WHITESPACE);
817
parameters.add(Constants.DOM_COMMENTS);
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);
824
fRecognizedParameters = new DOMStringListImpl(parameters);
828
return fRecognizedParameters;
804
if (fRecognizedParameters == null){
805
Vector parameters = new Vector();
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);
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);
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);
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);
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);
836
fRecognizedParameters = new DOMStringListImpl(parameters);
840
return fRecognizedParameters;
967
1011
is.getBaseURI (), is.getByteStream (),
968
1012
is.getEncoding ());
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 ()),
970
1021
// otherwise, just use the public/system/base Ids
1022
else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
1023
(is.getPublicId() != null && is.getPublicId().length() > 0)) {
972
1024
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
973
1025
is.getBaseURI ());
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);
1036
throw new LSException(LSException.PARSE_ERR, "no-input-specified");
997
1059
// If parse operation is in progress then reset it
1062
if(currentThread != null) {
1065
fConfiguration.setDocumentHandler(abortHandler);
1066
fConfiguration.setDTDHandler(abortHandler);
1067
fConfiguration.setDTDContentModelHandler(abortHandler);
1069
if(currentThread == Thread.currentThread())
1072
currentThread.interrupt();
1002
1075
return; // If not busy then this is noop
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.
1084
* @param element The name of the element.
1085
* @param attributes The element attributes.
1086
* @param augs Additional information that may include infoset augmentations
1088
* @throws XNIException Thrown by handler to signal an error.
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);
1101
super.startElement(element, attributes, augs);
1104
private class AbortHandler implements XMLDocumentHandler, XMLDTDHandler, XMLDTDContentModelHandler {
1106
private XMLDocumentSource documentSource;
1107
private XMLDTDContentModelSource dtdContentSource;
1108
private XMLDTDSource dtdSource;
1110
public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException {
1114
public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
1118
public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) throws XNIException {
1122
public void comment(XMLString text, Augmentations augs) throws XNIException {
1126
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
1130
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
1134
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
1138
public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs) throws XNIException {
1142
public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
1146
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
1150
public void characters(XMLString text, Augmentations augs) throws XNIException {
1154
public void ignorableWhitespace(XMLString text, Augmentations augs) throws XNIException {
1158
public void endElement(QName element, Augmentations augs) throws XNIException {
1162
public void startCDATA(Augmentations augs) throws XNIException {
1166
public void endCDATA(Augmentations augs) throws XNIException {
1170
public void endDocument(Augmentations augs) throws XNIException {
1174
public void setDocumentSource(XMLDocumentSource source) {
1175
documentSource = source;
1178
public XMLDocumentSource getDocumentSource() {
1179
return documentSource;
1182
public void startDTD(XMLLocator locator, Augmentations augmentations) throws XNIException {
1186
public void startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augmentations) throws XNIException {
1190
public void endParameterEntity(String name, Augmentations augmentations) throws XNIException {
1194
public void startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1198
public void endExternalSubset(Augmentations augmentations) throws XNIException {
1202
public void elementDecl(String name, String contentModel, Augmentations augmentations) throws XNIException {
1206
public void startAttlist(String elementName, Augmentations augmentations) throws XNIException {
1210
public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augmentations) throws XNIException {
1214
public void endAttlist(Augmentations augmentations) throws XNIException {
1218
public void internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augmentations) throws XNIException {
1222
public void externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1226
public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations) throws XNIException {
1230
public void notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) throws XNIException {
1234
public void startConditional(short type, Augmentations augmentations) throws XNIException {
1238
public void ignoredCharacters(XMLString text, Augmentations augmentations) throws XNIException {
1242
public void endConditional(Augmentations augmentations) throws XNIException {
1246
public void endDTD(Augmentations augmentations) throws XNIException {
1250
public void setDTDSource(XMLDTDSource source) {
1254
public XMLDTDSource getDTDSource() {
1258
public void startContentModel(String elementName, Augmentations augmentations) throws XNIException {
1262
public void any(Augmentations augmentations) throws XNIException {
1266
public void empty(Augmentations augmentations) throws XNIException {
1270
public void startGroup(Augmentations augmentations) throws XNIException {
1274
public void pcdata(Augmentations augmentations) throws XNIException {
1278
public void element(String elementName, Augmentations augmentations) throws XNIException {
1282
public void separator(short separator, Augmentations augmentations) throws XNIException {
1286
public void occurrence(short occurrence, Augmentations augmentations) throws XNIException {
1290
public void endGroup(Augmentations augmentations) throws XNIException {
1294
public void endContentModel(Augmentations augmentations) throws XNIException {
1298
public void setDTDContentModelSource(XMLDTDContentModelSource source) {
1299
dtdContentSource = source;
1302
public XMLDTDContentModelSource getDTDContentModelSource() {
1303
return dtdContentSource;
1005
1308
} // class DOMParserImpl