Author: mrglavas
Date: Wed Jul  3 18:29:43 2013
New Revision: 1499506

URL: http://svn.apache.org/r1499506
Log:
The only legal names in XML 1.0/1.1 documents are 'version', 'encoding' and 
'standalone'. Replacing the generic call to the scanner with a specialized 
method which only allows these legal XML pseudo attribute names. This improves 
the performance of the XML scanner when it is processing the XML declaration.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/XMLScanner.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/XMLScanner.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLScanner.java?rev=1499506&r1=1499505&r2=1499506&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/XMLScanner.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/XMLScanner.java Wed Jul  3 
18:29:43 2013
@@ -542,7 +542,7 @@ public abstract class XMLScanner 
         // document is until we scan the encoding declaration
         // you cannot reliably read any characters outside
         // of the ASCII range here. -- mrglavas
-        String name = fEntityScanner.scanName();
+        String name = scanPseudoAttributeName();
         XMLEntityManager.print(fEntityManager.getCurrentEntity());
         if (name == null) {
             reportFatalError("PseudoAttrNameExpected", null);
@@ -599,6 +599,35 @@ public abstract class XMLScanner 
     } // scanPseudoAttribute(XMLString):String
     
     /**
+     * Scans the name of a pseudo attribute. The only legal names
+     * in XML 1.0/1.1 documents are 'version', 'encoding' and 'standalone'.
+     * 
+     * @return the name of the pseudo attribute or <code>null</code>
+     * if a legal pseudo attribute name could not be scanned.
+     */
+    private String scanPseudoAttributeName() throws IOException, XNIException {
+        final int ch = fEntityScanner.peekChar();
+        switch (ch) {
+            case 'v':
+                if (fEntityScanner.skipString(fVersionSymbol)) {
+                    return fVersionSymbol;
+                }
+                break;
+            case 'e':
+                if (fEntityScanner.skipString(fEncodingSymbol)) {
+                    return fEncodingSymbol;
+                }
+                break;
+            case 's':
+                if (fEntityScanner.skipString(fStandaloneSymbol)) {
+                    return fStandaloneSymbol;
+                }
+                break;
+        }
+        return null;
+    } // scanPseudoAttributeName()
+    
+    /**
      * Scans a processing instruction.
      * <p>
      * <pre>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to