当前位置: 首页>>代码示例>>Java>>正文


Java URIResolver.resolve方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:45,代码来源:MCRURIResolver.java

示例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;
}
 
开发者ID:phax,项目名称:ph-stx,代码行数:73,代码来源:THTrAXResolver.java


注:本文中的javax.xml.transform.URIResolver.resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。