8190227: Forward port 8188880 to JDK10CPU

Reviewed-by: dfuchs, lancea, rriggs
This commit is contained in:
Joe Wang 2017-10-31 11:35:15 -07:00
parent 54d482220b
commit 8ea00aed64
2 changed files with 12 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
import com.sun.org.apache.xerces.internal.util.SAXLocatorWrapper;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
import com.sun.org.apache.xerces.internal.xni.QName;
@ -78,6 +79,7 @@ final class SchemaContentHandler implements ContentHandler {
private final QName fAttributeQName = new QName();
private final XMLAttributesImpl fAttributes = new XMLAttributesImpl();
private final XMLString fTempString = new XMLString();
private final XMLStringBuffer fStringBuffer = new XMLStringBuffer();
/**
* <p>Constructs an SchemaContentHandler.</p>
@ -103,6 +105,7 @@ final class SchemaContentHandler implements ContentHandler {
*/
public void startDocument() throws SAXException {
fNeedPushNSContext = true;
fNamespaceContext.reset();
try {
fSchemaDOMParser.startDocument(fSAXLocatorWrapper, null, fNamespaceContext, null);
}
@ -326,7 +329,11 @@ final class SchemaContentHandler implements ContentHandler {
if (nsPrefix.length() > 0) {
prefix = XMLSymbols.PREFIX_XMLNS;
localpart = nsPrefix;
rawname = fSymbolTable.addSymbol(prefix + ":" + localpart);
fStringBuffer.clear();
fStringBuffer.append(prefix);
fStringBuffer.append(':');
fStringBuffer.append(localpart);
rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
}
else {
prefix = XMLSymbols.EMPTY_STRING;
@ -334,7 +341,8 @@ final class SchemaContentHandler implements ContentHandler {
rawname = XMLSymbols.PREFIX_XMLNS;
}
fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, nsURI);
fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol,
(nsURI != null) ? nsURI : XMLSymbols.EMPTY_STRING);
}
}

View File

@ -2266,6 +2266,8 @@ public class XSDHandler {
fSecurityManager.isSecureProcessing());
try {
parser.setFeature(NAMESPACE_PREFIXES, true);
namespacePrefixes = true;
// If this is a Xerces SAX parser set the security manager if there is one
if (parser instanceof SAXParser) {
if (fSecurityManager != null) {