本文整理汇总了Java中org.w3c.dom.ls.LSResourceResolver.resolveResource方法的典型用法代码示例。如果您正苦于以下问题:Java LSResourceResolver.resolveResource方法的具体用法?Java LSResourceResolver.resolveResource怎么用?Java LSResourceResolver.resolveResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.ls.LSResourceResolver
的用法示例。
在下文中一共展示了LSResourceResolver.resolveResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveResource
import org.w3c.dom.ls.LSResourceResolver; //导入方法依赖的package包/类
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;
}
示例2: resolveResource
import org.w3c.dom.ls.LSResourceResolver; //导入方法依赖的package包/类
/**
* @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;
}
示例3: testOSGIBundle
import org.w3c.dom.ls.LSResourceResolver; //导入方法依赖的package包/类
@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 (b.getState (), Bundle.ACTIVE);
// No leading slash is important as the ClassLoader is used!
assertNotNull (b.getResource ("org/apache/felix/framework/util/Mutex.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/Mutex.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 ();
}
}
示例4: createResolver
import org.w3c.dom.ls.LSResourceResolver; //导入方法依赖的package包/类
public static Resolver createResolver(final LSResourceResolver resourceResolver) {
return new AbstractResolver() {
public void resolve(Identifier id, Input input) throws IOException, ResolverException {
if (input.isResolved())
return;
String base = id.getBase();
String publicId = null;
String type = null;
if (id instanceof ExternalIdentifier) {
publicId = ((ExternalIdentifier)id).getPublicId();
type = XML_TYPE;
}
else if (id instanceof XMLDocumentIdentifier)
type = ((XMLDocumentIdentifier)id).getNamespaceUri();
if (type == null) {
String mediaType = id.getMediaType();
if (mediaType.indexOf('*') < 0)
type = IANA_MEDIA_TYPE_URI + mediaType;
}
String targetNamespace = null;
if (id instanceof TargetNamespaceIdentifier)
targetNamespace = ((TargetNamespaceIdentifier)id).getTargetNamespace();
LSInput lsInput = resourceResolver.resolveResource(type, targetNamespace, publicId, id.getUriReference(), base);
if (lsInput == null)
return;
input.setEncoding(lsInput.getEncoding());
input.setUri(lsInput.getSystemId());
final Reader characterStream = lsInput.getCharacterStream();
if (characterStream != null) {
input.setCharacterStream(characterStream);
return;
}
final InputStream byteStream = lsInput.getByteStream();
if (byteStream != null) {
input.setByteStream(byteStream);
return;
}
final String stringData = lsInput.getStringData();
if (stringData != null) {
input.setCharacterStream(new StringReader(stringData));
return;
}
// we don't support redirecting to a public ID
}
};
}