Class ResolvedResource
- java.lang.Object
-
- org.xmlresolver.ResolvedResource
-
public abstract class ResolvedResource extends java.lang.ObjectA resolved resource represents a successfully resolved resource.While the
XMLCatalogResolverinterface simply maps from request parameters to URIs, the resolver interfaces defined by SAX, DOM, etc. expect open streams to be returned. This abstract class provides the information necessary to support those APIs.The "local" URI is always the URI returned by catalog resolution. The "resolved" URI is almost always the same. They can be different when catalog resolution returns a
jar:orclasspath:URI. Those schemes are not supported by theURIclass in a useful way. This will cause problems if the document returned contains relative URI references. Consider this XSLT stylesheet:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"> <xsl:import href="module.xsl"/> </xsl:stylesheet>Suppose that it is referenced with the URI
http://example.com/xsl/style.xsland the catalog contains this matching entry:<uri name="http://example.com/xsl/style.xsl" uri="classpath:xsl/style.xsl"/>(An explicit
classpath:URI is not the only way for this to arise, if the URI was simply relative to the catalog and the catalog happened to be found with ajar:orclasspath:URI, that would have the same effect.)If
classpath:xsl/style.xslis returned as the resolved URI, the XSLT processor will attempt to resolvemodule.xslagainst that as the base URI. If this is done with just theresolve()method onURI, it won’t work.URIdoesn’t recognizeclasspath:as a relative URI scheme. The situation is even worse withjar:URIs which have a syntax that is possibly not even sanctioned by the relevant RFCs.In this case, the resolver might choose to return
http://example.com/xsl/style.xslas the resolved URI. The XSLT processor will then formhttp://example.com/xsl/module.xslas the URI of the module and, if the catalog author provided an entry for that as well, processing can continue with all of the URIs resolved locally.
-
-
Constructor Summary
Constructors Constructor Description ResolvedResource()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract java.lang.StringgetContentType()The content type of the resource.abstract java.io.InputStreamgetInputStream()The input stream.abstract java.net.URIgetLocalURI()The local URI.abstract java.net.URIgetResolvedURI()The resolved URI.
-
-
-
Method Detail
-
getResolvedURI
public abstract java.net.URI getResolvedURI()
The resolved URI.This is the URI that should be reported as the resolved URI.
- Returns:
- The resolved URI.
-
getLocalURI
public abstract java.net.URI getLocalURI()
The local URI.This is the URI that was used to retrieve the resource (to open the input stream). This is usually, but not necessarily always, the same as the resolved URI.
- Returns:
- The local URI.
-
getInputStream
public abstract java.io.InputStream getInputStream()
The input stream.This is the input stream containing the resolved resource. This may return null, in which case it is the application's responsibily to access the resource through its resolved URI.
- Returns:
- The input stream that will return the content of the resolved resource.
-
getContentType
public abstract java.lang.String getContentType()
The content type of the resource.If the resolver knows the content type of the resource (for example
application/xml), it will be provided here.- Returns:
- The content type, possibly null.
-
-