Methods Summary |
---|
protected abstract org.apache.tools.ant.taskdefs.XSLTLiaison | createLiaison()
|
protected java.io.File | getFile(java.lang.String name)load the file from the caller classloader that loaded this class
URL url = getClass().getResource(name);
if (url == null){
throw new FileNotFoundException("Unable to load '" + name + "' from classpath");
}
return new File(FILE_UTILS.fromURI(url.toExternalForm()));
|
public org.w3c.dom.Document | parseXML(java.io.File file)
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dbuilder = dbfactory.newDocumentBuilder();
return dbuilder.parse(file);
|
protected void | setUp()
liaison = createLiaison();
|
public void | testEncoding()
File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl");
liaison.setStylesheet(xsl);
File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml");
File out = new File("xsltliaison-encoding.tmp");
out.deleteOnExit(); // just to be sure
try {
liaison.transform(in, out);
Document doc = parseXML(out);
assertEquals("root",doc.getDocumentElement().getNodeName());
assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName());
assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue());
} finally {
out.delete();
}
|
public void | testTransform()keep it simple stupid
File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
liaison.setStylesheet(xsl);
liaison.addParam("param", "value");
File in = getFile("/taskdefs/optional/xsltliaison-in.xml");
File out = new File("xsltliaison.tmp");
out.deleteOnExit(); // just to be sure
try {
liaison.transform(in, out);
} finally {
out.delete();
}
|