FileDocCategorySizeDatePackage
ServletURIResolver.javaAPI DocExample2627Mon Jul 23 13:26:44 BST 2007org.apache.struts2.views.xslt

ServletURIResolver

public class ServletURIResolver extends Object implements URIResolver
ServletURIResolver is a URIResolver that can retrieve resources from the servlet context using the scheme "response". e.g. A URI resolver is called when a stylesheet uses an xsl:include, xsl:import, or document() function to find the resource (file).

Fields Summary
private Log
log
static final String
PROTOCOL
private ServletContext
sc
Constructors Summary
public ServletURIResolver(ServletContext sc)


       
        log.trace("ServletURIResolver: " + sc);
        this.sc = sc;
    
Methods Summary
public javax.xml.transform.Sourceresolve(java.lang.String href, java.lang.String base)

        log.debug("ServletURIResolver resolve(): href=" + href + ", base=" + base);
        if (href.startsWith(PROTOCOL)) {
            String res = href.substring(PROTOCOL.length());
            log.debug("Resolving resource <" + res + ">");

            InputStream is = sc.getResourceAsStream(res);

            if (is == null) {
                throw new TransformerException(
                        "Resource " + res + " not found in resources.");
            }

            return new StreamSource(is);
        }

        throw new TransformerException(
                "Cannot handle procotol of resource " + href);