Java Code Examples for org.apache.xerces.xni.XMLResourceIdentifier#getNamespace()

The following examples show how to use org.apache.xerces.xni.XMLResourceIdentifier#getNamespace() . 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: XMLCatalogURIResolverExtension.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
	if (hasDTDorXMLSchema(resourceIdentifier.getBaseSystemId())) {
		return null;
	}
	String publicId = resourceIdentifier.getNamespace();
	if (CATALOG_NAMESPACE_URI.equals(publicId)) {
		return new XMLInputSource(publicId, CATALOG_SYSTEM, CATALOG_SYSTEM);
	}
	return null;
}
 
Example 2
Source File: XSDURIResolverExtension.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
	String publicId = resourceIdentifier.getNamespace();
	if (SCHEMA_FOR_SCHEMA_URI_2001.equals(publicId) || SCHEMA_FOR_NAMESPACE_URI_1998.equals(publicId)) {
		String baseLocation = resourceIdentifier.getBaseSystemId();
		String xslFilePath = resolve(baseLocation, publicId, null);
		if (xslFilePath != null) {
			return new XMLInputSource(publicId, xslFilePath, xslFilePath);
		}
	}
	return null;
}
 
Example 3
Source File: XSLURIResolverExtension.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
	String publicId = resourceIdentifier.getNamespace();
	if (XSL_NAMESPACE_URI.equals(publicId)) {
		String baseLocation = resourceIdentifier.getBaseSystemId();
		String xslFilePath = resolve(baseLocation, publicId, null);
		if (xslFilePath != null) {
			return new XMLInputSource(publicId, xslFilePath, xslFilePath);
		}
	}
	return null;
}
 
Example 4
Source File: ClassLoaderXmlEntityResolver.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
	if (log.isDebugEnabled()) log.debug("resolveEntity publicId ["+resourceIdentifier.getPublicId()+"] baseSystemId ["+resourceIdentifier.getBaseSystemId()+"] expandedSystemId ["+resourceIdentifier.getExpandedSystemId()+"] literalSystemId ["+resourceIdentifier.getLiteralSystemId()+"] namespace ["+resourceIdentifier.getNamespace()+"]");
	if (resourceIdentifier.getBaseSystemId() == null
			&& resourceIdentifier.getExpandedSystemId() == null
			&& resourceIdentifier.getLiteralSystemId() == null
			&& resourceIdentifier.getNamespace() == null
			&& resourceIdentifier.getPublicId() == null) {
		// This seems to happen sometimes. For example with import of
		// sub01a.xsd and sub05.xsd without namespace in
		// /XmlValidator/import_include/root.xsd of Ibis4TestIAF. The
		// default resolve entity implementation seems to ignore it, hence
		// return null.
		return null;
	}
	
	String base = resourceIdentifier.getBaseSystemId();
	String href = resourceIdentifier.getLiteralSystemId();
	if (href == null) {
		// Ignore import with namespace but without schemaLocation
		return null;
	}

	Resource resource;
	try {
		resource = resolveToResource(href, base);
	} catch (TransformerException e) {
		throw new XNIException(e);
	}

	
	InputStream inputStream = resource.getURL().openStream();
	return new XMLInputSource(null, resource.getSystemId(), null, inputStream, null);
}