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 Om Narayan <om...@hotmail.com> on 2003/05/14 07:23:17 UTC
Error when piping XSL-FO to FOP driver using SAXResult
I am basically using the ExampleXML2PDF code to test my xsl file. I get an
error message saying only "table-row" are allowed inside table-body. The xsl
is generating table-row tags which I verified by dumping the output to a
file. Also, if I saved the generated xsl-fo file into a temporary file, and
then run the fop by reading the temporary file, it generates the correct
output. So I am assuiming that the act of piping the xsl-fo output through
the SAXResult is somehow affecting the interpretation of the generated code
(the ContentHandler is getting confused becuase of the CDATA code that the
xsl generates). I would appreciate it if somebody can suggest a solution.
Basically , what I am trying to do here is take the following xml and layout
the data into 3 column tabular layout. Alternate methods of doing this will
be appreciated as well.
<customers>
<customer>
<firstname>xxx</firstname>
<lastname>yyy</lastname>
</customer>
... <customer> repeats ....
</customers>
Snippet from ExampleXML2PDF.java
===========================
//Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(driver.getContentHandler());
//Start XSLT transformation and FOP processing
transformer.transform(src, res);
Here is a snippet of the code from the XSL
===============================
<fo:table-body>
<xsl:text
disable-output-escaping="yes"><![CDATA[<fo:table-row>]]></xsl:text>
<xsl:for-each select="customerPF">
<xsl:if test="position()!=1">
<xsl:if test="(position()-1) mod 3 = 0">
<xsl:text
disable-output-escaping="yes"><![CDATA[</fo:table-row>]]></xsl:text>
<xsl:text
disable-output-escaping="yes"><![CDATA[<fo:table-row>]]></xsl:text>
</xsl:if>
</xsl:if>
<fo:table-cell><fo:block><xsl:value-of
select="position()"/></fo:block></fo:table-cell>
</xsl:for-each>
<xsl:text
disable-output-escaping="yes"><![CDATA[</fo:table-row>]]></xsl:text>
</fo:table-body>
Thanks for any help.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: Error when piping XSL-FO to FOP driver using SAXResult
Posted by Jeremias Maerki <de...@greenmail.ch>.
You MUSTN'T enclose XML tags to be written to the output in CDATA
sections. In SAX that will result in calls to characters() instead of
startElement/endElement and therefore your closing fo:table-row tags
don't get recognized as tags. What you did here is a hack. Try to
reformulate that snippet.
On 14.05.2003 07:23:17 Om Narayan wrote:
> Here is a snippet of the code from the XSL
> ===============================
>
> <fo:table-body>
> <xsl:text
> disable-output-escaping="yes"><![CDATA[<fo:table-row>]]></xsl:text>
> <xsl:for-each select="customerPF">
> <xsl:if test="position()!=1">
> <xsl:if test="(position()-1) mod 3 = 0">
> <xsl:text
> disable-output-escaping="yes"><![CDATA[</fo:table-row>]]></xsl:text>
> <xsl:text
> disable-output-escaping="yes"><![CDATA[<fo:table-row>]]></xsl:text>
> </xsl:if>
> </xsl:if>
> <fo:table-cell><fo:block><xsl:value-of
> select="position()"/></fo:block></fo:table-cell>
> </xsl:for-each>
> <xsl:text
> disable-output-escaping="yes"><![CDATA[</fo:table-row>]]></xsl:text>
> </fo:table-body>
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org