本文整理汇总了Java中javax.xml.transform.URIResolver.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java URIResolver.resolve方法的具体用法?Java URIResolver.resolve怎么用?Java URIResolver.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.transform.URIResolver
的用法示例。
在下文中一共展示了URIResolver.resolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import javax.xml.transform.URIResolver; //导入方法依赖的package包/类
/**
* URI Resolver that resolves XSL document() or xsl:include calls.
*
* @see javax.xml.transform.URIResolver
*/
public Source resolve(String href, String base) throws TransformerException {
if (LOGGER.isDebugEnabled()) {
if (base != null) {
LOGGER.debug("Including {} from {}", href, base);
addDebugInfo(href, base);
} else {
LOGGER.debug("Including {}", href);
addDebugInfo(href, null);
}
}
if (!href.contains(":")) {
return tryResolveXSL(href, base);
}
String scheme = getScheme(href, base);
URIResolver uriResolver = SUPPORTED_SCHEMES.get(scheme);
if (uriResolver != null) {
return uriResolver.resolve(href, base);
} else { // try to handle as URL, use default resolver for file:// and
try {
InputSource entity = MCREntityResolver.instance().resolveEntity(null, href);
if (entity != null) {
LOGGER.debug("Resolved via EntityResolver: {}", entity.getSystemId());
return new MCRLazyStreamSource(entity::getByteStream, entity.getSystemId());
}
} catch (SAXException | IOException e) {
LOGGER.debug("Error while resolving uri: {}", href);
}
// http://
if (href.endsWith("/") && scheme.equals("file")) {
//cannot stream directories
return null;
}
StreamSource streamSource = new StreamSource();
streamSource.setSystemId(href);
return streamSource;
}
}
示例2: resolve
import javax.xml.transform.URIResolver; //导入方法依赖的package包/类
public TransformerHandler resolve (final String method,
final String href,
final String base,
final URIResolver uriResolver,
final ErrorListener errorListener,
final Hashtable <String, Object> params) throws SAXException
{
if (!available (method))
throw new SAXException ("Not supported filter-method:" + method);
if (CSTX.DEBUG)
log.debug ("resolve(url): href=" + href + ", base=" + base);
if (href == null)
throw new SAXException ("method-src must be url() or buffer()");
setFilterAttributes (params);
TransformerHandler th = null;
// reuse th if available
th = getReusableHrefTH (method, href);
// new transformer if non available
if (th == null)
{
// prepare the source
Source source = null;
try
{
// use custom URIResolver if present
if (uriResolver != null)
{
source = uriResolver.resolve (href, base);
}
if (source == null)
{
if (HREF_IS_SYSTEM_ID.booleanValue ())
{
// systemId
if (CSTX.DEBUG)
log.debug ("resolve(url): new source out of systemId='" + href + "'");
source = new StreamSource (href);
}
else
{
// file
final String url = new URL (new URL (base), href).toExternalForm ();
if (CSTX.DEBUG)
log.debug ("resolve(url): new source out of file='" + url + "'");
source = new StreamSource (url);
}
}
}
catch (final MalformedURLException muex)
{
throw new SAXException (muex);
}
catch (final TransformerException tex)
{
throw new SAXException (tex);
}
th = newTHOutOfTrAX (method, source, params, errorListener, uriResolver);
// cache the instance if required
cacheHrefTH (method, href, th);
}
prepareTh (th, params);
return th;
}