So, are you generating PDF from XML and XSL, or from FO?

For instance, as an example, if I want PDF to show XML content, and I start from XML and XSL then I put this in the XML file:

<example>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<fo:layout-master-set>
<fo:simple-page-master margin="2cm"
      page-width="21.0cm" page-height="29.7cm" master-name="A4-portrait">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4-portrait">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
        ]]>
</example>

and something like this in the XSL file:

<fo:block>
<xsl:apply-templates select="example" />
</fo:block>
<xsl:template match="example">
<fo:block font-size="12pt" linefeed-treatment="preserve" white-space-treatment="preserve" white-space-collapse="false" font-family="monospace">
<xsl:value-of select="." />
</fo:block>
</xsl:template>

Then fop -xml example.xml -xsl example.xsl -pdf example.pdf generates a PDF with the example you see above inside the <![CDATA[]]>.

If you are working with FO, then you can use the above example and fop -xml example.xml -xsl example.xsl -foout example.fo to see how it should look like:

<fo:block font-family="monospace" white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve" font-size="12pt">

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
&lt;fo:layout-master-set&gt;
&lt;fo:simple-page-master margin="2cm"
page-width="21.0cm" page-height="29.7cm" master-name="A4-portrait"&gt;
&lt;fo:region-body /&gt;
&lt;/fo:simple-page-master&gt;
&lt;/fo:layout-master-set&gt;
&lt;fo:page-sequence master-reference="A4-portrait"&gt;
&lt;fo:flow flow-name="xsl-region-body"&gt;
&lt;fo:block&gt;Hello World!&lt;/fo:block&gt;
&lt;/fo:flow&gt;
&lt;/fo:page-sequence&gt;
&lt;/fo:root&gt;

</fo:block>


On 2/21/12 11:35 PM, Craig Christophersen wrote:

I am encountering xml processing instructions in textual content. Example: " <para> text con<?Pub Caret?>tent here </para>"

The resulting pdf from using FOP is " text con" followed by content from the next element. The remainder of the text content following the processing instruction "tent here" is left out.

Is this a bug? Is there something I can configure in FOP config.xml to handle this? Processing instructions are allowed in textual content of xml elements.

Using FOP 1.0, Windows 7, JDK 1.6.0_26

Craig Christophersen

Software Developer

Synesis7

[email protected] <mailto:[email protected]>


Reply via email to