A repository of notes and comments that will
eventually make their way into the documentation. Please
treat the information here with caution, it has often not been
verified.
With an URIResolver is that you can create a catalog or
map configuration that matchs an ID with the actual URI. So you use the id
xml:hoo in you document("xml:hoo") and you set the URIResolver to return the
resource id'd in the catalog. You can also ensure that non-inhouse developed XSL
are coming from a place that you specify.
<catalog>
<file id="xml:hoo" uri="http://hoo.com/boo/hoo.xml"/>
</catalog>
|
you set the URIResolver like:
TransformerFactory factory = TransformerFactory.newInstance();
factory.setURIResolver(new MyURIResolver(args));
|
here is a simple URIResolver:
import java.io.*;
import java.util.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
class MyURIResolver implements URIResolver {
private MyObj obj;
public MyURIResolver(MyObj obj) {
this.obj = obj;
}
public Source resolve(String href,String base) {
System.out.println("href: " + href);
System.out.println("base: " + base);
if (href.equals("xml:hoo")) {
return new StreamSource((File)this.obj.getResolvedFile(href));
}
return null;
}
}
|
(Thanks to Robert Koberg)