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 Ramon Maria Gallart <rg...@asistemas.net> on 2002/04/23 15:34:41 UTC
Problems with FOP and XML/XSL
Hi all.
I'm new to FOP, XML, XSL, FO and so on. I'm getting an error message
when i try to get a PDF from a XML and XSL source. The message i'm
getting is the following:
[INFO]: FOP 0.20.3
[INFO]: building formatting object tree
[INFO]: Parsing of document complete, stopping renderer
[ERROR]: java.lang.ArithmeticException: / by zero
As you could see, the error is for a division by 0 which means that
when i'm going to see the *.pdf that FOP has created, it has no pages at
all.
If it is useful, i put here the command i use to execute FOP:
C:\fop-0.20.3>fop -xsl c:\java\plantillaInformeFO-2.xsl -xml
c:\java\informe3.xml -pdf c:\java\informe.pdf
_____
I put also here the documents used to do the transformation:
plantillaInformeFO-2.xsl
<?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="informe">
<fo:root xmlns:fo="http://www.w3c.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all"
page-height="11.5in" page-width="8.5in"
margin="1in">
<fo:region-body margin-top="1in"
margin-bottom="0.75in"/>
<fo:region-before extent="0.75in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="start" font-size="10pt"
font-family="serif">
Page(<fo:page-number/>)
</fo:block>
</fo:static-content>
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="comentari"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="comentari">
<fo:block>
<xsl:apply-templates select="titulo"/>
<xsl:apply-templates select="autor"/>
<xsl:apply-templates select="text"/>
</fo:block>
</xsl:template>
<xsl:template match="titulo">
<fo:block color="blue" font-family="sans-serif"
font-size="20pt">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="autor">
<fo:block font-style="italic" font-family="sans-serif"
font-size="16pt">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
<xsl:template match="text">
<fo:block font-family="sans-serif" font-size="12pt">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
_____
And here is informe3.xml
<?xml version="1.0" encoding="UTF-16"?>
<informe>
<comentari>
<titulo>El señor de los anillos</titulo>
<autor>J.R.R. Tolkien</autor>
<text>La companyia de l'anell ha de destruir l'anell
únic.</text>
</comentari>
<comentari>
<titulo>Omertà</titulo>
<autor>Mario Puzzo</autor>
<text>Aquesta és l'última novela de l'autor.</text>
</comentari>
<comentari>
<titulo>El caso de Charles Dexter Ward</titulo>
<autor>H.P. Lovecraft</autor>
<text>Terror i misteri en aquesta obra d'un dels mestres del
suspens.</text>
</comentari>
</informe>
Re: Problems with FOP and XML/XSL
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Ramon Maria Gallart wrote:
> ...I'm getting an error message when i try to get a PDF from a XML
> and XSL source. The message i'm getting is the following:
> [INFO]: FOP 0.20.3
> [INFO]: building formatting object tree
> [INFO]: Parsing of document complete, stopping renderer
> [ERROR]: java.lang.ArithmeticException: / by zero
Are you sure you produced this message with the code below?
> <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="informe">
> <fo:root xmlns:fo="http://www.w3c.org/1999/XSL/Format">
^^^
Wrong namespace. The correct one is already declared above.
FOP barfs #1;
...
> <fo:simple-page-master master-name="all"
page-height="11.5in" page-width="8.5in"
margin="1in">
Shorthand property margin is not yet implemented. Use margin-top,
margin-left and so on.
FOP barfs #2, this time a warning only.
> </fo:layout-master-set>
> <fo:static-content flow-name="xsl-region-after">
A flow has to be inside a page-sequence, this means...> <fo:page-sequence master-reference="all">
... here.
After this is corrected your sample files produce a perfectly
usable PDF.
J.Pietschmann