Hi everybody,

Im new in this forum. I were very thankfull if somebody could lend me a hand with the Jtidy library.

I've installed a WYSIWYG editor for my customers in a CMS, for publishing pretty documents in their portal. The issue is the usual with that kind of HTML editors, the final code that they provide doesn't validate for the most grammars published by the w3c, specificilly we are looking for a XHTML Strict validation.

I have heared about the Tidy project, in fact I am interesting in the Jtidy library.I need to develop a .java class for cleaning my code, more or less like the Guid for Jtidy do (http://www.paehl.de/tidy/). This tool works very well, it fix a lot of bugs in your code.

Ive do only a couple of test with the jTidy, next I post the code:

package es.pa.common.tidy;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import org.w3c.dom.Document;
import org.w3c.tidy.Configuration;
import org.w3c.tidy.Tidy;

public class CleanHtmlCode {

public CleanHtmlCode() {
// TODO Auto-generated constructor stub

public String clean(String input){
ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Tidy tidy = new Tidy();
return baos.toString();


package es.pa.test;

import es.pa.common.tidy.CleanHtmlCode;

public class TestCleanHtmlCode {

* @param args
public static void main(String[] args) {
CleanHtmlCode chc = new CleanHtmlCode();
System.out.println(chc.clean("<p>OTROS SUPUESTOS AUTORIZABLES</p> <p>Podr&aacute; solicitarse la realizaci&oacute;n de quemas no contempladas en la Resoluci&oacute;n de 14 de agosto de 2002, <strong>Otras quemas</strong>, <u>quemas para otras finalidades diferentes a la eliminaci&oacute;n de rastrojos agr&iacute;colas (pueden tener finalidad educativa, cultural...)</u> as&iacute; como la solicitud de trabajos que, de forma puntual, se realicen en los montes y exijan el empleo de equipos o herramientas susceptibles de propagar el fuego. El Jefe del Servicio de Montes y Producci&oacute;n Forestal de la Consejer&iacute;a de Medio Rural y Pesca podr&aacute;, previo informe, autorizar estos trabajos imponiendo las normas que se consideren oportunas en cada caso y por un plazo no superior a 15 d&iacute;as.</p>"));


In this piece of code you can find the tag <u>, that is not allowed in XHTML Strict. In this case the GUITIDY generates a XHTML Transitional page.

What Im looking for is a .java class for fixing these pieces of code, Id call this class in a <xsl:variable> element of a XSL transformation page.

Thanks in advance,