W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > June 2007

RE: Call tomorrow?

From: Miguel Garcia <miguel.garcia@fundacionctic.org>
Date: Tue, 5 Jun 2007 18:34:55 +0200
Message-ID: <09700B613C4DD84FA9F2FEA521882819021EBAB8@ayalga.fundacionctic.org>
To: "Sean Owen" <srowen@google.com>, <public-mobileok-checker@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:13:03 GMT