Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
261
The javax.xml.transform.URIResolver Class
Members
Signature
Public methods
Source
resolve(String
href, String base)
Overview
This is
the interface responsible for URI resolution, and is analogous to the SAX
EntityResolver interface. This interface allows URIs found in XML constructs
like xsl:import and xsl:include to be handled. It has only one method
resolve(), which returns javax.xml.transform.Source. You can
instructtransformer to search for the specified document in various locations
when a particular URI is encountered. For example, when an include of the URI http://www.topxml.com/header.xsl is
encountered, you might instead return the local document Localheader.xsl and
prevent the need for network access.
Method Overviews
The only method in this interface
is resolve(String href,String base). This method is called by the processor
when it encounters an xsl:include, xsl:import, or document() function.
Example of how to use resolve(String href,String base)
Your main stylesheet contains <xsl:include
href="http://www.topxml.com/header.xsl"/>. During processing, when
it encounters this href, you want to use your local stylesheet. “Localheading.xsl”.
source = new
StreamSource("E:\\topxml\\Localheading.xsl");
return source;
}
if(source == null)
{
source = new
StreamSource("E:\\topxml\\Default.xsl");
}
return source;
}
The above method first compares
the href. If it matches your criteria, then it creates a new source so your
transformer uses this source in stead of http://www.topxml.com/header.xsl .
URIResolverImpl uriResolver = new
URIResolverImpl(); //This class implements URIResolver.