當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。