I\'m working on addition internationalization to my XSL. I\'ve seen plenty of examples of creating a dictionary.xml file and loading it into my XSL via document(\'dictionar
Use a URIResolver
instead of a parameter. First, create the resolver like this:
public class DocURIResolver implements URIResolver {
final Map documents;
public DocURIResolver(final Map documents) {
this.documents = documents;
}
public Source resolve(final String href, final String base) {
final Document doc = documents.get(href);
return (doc != null) ? new DOMSource(doc) : null;
}
}
Use it like this:
Document dictionary = TranslationDictionary.getDictionaryDocument();
Map docs = new HashMap();
docs.put("dictionary", dictionary);
// transformer is your javax.xml.transform.Transformer
transformer.setURIResolver(new DocURIResolver(docs));
And reference it in your stylesheet by name:
This is just a toy example, of course. You can make your URIResolver
as full-featured as necessary.