Here's another option that is greatly simplified; just print a copy of the entire XML.
Example:
XML Input
<doc attr="test">
<a>Lorem ipsum dolor sit amet...</a>
<b>
<c>Lorem ipsum dolor sit amet...</c>
<d>
<e attr="another test"/>
<f>Lorem ipsum dolor sit amet...</f>
</d>
</b>
</doc>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body" font-family="monospace">
<fo:block white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">
<xsl:text disable-output-escaping="yes">
<![CDATA[
</xsl:text>
<xsl:copy-of select="/*"/>
<xsl:text disable-output-escaping="yes">
]]>
</xsl:text>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
XSL-FO Output
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body" font-family="monospace">
<fo:block white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">
<![CDATA[
<doc attr="test">
<a>Lorem ipsum dolor sit amet...</a>
<b>
<c>Lorem ipsum dolor sit amet...</c>
<d>
<e attr="another test"/>
<f>Lorem ipsum dolor sit amet...</f>
</d>
</b>
</doc>
]]>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
PDF Output (Apache FOP)
