I'm using XSLT to generate Java Code with the javax.annotation.processing API. It works well as long as I don't want to test it, which I of course do :) While running the processor, the JavaFileObject.toUri() gives me a "file:/"-URI, which I can use for creating a StreamResult for the Transformer.
This is not the case when testing the class I get, for example /CLASS_OUTPUT/com/example.MyClass.class
JavaFileObject jfo = filer.createSourceFile(className);
String uri = jfo.toUri().toASCIIString();
if (!uri.startsWith("file:/")) { // is test!
messager.printMessage(Diagnostic.Kind.NOTE, "Not a file URI, we're testing!");
return;
}
StreamResult result = new StreamResult(uri);
DOMSource src = new DOMSource(modelDoc);
DOMSource xslSource = new DOMSource(loadDocument(xslUri));
TransformerFactory tf = new net.sf.saxon.TransformerFactoryImpl();
Transformer transformer = tf.newTransformer(xslSource);
transformer.transform(src, result);
I have the following questions:
- Does the test create a real source file?
- If yes, what is its actual location?
Thanks!
Aucun commentaire:
Enregistrer un commentaire