Use XSLT template, the most efficient and easy way to generate to any report format from xml.
In my project, we are generating different category of html reports from testng-results.xml for fast regression analysis. Also we had generated json report using xslt from testng-results.xml to see aggregate result.
We use gradle build tool to run xslt and generate report after completion of test like,
configurations{ xslt }
dependencies {
xslt 'net.sf.saxon:saxon:8.7'
}
task generateReport << {
File reportDir=new File("${projectDir}/HTML_Reports")
if(reportDir.exists()){
reportDir.deleteDir()
}
reportDir.mkdir()
ant.xslt(in: "${testReportDir.absolutePath}/test/testng-results.xml",
style: "${projectDir.absolutePath}/src/test/resources/xslt_config/emailablereport.xsl",
out: "${reportDir.absolutePath}/index.html",
classpath: configurations.xslt.asPath) {
param(name: 'paramXSLT.environment', expression: "${env}")
}
You can also run xsl in maven using this plugin
For run xsl in java program refer this post