Java Code Examples for com.sun.org.apache.xerces.internal.impl.XMLEntityManager#expandSystemId()

The following examples show how to use com.sun.org.apache.xerces.internal.impl.XMLEntityManager#expandSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XIncludeHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 2
Source File: XMLSchemaValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
    int length = locations.length;
    String[] hints = new String[length];
    int counter = 0;

    for (int i=0; i<length; i++) {
        try {
            String id = XMLEntityManager.expandSystemId(locations[i], desc.getBaseSystemId(), false);
            if (!docLocations.contains(id)) {
                hints[counter++] = locations[i];
            }
        }
        catch (MalformedURIException e) {
        }
    }

    if (counter > 0) {
        if (counter == length) {
            fXSDDescription.fLocationHints = hints;
        }
        else {
            fXSDDescription.fLocationHints = new String[counter];
            System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
        }
    }
}
 
Example 3
Source File: XIncludeHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 4
Source File: XMLSchemaValidator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
    int length = locations.length;
    String[] hints = new String[length];
    int counter = 0;

    for (int i=0; i<length; i++) {
        try {
            String id = XMLEntityManager.expandSystemId(locations[i], desc.getBaseSystemId(), false);
            if (!docLocations.contains(id)) {
                hints[counter++] = locations[i];
            }
        }
        catch (MalformedURIException e) {
        }
    }

    if (counter > 0) {
        if (counter == length) {
            fXSDDescription.fLocationHints = hints;
        }
        else {
            fXSDDescription.fLocationHints = new String[counter];
            System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
        }
    }
}
 
Example 5
Source File: XMLSchemaValidator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
    int length = locations.length;
    String[] hints = new String[length];
    int counter = 0;

    for (int i=0; i<length; i++) {
        try {
            String id = XMLEntityManager.expandSystemId(locations[i], desc.getBaseSystemId(), false);
            if (!docLocations.contains(id)) {
                hints[counter++] = locations[i];
            }
        }
        catch (MalformedURIException e) {
        }
    }

    if (counter > 0) {
        if (counter == length) {
            fXSDDescription.fLocationHints = hints;
        }
        else {
            fXSDDescription.fLocationHints = new String[counter];
            System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
        }
    }
}
 
Example 6
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 7
Source File: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 8
Source File: XIncludeHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 9
Source File: XMLSchemaValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void setLocationHints(XSDDescription desc, String[] locations, StringList docLocations) {
    int length = locations.length;
    String[] hints = new String[length];
    int counter = 0;

    for (int i=0; i<length; i++) {
        try {
            String id = XMLEntityManager.expandSystemId(locations[i], desc.getBaseSystemId(), false);
            if (!docLocations.contains(id)) {
                hints[counter++] = locations[i];
            }
        }
        catch (MalformedURIException e) {
        }
    }

    if (counter > 0) {
        if (counter == length) {
            fXSDDescription.fLocationHints = hints;
        }
        else {
            fXSDDescription.fLocationHints = new String[counter];
            System.arraycopy(hints, 0, fXSDDescription.fLocationHints, 0, counter);
        }
    }
}
 
Example 10
Source File: XIncludeHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks if the file indicated by the given XMLLocator has already been included
 * in the current stack.
 * @param includedSource the source to check for inclusion
 * @return true if the source has already been included
 */
protected boolean searchForRecursiveIncludes(XMLLocator includedSource) {
    String includedSystemId = includedSource.getExpandedSystemId();

    if (includedSystemId == null) {
        try {
            includedSystemId =
                XMLEntityManager.expandSystemId(
                    includedSource.getLiteralSystemId(),
                    includedSource.getBaseSystemId(),
                    false);
        }
        catch (MalformedURIException e) {
            reportFatalError("ExpandedSystemId");
        }
    }

    if (includedSystemId.equals(fCurrentBaseURI.getExpandedSystemId())) {
        return true;
    }

    if (fParentXIncludeHandler == null) {
        return false;
    }
    return fParentXIncludeHandler.searchForRecursiveIncludes(
        includedSource);
}
 
Example 11
Source File: XMLInputSourceAdaptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String getSystemId() {
    try {
        return XMLEntityManager.expandSystemId(
                fSource.getSystemId(), fSource.getBaseSystemId(), false);
    } catch (MalformedURIException e) {
        return fSource.getSystemId();
    }
}
 
Example 12
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Checks if the file indicated by the given XMLLocator has already been included
 * in the current stack.
 * @param includedSource the source to check for inclusion
 * @return true if the source has already been included
 */
protected boolean searchForRecursiveIncludes(XMLLocator includedSource) {
    String includedSystemId = includedSource.getExpandedSystemId();

    if (includedSystemId == null) {
        try {
            includedSystemId =
                XMLEntityManager.expandSystemId(
                    includedSource.getLiteralSystemId(),
                    includedSource.getBaseSystemId(),
                    false);
        }
        catch (MalformedURIException e) {
            reportFatalError("ExpandedSystemId");
        }
    }

    if (includedSystemId.equals(fCurrentBaseURI.getExpandedSystemId())) {
        return true;
    }

    if (fParentXIncludeHandler == null) {
        return false;
    }
    return fParentXIncludeHandler.searchForRecursiveIncludes(
        includedSource);
}
 
Example 13
Source File: XMLSchemaLoader.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** This method tries to resolve location of the given schema.
 * The loader stores the namespace/location pairs in a map (use "" as the
 * namespace of absent namespace). When resolving an entity, loader first tries
 * to find in the map whether there is a value for that namespace,
 * if so, pass that location value to the user-defined entity resolver.
 *
 * @param desc
 * @param locationPairs
 * @param entityResolver
 * @return
 * @throws IOException
 */
public static XMLInputSource resolveDocument(XSDDescription desc,
        Map<String, LocationArray> locationPairs,
        XMLEntityResolver entityResolver) throws IOException {
    String loc = null;
    // we consider the schema location properties for import
    if (desc.getContextType() == XSDDescription.CONTEXT_IMPORT ||
            desc.fromInstance()) {
        // use empty string as the key for absent namespace
        String namespace = desc.getTargetNamespace();
        String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
        // get the location hint for that namespace
        LocationArray tempLA = locationPairs.get(ns);
        if(tempLA != null)
            loc = tempLA.getFirstLocation();
    }

    // if it's not import, or if the target namespace is not set
    // in the schema location properties, use location hint
    if (loc == null) {
        String[] hints = desc.getLocationHints();
        if (hints != null && hints.length > 0)
            loc = hints[0];
    }

    String expandedLoc = XMLEntityManager.expandSystemId(loc, desc.getBaseSystemId(), false);
    desc.setLiteralSystemId(loc);
    desc.setExpandedSystemId(expandedLoc);
    return entityResolver.resolveEntity(desc);
}
 
Example 14
Source File: XIncludeHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks if the file indicated by the given XMLLocator has already been included
 * in the current stack.
 * @param includedSource the source to check for inclusion
 * @return true if the source has already been included
 */
protected boolean searchForRecursiveIncludes(XMLLocator includedSource) {
    String includedSystemId = includedSource.getExpandedSystemId();

    if (includedSystemId == null) {
        try {
            includedSystemId =
                XMLEntityManager.expandSystemId(
                    includedSource.getLiteralSystemId(),
                    includedSource.getBaseSystemId(),
                    false);
        }
        catch (MalformedURIException e) {
            reportFatalError("ExpandedSystemId");
        }
    }

    if (includedSystemId.equals(fCurrentBaseURI.getExpandedSystemId())) {
        return true;
    }

    if (fParentXIncludeHandler == null) {
        return false;
    }
    return fParentXIncludeHandler.searchForRecursiveIncludes(
        includedSource);
}
 
Example 15
Source File: XMLDTDLoader.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a Grammar object by parsing the contents of the
 * entity pointed to by source.
 *
 * @param source        the location of the entity which forms
 *                          the starting point of the grammar to be constructed.
 * @throws IOException      When a problem is encountered reading the entity
 *          XNIException    When a condition arises (such as a FatalError) that requires parsing
 *                              of the entity be terminated.
 */
public Grammar loadGrammar(XMLInputSource source)
        throws IOException, XNIException {
    reset();
    // First chance checking strict URI
    String eid = XMLEntityManager.expandSystemId(source.getSystemId(), source.getBaseSystemId(), fStrictURI);
    XMLDTDDescription desc = new XMLDTDDescription(source.getPublicId(), source.getSystemId(), source.getBaseSystemId(), eid, null);
    if (!fBalanceSyntaxTrees) {
        fDTDGrammar = new DTDGrammar(fSymbolTable, desc);
    }
    else {
        fDTDGrammar = new BalancedDTDGrammar(fSymbolTable, desc);
    }
    fGrammarBucket = new DTDGrammarBucket();
    fGrammarBucket.setStandalone(false);
    fGrammarBucket.setActiveGrammar(fDTDGrammar);
    // no reason to use grammar bucket's "put" method--we
    // know which grammar it is, and we don't know the root name anyway...

    // actually start the parsing!
    try {
        fDTDScanner.setInputSource(source);
        fDTDScanner.scanDTDExternalSubset(true);
    } catch (EOFException e) {
        // expected behaviour...
    }
    finally {
        // Close all streams opened by the parser.
        fEntityManager.closeReaders();
    }
    if(fDTDGrammar != null && fGrammarPool != null) {
        fGrammarPool.cacheGrammars(XMLDTDDescription.XML_DTD, new Grammar[] {fDTDGrammar});
    }
    return fDTDGrammar;
}
 
Example 16
Source File: ValidatorHandlerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Resolves a system identifier against a base URI. */
private String resolveSystemId(String systemId, String baseURI) {
    try {
        return XMLEntityManager.expandSystemId(systemId, baseURI, false);
    }
    // In the event that resolution failed against the
    // base URI, just return the system id as is. There's not
    // much else we can do.
    catch (URI.MalformedURIException ex) {
        return systemId;
    }
}
 
Example 17
Source File: XMLDTDValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Notifies of the presence of the DOCTYPE line in the document.
 *
 * @param rootElement The name of the root element.
 * @param publicId    The public identifier if an external DTD or null
 *                    if the external DTD is specified using SYSTEM.
 * @param systemId    The system identifier if an external DTD, null
 *                    otherwise.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void doctypeDecl(String rootElement, String publicId, String systemId,
                        Augmentations augs)
throws XNIException {

    // save root element state
    fSeenDoctypeDecl = true;
    fRootElement.setValues(null, rootElement, rootElement, null);
    // find or create grammar:
    String eid = null;
    try {
        eid = XMLEntityManager.expandSystemId(systemId, fDocLocation.getExpandedSystemId(), false);
    } catch (java.io.IOException e) {
    }
    XMLDTDDescription grammarDesc = new XMLDTDDescription(publicId, systemId, fDocLocation.getExpandedSystemId(), eid, rootElement);
    fDTDGrammar = fGrammarBucket.getGrammar(grammarDesc);
    if(fDTDGrammar == null) {
        // give grammar pool a chance...
        //
        // Do not bother checking the pool if no public or system identifier was provided.
        // Since so many different DTDs have roots in common, using only a root name as the
        // key may cause an unexpected grammar to be retrieved from the grammar pool. This scenario
        // would occur when an ExternalSubsetResolver has been queried and the
        // XMLInputSource returned contains an input stream but no external identifier.
        // This can never happen when the instance document specified a DOCTYPE. -- mrglavas
        if (fGrammarPool != null && (systemId != null || publicId != null)) {
            fDTDGrammar = (DTDGrammar)fGrammarPool.retrieveGrammar(grammarDesc);
        }
    }
    if(fDTDGrammar == null) {
        // we'll have to create it...
        if (!fBalanceSyntaxTrees) {
            fDTDGrammar = new DTDGrammar(fSymbolTable, grammarDesc);
        }
        else {
            fDTDGrammar = new BalancedDTDGrammar(fSymbolTable, grammarDesc);
        }
    } else {
        // we've found a cached one;so let's make sure not to read
        // any external subset!
        fValidationManager.setCachedDTD(true);
    }
    fGrammarBucket.setActiveGrammar(fDTDGrammar);

    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.doctypeDecl(rootElement, publicId, systemId, augs);
    }

}
 
Example 18
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * getSchemaDocument method uses XMLInputSource to parse a schema document.
 * @param schemaNamespace
 * @param schemaSource
 * @param mustResolve
 * @param referType
 * @param referElement
 * @return A schema Element.
 */
private Element getSchemaDocument(String schemaNamespace, XMLInputSource schemaSource,
        boolean mustResolve, short referType, Element referElement) {

    boolean hasInput = true;
    IOException exception = null;
    // contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
    Element schemaElement = null;
    try {
        // when the system id and byte stream and character stream
        // of the input source are all null, it's
        // impossible to find the schema document. so we skip in
        // this case. otherwise we'll receive some NPE or
        // file not found errors. but schemaHint=="" is perfectly
        // legal for import.
        if (schemaSource != null &&
                (schemaSource.getSystemId() != null ||
                        schemaSource.getByteStream() != null ||
                        schemaSource.getCharacterStream() != null)) {

            // When the system id of the input source is used, first try to
            // expand it, and check whether the same document has been
            // parsed before. If so, return the document corresponding to
            // that system id.
            XSDKey key = null;
            String schemaId = null;
            if (referType != XSDDescription.CONTEXT_PREPARSE){
                schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
                key = new XSDKey(schemaId, referType, schemaNamespace);
                if((schemaElement = fTraversed.get(key)) != null) {
                    fLastSchemaWasDuplicate = true;
                    return schemaElement;
                }
                if (referType == XSDDescription.CONTEXT_IMPORT || referType == XSDDescription.CONTEXT_INCLUDE
                        || referType == XSDDescription.CONTEXT_REDEFINE) {
                    String accessError = SecuritySupport.checkAccess(schemaId, fAccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
                    if (accessError != null) {
                        reportSchemaFatalError("schema_reference.access",
                                new Object[] { SecuritySupport.sanitizePath(schemaId), accessError },
                                referElement);
                    }
                }
            }

            fSchemaParser.parse(schemaSource);
            Document schemaDocument = fSchemaParser.getDocument();
            schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
            return getSchemaDocument0(key, schemaId, schemaElement);
        }
        else {
            hasInput = false;
        }
    }
    catch (IOException ex) {
        exception = ex;
    }
    return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
}
 
Example 19
Source File: XMLDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Notifies of the presence of the DOCTYPE line in the document.
 *
 * @param rootElement The name of the root element.
 * @param publicId    The public identifier if an external DTD or null
 *                    if the external DTD is specified using SYSTEM.
 * @param systemId    The system identifier if an external DTD, null
 *                    otherwise.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void doctypeDecl(String rootElement, String publicId, String systemId,
                        Augmentations augs)
throws XNIException {

    // save root element state
    fSeenDoctypeDecl = true;
    fRootElement.setValues(null, rootElement, rootElement, null);
    // find or create grammar:
    String eid = null;
    try {
        eid = XMLEntityManager.expandSystemId(systemId, fDocLocation.getExpandedSystemId(), false);
    } catch (java.io.IOException e) {
    }
    XMLDTDDescription grammarDesc = new XMLDTDDescription(publicId, systemId, fDocLocation.getExpandedSystemId(), eid, rootElement);
    fDTDGrammar = fGrammarBucket.getGrammar(grammarDesc);
    if(fDTDGrammar == null) {
        // give grammar pool a chance...
        //
        // Do not bother checking the pool if no public or system identifier was provided.
        // Since so many different DTDs have roots in common, using only a root name as the
        // key may cause an unexpected grammar to be retrieved from the grammar pool. This scenario
        // would occur when an ExternalSubsetResolver has been queried and the
        // XMLInputSource returned contains an input stream but no external identifier.
        // This can never happen when the instance document specified a DOCTYPE. -- mrglavas
        if (fGrammarPool != null && (systemId != null || publicId != null)) {
            fDTDGrammar = (DTDGrammar)fGrammarPool.retrieveGrammar(grammarDesc);
        }
    }
    if(fDTDGrammar == null) {
        // we'll have to create it...
        if (!fBalanceSyntaxTrees) {
            fDTDGrammar = new DTDGrammar(fSymbolTable, grammarDesc);
        }
        else {
            fDTDGrammar = new BalancedDTDGrammar(fSymbolTable, grammarDesc);
        }
    } else {
        // we've found a cached one;so let's make sure not to read
        // any external subset!
        fValidationManager.setCachedDTD(true);
    }
    fGrammarBucket.setActiveGrammar(fDTDGrammar);

    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.doctypeDecl(rootElement, publicId, systemId, augs);
    }

}
 
Example 20
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * getSchemaDocument method uses XMLInputSource to parse a schema document.
 * @param schemaNamespace
 * @param schemaSource
 * @param mustResolve
 * @param referType
 * @param referElement
 * @return A schema Element.
 */
private Element getSchemaDocument(String schemaNamespace, XMLInputSource schemaSource,
        boolean mustResolve, short referType, Element referElement) {

    boolean hasInput = true;
    IOException exception = null;
    // contents of this method will depend on the system we adopt for entity resolution--i.e., XMLEntityHandler, EntityHandler, etc.
    Element schemaElement = null;
    try {
        // when the system id and byte stream and character stream
        // of the input source are all null, it's
        // impossible to find the schema document. so we skip in
        // this case. otherwise we'll receive some NPE or
        // file not found errors. but schemaHint=="" is perfectly
        // legal for import.
        if (schemaSource != null &&
                (schemaSource.getSystemId() != null ||
                        schemaSource.getByteStream() != null ||
                        schemaSource.getCharacterStream() != null)) {

            // When the system id of the input source is used, first try to
            // expand it, and check whether the same document has been
            // parsed before. If so, return the document corresponding to
            // that system id.
            XSDKey key = null;
            String schemaId = null;
            if (referType != XSDDescription.CONTEXT_PREPARSE){
                schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
                key = new XSDKey(schemaId, referType, schemaNamespace);
                if((schemaElement = (Element)fTraversed.get(key)) != null) {
                    fLastSchemaWasDuplicate = true;
                    return schemaElement;
                }
                if (referType == XSDDescription.CONTEXT_IMPORT || referType == XSDDescription.CONTEXT_INCLUDE
                        || referType == XSDDescription.CONTEXT_REDEFINE) {
                    String accessError = SecuritySupport.checkAccess(schemaId, fAccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
                    if (accessError != null) {
                        reportSchemaFatalError("schema_reference.access",
                                new Object[] { SecuritySupport.sanitizePath(schemaId), accessError },
                                referElement);
                    }
                }
            }

            fSchemaParser.parse(schemaSource);
            Document schemaDocument = fSchemaParser.getDocument();
            schemaElement = schemaDocument != null ? DOMUtil.getRoot(schemaDocument) : null;
            return getSchemaDocument0(key, schemaId, schemaElement);
        }
        else {
            hasInput = false;
        }
    }
    catch (IOException ex) {
        exception = ex;
    }
    return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
}