private XSDSchema getSchema(String publicName, String schemaURIString) {
    XSDSchema xsdSchema = null;
    try {
      String schemaLocation = DocumentCache.getInstance().getLocation(publicName, schemaURIString);
      schemaLocation = FileUtils.addProtocol(schemaLocation);
      ResourceSet resourceSet = new ResourceSetImpl();

      XSDResourceFactoryImpl resourceFactoryImpl = new XSDResourceFactoryImpl();
      Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", resourceFactoryImpl);
      Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(null, resourceFactoryImpl);

      resourceSet.getAdapterFactories().add(new XSDSchemaLocatorAdapterFactory());

      URI uri = createURI(schemaURIString);

      InputStream inputStream =
          resourceSet.getURIConverter().createInputStream(URI.createURI(schemaLocation));
      XSDResourceImpl resource =
          (XSDResourceImpl) resourceSet.createResource(URI.createURI("*.xsd"));
      resource.setURI(uri);
      resource.load(inputStream, null);
      xsdSchema = resource.getSchema();
    } catch (Exception e) {
      XMLEditorPlugin.logErrorMessage(
          "Error retrieving Schema for publicName: "
              + publicName
              + " schemaURIString: "
              + schemaURIString,
          e);
    }

    return xsdSchema;
  }
  /**
   * Walk through all XSDDirectives for the specified XSDResource and attempt to resolve those that
   * are undefined.
   *
   * @param eResource
   * @param recurse
   * @param visited
   * @since 4.3
   */
  protected void resolveSchemaDirectives(
      final XSDResourceImpl eResource,
      final boolean recurse,
      final Set visited,
      final Set unresolvedResourceURIs) {

    if (eResource != null && !visited.contains(eResource)) {
      // The resource must be loaded to retrieve its contents
      if (!eResource.isLoaded()) {
        try {
          eResource.load(getContainer().getLoadOptions());
        } catch (IOException err) {
          String msg =
              ModelerCore.Util.getString(
                  "DefaultResourceFinder.Error_loading_resource", eResource); // $NON-NLS-1$
          ModelerCore.Util.log(IStatus.ERROR, msg);
        }
      }
      // Add this resource to the list of those visited
      visited.add(eResource);

      // Check all imports to see if they were resolved
      for (final Iterator i = eResource.getSchema().eContents().iterator(); i.hasNext(); ) {
        EObject eObj = (EObject) i.next();
        if (eObj instanceof XSDSchemaDirective) {
          XSDSchema resolvedSchema = resolveSchemaDirective((XSDSchemaDirective) eObj);

          // Log any unresolved schema directives
          if (resolvedSchema == null
              || resolvedSchema.eResource() == null
              || resolvedSchema.eResource().getResourceSet() == null) {
            URI unresolvedURI = URI.createURI(((XSDSchemaDirective) eObj).getSchemaLocation());
            unresolvedResourceURIs.add(unresolvedURI);
            continue;
          }

          // Follow the chain and resolve all directives for the schema being imported
          if (recurse)
            resolveSchemaDirectives(
                (XSDResourceImpl) resolvedSchema.eResource(),
                recurse,
                visited,
                unresolvedResourceURIs);
        }
      }
    }
  }