- private byte[] getXhtml(HttpMethod aMethod) throws URIException, IOException {
- // Transform the HTML into wellformed XML.
- Tidy tidy = new Tidy();
- tidy.setXHTML(true);
- tidy.setQuiet(true);
- tidy.setShowWarnings(false);
- if (_os != null) {
- _os.println("Content of '" + aMethod.getURI() + "'");
- _os.println();
- }
- // We write the jtidy output to XML since the DOM tree it produces is
- // not namespace aware and namespace awareness is required by XSLT.
- // An alternative is to configure namespace awareness of the XML parser
- // in a system wide way.
- Document w3cDoc = tidy.parseDOM(aMethod.getResponseBodyAsStream(),
- _os);
- DOMUtility.removeDuplicateAttributes(w3cDoc);
-
- ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
- XMLSerializer serializer = new XMLSerializer(xhtml, new OutputFormat());
- serializer.serialize(w3cDoc);
- xhtml.flush();
- if (_os != null) {
- _os.println();
- }
- return xhtml.toByteArray();
- }
+ private byte[] getXhtml(HttpMethod aMethod) throws IOException {
+ // Transform the HTML into wellformed XML.
+ Tidy tidy = new Tidy();
+ tidy.setXHTML(true);
+ tidy.setQuiet(true);
+ tidy.setShowWarnings(false);
+
+ // We write the jtidy output to XML since the DOM tree it produces is
+ // not namespace aware and namespace awareness is required by XSLT.
+ // An alternative is to configure namespace awareness of the XML parser
+ // in a system wide way.
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Document w3cDoc = tidy.parseDOM(aMethod.getResponseBodyAsStream(), os);
+ DomUtils.removeDuplicateAttributes(w3cDoc);
+ LOG.debug("Content of response is \n" + os.toString());
+
+ ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
+ XMLSerializer serializer = new XMLSerializer(xhtml, new OutputFormat());
+ serializer.serialize(w3cDoc);
+ xhtml.flush();
+
+ return xhtml.toByteArray();
+ }