changeset 802:686f3a3e49ac

8130078: Document better processing Reviewed-by: dfuchs, lancea, ahgross
author joehw
date Tue, 07 Jul 2015 16:57:55 -0700
parents 5f2ff10c2974
children 198a7fd9ec1f
files src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java
diffstat 3 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Tue Jul 07 15:56:38 2015 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java	Tue Jul 07 16:57:55 2015 -0700
@@ -379,6 +379,26 @@
 
     } // scanDTDInternalSubset(boolean,boolean,boolean):boolean
 
+    /**
+     * Skip the DTD if javax.xml.stream.supportDTD is false.
+     *
+     * @param supportDTD The value of the property javax.xml.stream.supportDTD.
+     * @return true if DTD is skipped, false otherwise.
+     * @throws java.io.IOException if i/o error occurs
+     */
+    @Override
+    public boolean skipDTD(boolean supportDTD) throws IOException {
+        if (!supportDTD) {
+            fStringBuffer.clear();
+            if (!fEntityScanner.scanData("]", fStringBuffer)) {
+                fEntityScanner.fCurrentEntity.position--;
+            }
+
+            return true;
+        }
+        return false;
+    }
+
     //
     // XMLComponent methods
     //
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Tue Jul 07 15:56:38 2015 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java	Tue Jul 07 16:57:55 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -1095,11 +1095,14 @@
                     again = false;
                     switch (fScannerState) {
                         case SCANNER_STATE_DTD_INTERNAL_DECLS: {
-                            // REVISIT: Should there be a feature for
-                            //          the "complete" parameter?
-                            boolean completeDTD = true;
+                            boolean moreToScan = false;
+                            if (!fDTDScanner.skipDTD(fSupportDTD)) {
+                                // REVISIT: Should there be a feature for
+                                //          the "complete" parameter?
+                                boolean completeDTD = true;
 
-                            boolean moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
+                                moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
+                            }
                             Entity entity = fEntityScanner.getCurrentEntity();
                             if(entity instanceof Entity.ScannedEntity){
                                 fEndPos=((Entity.ScannedEntity)entity).position;
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java	Tue Jul 07 15:56:38 2015 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xni/parser/XMLDTDScanner.java	Tue Jul 07 16:57:55 2015 -0700
@@ -96,5 +96,14 @@
     public boolean scanDTDExternalSubset(boolean complete)
         throws IOException, XNIException;
 
+    /**
+     * Skip the DTD if javax.xml.stream.supportDTD is false.
+     * @param supportDTD The value of the property javax.xml.stream.supportDTD.
+     * @return true if DTD is skipped, false otherwise.
+     * @throws java.io.IOException if i/o error occurs
+     */
+    public boolean skipDTD(boolean supportDTD)
+        throws IOException;
+
     public void setLimitAnalyzer(XMLLimitAnalyzer limitAnalyzer);
 } // interface XMLDTDScanner