- From: Miguel Garcia <miguel.garcia@fundacionctic.org>
- Date: Tue, 5 Jun 2007 18:34:55 +0200
- To: "Sean Owen" <srowen@google.com>, <public-mobileok-checker@w3.org>
Received on Tuesday, 5 June 2007 16:35:18 UTC
Hi, We have found out that TransformerFactory class has an URIResolver handler. This handler returns a Source object to a resource specified by a href and a base. With this handler and Java ClassLoader we could import xsl from jar files. We prefer to attach the source code before commit such changes to allow some discussion about this solution. Also I highlight some of the code to give and idea: final TransformerFactory factory =TransformerFactory.newInstance(); factory.setURIResolver( new XSLTURIResolver() ); final Transformer transformer=factory.newTransformer(new StreamSource(xslStream)); transformer.transform(new DOMSource(results.getMokiDocument()), domResult); return runTest(domResult.getNode()); and our URIResolver implementation: private static class XSLTURIResolver implements URIResolver { public Source resolve(String href, String base) { //if (href.contains("xsl")) { return new StreamSource((InputStream)this.getClass().getClassLoader().getResourceAs Stream("org/w3c/mwi/mobileok/basic/xslt/"+href)); //} } } Regards
Received on Tuesday, 5 June 2007 16:35:18 UTC