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 Sheldon Glickler <sh...@thevillages.net> on 2008/10/14 01:03:44 UTC

I need a little more help please.

I have reduced my xsl to a minimum so that I can generated data to write 
an xml.  I can't find why my two "headerline"s are not appearing.  (I 
have reduced this example to as small as I can).  I have included the files.

Re: I need a little more help please.

Posted by Jay Bryant <ja...@bryantcs.com>.
Hi, Sheldon,

Since this is a purely XSLT issue, you'd get more (and possibly 
more-on-target) responses on the XSL list:
http://www.mulberrytech.com/xsl/xsl-list/

It's not that we FOP-lovers hate XSLT - just the opposite, in fact. It's 
just that XSLT isn't the focus of this list.

When I run your transform, I get elements from the headerline part of the 
transform.

For one run, I added a static attribute to each table being created by that 
for-each instruction, thus:
<fo:table table-layout="fixed" border-collapse="collapse" space-before="0pt" 
id="{count(preceding-sibling::headerline)}">

I got these two table start lines:
<fo:table table-layout="fixed" border-collapse="collapse" space-before="0pt" 
id="0">
<fo:table table-layout="fixed" border-collapse="collapse" space-before="0pt" 
id="1">

So your transform is finding the headerline elements.

However, when I ran the transform, I did not get any content for the rows 
(that is, I got no cell elements in the row elements). That was because your 
XML has hdr_itm elements, but your XSLT was looking for hdr_item elements 
(not the extra e) - probably a typo.

I corrected that and have attached the file as t.xsl.

I also made a greatly modified version in which I ditched all the variables 
(except product_list, since I assume you're going to write a nodeset into 
that one and then use it later) and ditched the for-eaches to use templates 
instead. I avoid variables that do nothing more than hold a reference to a 
node. I also use templates wherever I can. I find that both of those 
practices make a transform easier to read and thus easier to maintain. Also, 
the modified transform is 1000 bytes smaller than the original (a sign that 
it's ultimately simpler). I attached that file as t_jb.xsl. (And yes, it's a 
slow evening, though my favorite of the two teams is winning the game right 
now.)

If you wish to ignore the arrogant know-it-all and just use your original 
file, use t.xsl. If you want to try it my way, use t_jb.xsl. I know you've 
got much more to do in this transform and that you can't just substitute 
files, but I'm sure you get the idea.

Let me know (preferably on list, as others may have the same questions 
someday) if you need more help.

Happy programming.

Jay Bryant

----- Original Message ----- 
From: "Sheldon Glickler" <sh...@thevillages.net>
To: <fo...@xmlgraphics.apache.org>
Sent: Monday, October 13, 2008 6:03 PM
Subject: I need a little more help please.


>I have reduced my xsl to a minimum so that I can generated data to write
> an xml.  I can't find why my two "headerline"s are not appearing.  (I
> have reduced this example to as small as I can).  I have included the 
> files.
>


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


> <?xml version="1.0"?>
> <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="print-compliance">
>  <xsl:processing-instruction 
> name="cocoon-format">type="text/xslfo"</xsl:processing-instruction>
>  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
>    <fo:layout-master-set>
>      <fo:simple-page-master master-name="compliance-form"
>         margin-top="50pt"
>         margin-bottom="50pt"
>         margin-left="15pt"
>         margin-right="20pt"
>         page-height="8.5in"
>         page-width="11in">
>        <fo:region-body margin-bottom="1pt"/>
>      </fo:simple-page-master>
>    </fo:layout-master-set>
>    <fo:page-sequence master-reference="compliance-form">
>      <fo:flow flow-name="xsl-region-body">
>        <xsl:apply-templates select="header" />
>      </fo:flow>
>    </fo:page-sequence>
>  </fo:root>
> </xsl:template>
>
> <xsl:template match="header">
>  <fo:table table-layout="fixed" border-collapse="collapse" 
> space-before="0pt" border-style="none">
>    <xsl:variable name="product_list" select="product_list" />
>    <xsl:variable name="title_bg_color" select="title_bg_color" />
>    <xsl:variable name="color" select="color" />
>    <xsl:variable name="linespace" select="linespace" />
>    <xsl:variable name="fullwidth" select="fullwidth" />
>    <xsl:variable name="fontsize" select="fontsize" />
>    <xsl:variable name="fontweight" select="fontweight" />
>    <xsl:variable name="border" select="border" />
>    <fo:table-column column-width="{$fullwidth}"/>
>    <fo:table-body >
>    <fo:table-row>
>        <fo:table-cell background-color="{$title_bg_color}" >
>          <fo:block text-align="center" wrap-option="no-wrap" 
> font-size="{$fontsize}" line-height="{$linespace}"
>                        font-weight="{$fontweight}" color="{$color}" 
> border="{$border}">
>            <xsl:value-of select="report_name"/>
>          </fo:block>
>        </fo:table-cell>
>      </fo:table-row>
>    </fo:table-body>
>  </fo:table>
>  <xsl:for-each select="headerline">
>  <fo:table table-layout="fixed" border-collapse="collapse" 
> space-before="0pt">
>      <xsl:variable name="border" select="border" />
>      <xsl:variable name="fontweight" select="fontweight" />
>      <xsl:variable name="linespace" select="linespace" />
>      <xsl:variable name="wrap" select="wrap" />
>    <xsl:for-each select="colsize">
> <xsl:variable name="width" select="value" />
> <fo:table-column column-width="{$width}"/>
>    </xsl:for-each>
>    <fo:table-body>
>      <fo:table-row line-height="{$linespace}">
>      <xsl:for-each select="hdr_item">
>            <fo:table-cell wrap-option="{$wrap}">
>            <xsl:variable name="align" select="align" />
>            <xsl:variable name="color" select="color" />
>            <xsl:variable name="fontsize" select="fontsize" />
>            <xsl:variable name="bg_color" select="bg_color" />
>            <xsl:variable name="color" select="color" />
>              <fo:block text-align="{$align}" font-size="{$fontsize}" 
> border="{$border}"
>                    font-weight="{$fontweight}" color="{$color}" 
> background-color='{$bg_color}'>
>                <xsl:value-of select="value"/>
>              </fo:block>
>            </fo:table-cell>
>          </xsl:for-each>
>        </fo:table-row>
>      </fo:table-body>
>  </fo:table>
>  </xsl:for-each>
> </xsl:template>
>
> </xsl:stylesheet>
>


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


> <?xml version="1.0" encoding="utf-8"?>
> <print-compliance>
> <header>
> <bg_color>rgb(255,190,160)</bg_color>
> <title_bg_color>darkgray</title_bg_color>
> <fontweight>bold</fontweight>
> <color>maroon</color>
> <report_name>TITLE</report_name>
> <fullwidth>400pt</fullwidth>
> <fontsize>10pt</fontsize>
> <linespace>15pt</linespace>
> <border>none</border>
> <headerline>
> <linespace>10pt</linespace>
> <fontweight>bold</fontweight>
> <border>solid 1pt</border>
> <wrap>no-wrap</wrap>
> <colsize><value>300pt</value></colsize>
> <colsize><value>50pt</value></colsize>
> <colsize><value>50pt</value></colsize>
> <hdr_itm>
> <value>COMMODITY  </value>
> <bg_color>darkgray</bg_color>
> <color>black</color>
> <fontsize>8pt</fontsize>
> <align>end</align>
> </hdr_itm>
> <hdr_itm>
> <value>Subtitle 1</value>
> <bg_color>rgb(255,190,160)</bg_color>
> <color>black</color>
> <fontsize>6pt</fontsize>
> <align>center</align>
> </hdr_itm>
> <hdr_itm>
> <value>Subtitle 1</value>
> <bg_color>darkgray</bg_color>
> <color>black</color>
> <fontsize>6pt</fontsize>
> <align>center</align>
> </hdr_itm>
> </headerline>
> <headerline>
> <linespace>8pt</linespace>
> <fontweight>bold</fontweight>
> <wrap>no-wrap</wrap>
> <colsize><value>120pt</value></colsize>
> <colsize><value>60pt</value></colsize>
> <colsize><value>60pt</value></colsize>
> <colsize><value>30pt</value></colsize>
> <colsize><value>30pt</value></colsize>
> <colsize><value>50pt</value></colsize>
> <colsize><value>50pt</value></colsize>
> <hdr_itm>
> <value>LOCATION</value>
> <align>start</align>
> <fontsize>8pt</fontsize>
> <color>black</color>
> <bg_color>rgb(255,190,160)</bg_color>
> <border>solid .5pt</border>
> </hdr_itm>
> <hdr_itm>
> <value>RESPONSIBILITY</value>
> <fontsize>8pt</fontsize>
> <align>start</align>
> <color>black</color>
> <bg_color>rgb(255,190,160)</bg_color>
> <border>solid .5pt</border>
> </hdr_itm>
> <hdr_itm>
> <value>VICE PRESIDENT</value>
> <fontsize>8pt</fontsize>
> <align>start</align>
> <color>black</color>
> <bg_color>rgb(255,190,160)</bg_color>
> <border>solid .5pt</border>
> </hdr_itm>
> <hdr_itm>
> <value>LOG / FIN CO.</value>
> <fontsize>8pt</fontsize>
> <color>black</color>
> <align>center</align>
> <bg_color>rgb(255,190,160)</bg_color>
> <border>solid .5pt</border>
> </hdr_itm>
> <hdr_itm>
> <value>DIM.</value>
> <fontsize>8pt</fontsize>
> <color>black</color>
> <bg_color>rgb(255,190,160)</bg_color>
> <border>solid .5pt</border>
> <align>center</align>
> </hdr_itm>
> <hdr_itm>
> <value>COMPANY 1</value>
> <color>black</color>
> <bg_color>rgb(255,190,160)</bg_color>
> <fontsize>8pt</fontsize>
> <border>solid 1pt</border>
> <align>center</align>
> </hdr_itm>
> <hdr_itm>
> <value>COMPANY 2</value>
> <fontsize>8pt</fontsize>
> <bg_color>darkgray</bg_color>
> <border>solid 1pt</border>
> <align>center</align>
> </hdr_itm>
> </headerline>
> </header>
> </print-compliance>


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


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


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