we have java-based system reads data database, merges individual data fields preset xsl-fo
tags , converts result pdf
apache fop
.
in xsl-fo
format looks this:
<?xml version="1.0" encoding="utf-8" ?> <!doctype html [ <!entity nbsp " "> <!-- other entities --> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <fo:root xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:svg="http://www.w3.org/2000/svg" font-family="..." font-size="..."> <fo:layout-master-set> <fo:simple-page-master master-name="letter page" page-width="8.500in" page-height="11.000in"> <!-- appropriate settings --> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="letter page"> <!-- static content --> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:table ...> <fo:table-column ... /> <fo:table-body> <fo:table-row> <fo:table-cell ...> <fo:block text-align="..."> <fo:inline font-size="..." font-weight="..."> <!-- header / title --> </fo:inline> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> <fo:block> <fo:table ...> <fo:table-column ... /> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block ...> <!-- field --> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> <!-- other fields in similar fashion above "field a" --> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> </xsl:stylesheet>
now looking way allow of fields contain static html-formatted content. content generated our html-enabled editor (something along lines of cleditor
, ckeditor
, etc.) or pasted outside.
my plan follow recipe from javaworld article:
- use
jtidy
convert html-formatted string proper xhtml - further modify xhtml2fo.xsl antenna house remove document-wide , page-wide transformations
- apply modified xslt xhtml string (javax.xml.transform)
- extract nodes under root xpath (javax.xml.xpath)
- feed result directly existing xsl-fo document
i have bare-bone version of such code , got following error:
(location of error unknown)org.apache.fop1.fo.validationexception: "{http://www.w3.org/1999/xsl/format}table-body" not valid child of "fo:block"! (no context info available)
my questions:
- what way troubleshoot issue?
- can
<fo:block>
serve generic container other objects (including tables) nested inside? - is overall reasonable approach solving task?
if "been there done that", please share experience.
the best way troubleshoot use validating viewer/editor examine xsl fo. many (such oxygen) show errors in xsl fo structure open them , describe issue (just error reported).
in case, have fo:table-body child of fo:block. cannot be. fo:table-body have 1 valid parent, fo:table. either missing fo:table tag or have erroneously inserted fo:block in position.
in opinion, might things different. put xhtml content inline xsl fo right want it. create identity transform copies on content fo-based, converts xhtml parts using xsl. way, can step transform in xsl editor oxygen , see errors occur , why. other degugger.
note: may wish @ other xsls also, if html may have style="" css attributes. if case not simple html, need better method processing html css fo.
http://www.cloudformatter.com/css2pdf based on complete transform. general stylesheet available here: http://xep.cloudformatter.com/doc/xsl/xeponline-fo-translate-2.xsl
i author of stylesheet. more ask, has complex parsing recursion converting css styling xsl fo attributes.
Comments
Post a Comment