Java Code Examples for org.w3c.dom.ls.LSResourceResolver#resolveResource()

The following examples show how to use org.w3c.dom.ls.LSResourceResolver#resolveResource() . 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: WSDLSchemaValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    LSInput input = null;
    
    Iterator<ValidatorSchemaFactory> it = mExtSchemaFactories.iterator();
    while(it.hasNext()) {
        ValidatorSchemaFactory fac = it.next();
        LSResourceResolver resolver = fac.getLSResourceResolver();
        if(resolver != null) {
            input = resolver.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
            if(input != null) {
               break;
            }
        }
    }
    
    return input;
}
 
Example 2
Source File: SimpleLSResourceResolverTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testOSGIBundle () throws BundleException
{
  LSInput aRes;

  // Initializing Apache Felix as OSGI container is required to get the
  // "bundle" URL protocol installed correctly
  // Otherwise the first call would end up as a "file" resource ;-)
  final Framework aOSGI = new FrameworkFactory ().newFramework (new HashMap <String, String> ());
  aOSGI.start ();
  try
  {
    // Bundle 0 is the org.apache.felix.framework bundle
    final Bundle b = aOSGI.getBundleContext ().getBundle (0);
    assertNotNull (b);
    assertEquals (Bundle.ACTIVE, b.getState ());

    // No leading slash is important as the ClassLoader is used!
    assertNotNull (b.getResource ("org/apache/felix/framework/util/Util.class"));

    final LSResourceResolver aRR = new SimpleLSResourceResolver ();

    // No class loader
    aRes = aRR.resolveResource (XMLConstants.W3C_XML_SCHEMA_NS_URI,
                                null,
                                null,
                                "../Felix.class",
                                "bundle://0.0:1/org/apache/felix/framework/util/Util.class");
    assertTrue (aRes instanceof ResourceLSInput);
    final IHasInputStream aISP = ((ResourceLSInput) aRes).getInputStreamProvider ();
    assertTrue (aISP instanceof URLResource);
    // Path maybe a "jar:file:" resource
    assertTrue (((URLResource) aISP).getPath ().endsWith ("org/apache/felix/framework/Felix.class"));
  }
  finally
  {
    aOSGI.stop ();
  }
}
 
Example 3
Source File: CompoundLSResourceResolver.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
    * @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    */
   public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
for (LSResourceResolver resolver: resolvers) {
    LSInput input = resolver.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
    if (input != null) {
	return input;
    }
}
return null;
   }