You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Andriy Sen <ap...@optonline.net> on 2006/11/21 21:21:21 UTC

Different output when using fop with -xsl and -xml and when doing two steps (xalan/fop)

When I use xalan to produce .fo file and then process it with fop I get correct result.
Not so when running fop directly.

I was expecting both approaches to produce identical results since it is my understanding
that fop is using xalan internally. Any idea why it is not? Or can someone confirm it as a bug?

I'm using fop 0.20.5 with xalan 2.5.2.
I'm running them as follows in the same batch. Content of the example
test files (export.bat, test.xslt, test.xml) is below.

export.bat
-------------
@ECHO OFF
rem %~dp0 is the expanded pathname of the current script under NT
set LOCAL_FOP_HOME=
if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME=Z:\pcgen\lib\

set LIBDIR=%LOCAL_FOP_HOME%
set LOCALCLASSPATH=%LOCAL_FOP_HOME%fop.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%xml-apis.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%xercesImpl-2.2.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%xalan-2.5.2.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%batik.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%avalon-framework-cvs-20020806.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%jimi-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%jai_core.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LOCAL_FOP_HOME%jai_codec.jar
java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -xsl test.xslt -in test.xml -out test.fo
java -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop -fo test.fo test2.pdf
java -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop  -xsl test.xslt -xml test.xml test1.pdf
java -cp "%LOCALCLASSPATH%" org.apache.xalan.xslt.Process -xsl test.xslt -in test.xml -out test.fo
java -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop -fo test.fo test2.pdf

java -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop  -xsl test.xslt -xml test.xml test1.pdf

-------------

test.xslt:
-------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match = "test" >
<xsl:text disable-output-escaping="yes">
<![CDATA[
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
     <fo:layout-master-set>
          <fo:simple-page-master margin-right="0.5cm" margin-left="1.5cm" margin-bottom="2cm" margin-top="0cm" page-width="21cm" 
page-height="20cm" master-name="one">
               <fo:region-body margin-bottom="2cm" margin-top="2cm"/>
               <fo:region-before extent="0.5cm"/>
               <fo:region-after extent="0.5cm"/>
          </fo:simple-page-master>
     </fo:layout-master-set>
    <fo:page-sequence master-reference="one">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
]]>
</xsl:text>
<xsl:value-of disable-output-escaping="yes" select="."/>
<xsl:text disable-output-escaping="yes">
<![CDATA[
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>
]]>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

-------------

test.xml
-------------
<?xml version="1.0" encoding="UTF-8"?>
<test>
&lt;fo:table table-layout=&quot;fixed&quot; inline-progression-dimension=&quot;8.0in&quot;&gt;
 &lt;fo:table-column column-width=&quot;proportional-column-width(25)&quot;/&gt;
 &lt;fo:table-column column-width=&quot;proportional-column-width(75)&quot;/&gt;
 &lt;fo:table-body&gt;
  &lt;fo:table-row&gt;
   &lt;fo:table-cell&gt;
    &lt;fo:block&gt;1st row/1st column&lt;/fo:block&gt;
   &lt;/fo:table-cell&gt;
   &lt;fo:table-cell&gt;
    &lt;fo:block&gt;1st row/2nd column&lt;/fo:block&gt;
   &lt;/fo:table-cell&gt;
  &lt;/fo:table-row&gt;
  &lt;fo:table-row&gt;
   &lt;fo:table-cell&gt;
    &lt;fo:block&gt;2nd row/1st column&lt;/fo:block&gt;
   &lt;/fo:table-cell&gt;
   &lt;fo:table-cell&gt;
    &lt;fo:block&gt;2nd row/2nd column&lt;/fo:block&gt;
   &lt;/fo:table-cell&gt;
  &lt;/fo:table-row&gt;
 &lt;/fo:table-body&gt;
&lt;/fo:table&gt;
</test>

-------------


Thanks,
Andriy


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Different output when using fop with -xsl and -xml and when doing two steps (xalan/fop)

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Andriy Sen wrote:
> 
> When I use xalan to produce .fo file and then process it with fop I get 
> correct result.
> Not so when running fop directly.
> 
> I was expecting both approaches to produce identical results since it is 
> my understanding
> that fop is using xalan internally. Any idea why it is not?

The problem is the disable-output-escaping="yes". This affects
how an output file is generated but has no effect if the result
tree of an XSL transformation is fed directly into the FO processor.

> Or can someone confirm it as a bug?

This is not a bug.

> <xsl:text disable-output-escaping="yes">
> <![CDATA[
>            </fo:block>

You should not use this kind of construct, ever. Well, at least unless
you clearly know what you are doing. Please refer to your favorite XSLT
tutorial and/or book for how to write XSLT properly.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org