views:

363

answers:

2

I have a Java string of XML content. I use Velocity to generate some HTML reports, and this XML needs to be included into one of those HTML files. It would be nice if this XML is syntax colored and formatted. Does anyone know of a Java library to do this?

+2  A: 

https://jhighlight.dev.java.net/

A: 

How about transforming your xml to html using a XSLT stylesheet and the transform API. See Transform XML into HTML using XSLT: http://www.rgagnon.com/javadetails/java-0407.html

Pierre
The idea is that the output looks like XML, but with syntax colouring.
Peter Hilton
XSLT can do that by replacing, say, <span class="codeKeyWord">..</span> with something like <span class="codeKeyWord" style="color:green">..</span>. It's just not very clean way to do it.
Esko