Hi,
      I would like to do a transform to "pretty-printed" HTML and get the
result as a byte array.
      I am doing this by using an XMLResult wrapping an HTMLWriter.
      Besides finding a possible bug ([ 616561 ] XMLResult/HTMLWriter
output cut short) where the XMLResult's XMLWriter is not being closed by
the end of the transform, I am having trouble getting the special features
of HTMLWriter to work in conjunction with the XMLResult.
      In particular, the main point of the HTMLWriter as I see it, is that
it knows which elements are preformatted (such as script tags). However,
using an XMLResult with an HTMLWriter apparently doesn't use this feature.
Is this meant to be the case?

Sample code
        Result result=null;
        ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
         if (usePrettyPrint){
             HTMLWriter htmlWriter = new HTMLWriter(out,
OutputFormat.createPrettyPrint());
             result = new XMLResult(htmlWriter);
         }
         else{
                result = new StreamResult(out);
         }

Doing a transform in the usePrettyPrint case results in indented HTML, but
script tags have whitespace (carriage returns) stripped.
In the other case, I get no indenting, but the script tags are properly
handled (assuming the XSL file's output method="html").

I notice that the special preformatted tag handling in HTMLWriter occurs on
the writeElement method, whereas XMLResult apparently fires the
HTMLWriter.startElement method which is lacking this handling.

Is there a way to do get the "pretty" HTML bytes directly via a transform?

Thanks,
Rob



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to