- // Execute the method.
- method = executeWithRedirects(client, method);
-
- // 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 '" + method.getURI() + "'");
- _os.println();
- }
- // We let jtidy produce raw output because the DOM it produces is
- // is not namespace aware. We let the XSLT processor parse the XML again
- // to ensure that the XSLT uses a namespace aware DOM tree. An alternative
- // is to configure namespace awareness of the XML parser in a system wide way.
- ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
- tidy.parse(method.getResponseBodyAsStream(), xhtml);
- _os.print(new String(xhtml.toByteArray()));
- // Obtaining the XML as dom is not used.
- //Document w3cDoc = tidy.parseDOM(method.getResponseBodyAsStream(),
- // _os);
- if ( _os != null ) {
- _os.println();
- }
- xhtml.flush();
- byte[] xhtmlData = xhtml.toByteArray();
- Document transformed = new XSLT().transform(xhtmlData, new FileResource(new File(_xslt)));
+ aMethod = executeWithRedirects(aClient, aMethod);
+ byte[] xhtmlData = getXhtml(aMethod);
+
+ Document transformed = new XSLT().transform(xhtmlData,
+ new FileResource(new File(_xslt)));