- From: G. Ken Holman <gkholman@CraneSoftwrights.com>
- Date: Fri, 25 May 2012 10:32:46 -0400
- To: www-xsl-fo@w3.org
At 2012-05-25 03:33 -0700, Léa Massiot wrote: >Below are the XSL stylesheet and the XML data files I am using. >Given these two files and using "fop" (1.0) emebeded in a Java application I >generate a resulting PDF document which basically consists of a 210mm x >297mm page containing a rectangle with the "Hello World" string inside. >My problem is that, even though I am specifying I would like that rectangle >to be 100mm x 200mm in the XML file (see below), I get a 94mm x 189mm area >when I print the generated PDF document and measure it with a ruler. > >Can you help me understand what's happening? I do not use FOP so I put your files through another processor and the box came out precisely at 100mmx200mm. So it sounds like a FOP bug. Note in your stylesheet you are following poor form in the declaration of result tree fragment variables with text nodes, rather than simply addressing the values of the elements with attribute value templates the way you did with your simple page master. > <xsl:template match="area"> > > <xsl:variable name="top"> > <xsl:value-of select="top" /> > </xsl:variable> > > <xsl:variable name="left"> > <xsl:value-of select="left" /> > </xsl:variable> > > <xsl:variable name="height"> > <xsl:value-of select="height" /> > </xsl:variable> > > <xsl:variable name="width"> > <xsl:value-of select="width" /> > </xsl:variable> > > <fo:block-container position = "absolute" > top = "{$top}" > left = "{$left}" > height = "{$height}" > width = "{$width}" > background-color = "DarkSlateGray"> The following would produce the same result without the overhead of creating variables: <xsl:template match="area"> <fo:block-container position = "absolute" top = "{top}" left = "{left}" height = "{height}" width = "{width}" background-color = "DarkSlateGray"> <fo:block> <xsl:value-of select="content" /> </fo:block> And even if you needed variables later in the code, the following would be better: <xsl:variable name="width" select="width"/> I hope this helps. . . . . . . . Ken -- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/ G. Ken Holman mailto:gkholman@CraneSoftwrights.com Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Received on Friday, 25 May 2012 14:33:43 UTC