1 /*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 */
4
5 /*
6 * Copyright 2005 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.xerces.internal.impl;
22
23
24 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDDescription;
25 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
26 import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
27 import com.sun.org.apache.xerces.internal.util.XMLChar;
28 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
29 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
30 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
31 import com.sun.org.apache.xerces.internal.xni.Augmentations;
32 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
33 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
34 import com.sun.org.apache.xerces.internal.xni.XNIException;
35 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
36 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
37 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
38 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
39 import com.sun.xml.internal.stream.Entity;
40 import com.sun.xml.internal.stream.StaxXMLInputSource;
41 import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
42 import java.io.EOFException;
43 import java.io.IOException;
1089 do {
1090 again = false;
1091 switch (fScannerState) {
1092 case SCANNER_STATE_DTD_INTERNAL_DECLS: {
1093 boolean moreToScan = false;
1094 if (!fDTDScanner.skipDTD(fSupportDTD)) {
1095 // REVISIT: Should there be a feature for
1096 // the "complete" parameter?
1097 boolean completeDTD = true;
1098
1099 moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
1100 }
1101 Entity entity = fEntityScanner.getCurrentEntity();
1102 if(entity instanceof Entity.ScannedEntity){
1103 fEndPos=((Entity.ScannedEntity)entity).position;
1104 }
1105 fReadingDTD=false;
1106 if (!moreToScan) {
1107 // end doctype declaration
1108 if (!fEntityScanner.skipChar(']')) {
1109 reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
1110 null);
1111 }
1112 fEntityScanner.skipSpaces();
1113 if (!fEntityScanner.skipChar('>')) {
1114 reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
1115 }
1116 fMarkupDepth--;
1117
1118 if (!fSupportDTD) {
1119 //simply reset the entity store without having to mess around
1120 //with the DTD Scanner code
1121 fEntityStore = fEntityManager.getEntityStore();
1122 fEntityStore.reset();
1123 } else {
1124 // scan external subset next unless we are ignoring DTDs
1125 if (fDoctypeSystemId != null && (fValidation || fLoadExternalDTD)) {
1126 setScannerState(SCANNER_STATE_DTD_EXTERNAL);
1127 break;
1128 }
1129 }
1130
|
1 /*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 */
4
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.xerces.internal.impl;
23
24 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDDescription;
25 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
26 import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
27 import com.sun.org.apache.xerces.internal.util.XMLChar;
28 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
29 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
30 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
31 import com.sun.org.apache.xerces.internal.xni.Augmentations;
32 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
33 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
34 import com.sun.org.apache.xerces.internal.xni.XNIException;
35 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
36 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
37 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
38 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
39 import com.sun.xml.internal.stream.Entity;
40 import com.sun.xml.internal.stream.StaxXMLInputSource;
41 import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
42 import java.io.EOFException;
43 import java.io.IOException;
1089 do {
1090 again = false;
1091 switch (fScannerState) {
1092 case SCANNER_STATE_DTD_INTERNAL_DECLS: {
1093 boolean moreToScan = false;
1094 if (!fDTDScanner.skipDTD(fSupportDTD)) {
1095 // REVISIT: Should there be a feature for
1096 // the "complete" parameter?
1097 boolean completeDTD = true;
1098
1099 moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
1100 }
1101 Entity entity = fEntityScanner.getCurrentEntity();
1102 if(entity instanceof Entity.ScannedEntity){
1103 fEndPos=((Entity.ScannedEntity)entity).position;
1104 }
1105 fReadingDTD=false;
1106 if (!moreToScan) {
1107 // end doctype declaration
1108 if (!fEntityScanner.skipChar(']')) {
1109 reportFatalError("DoctypedeclNotClosed", new Object[]{fDoctypeName});
1110 }
1111 fEntityScanner.skipSpaces();
1112 if (!fEntityScanner.skipChar('>')) {
1113 reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
1114 }
1115 fMarkupDepth--;
1116
1117 if (!fSupportDTD) {
1118 //simply reset the entity store without having to mess around
1119 //with the DTD Scanner code
1120 fEntityStore = fEntityManager.getEntityStore();
1121 fEntityStore.reset();
1122 } else {
1123 // scan external subset next unless we are ignoring DTDs
1124 if (fDoctypeSystemId != null && (fValidation || fLoadExternalDTD)) {
1125 setScannerState(SCANNER_STATE_DTD_EXTERNAL);
1126 break;
1127 }
1128 }
1129
|