Skip to content

Commit

Permalink
The only legal names in XML 1.0/1.1 documents are 'version', 'encodin…
Browse files Browse the repository at this point in the history
…g' 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.

git-svn-id: https://svn.apache.org/repos/asf/xerces/java/trunk@1499506 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Michael Glavassevich committed Jul 3, 2013
1 parent f4fe82e commit 266e837
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/org/apache/xerces/impl/XMLScanner.java
Expand Up @@ -542,7 +542,7 @@ public String scanPseudoAttribute(boolean scanningTextDecl,
// 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);
Expand Down Expand Up @@ -598,6 +598,35 @@ else if (isInvalidLiteral(c)) {

} // 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>
Expand Down

0 comments on commit 266e837

Please sign in to comment.