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 Johannes Künsebeck <hn...@gmx.de> on 2006/03/20 14:42:22 UTC
Re: alternatives to floats in fop
Thank you Jeremias, that's the solution!
This "2-pass"-approach is very cool, I can't imagine designs that aren't
possible with it.
If you can't wait for XSL-FO2.0, use this as a hack for "layout-driven"
documents.
I just summarize it for the list, because I think it can be helpful in
other situations, too.
1. first pass: render your content elements (like you want them to
appear) to a areatree
"fop ... - out application/X-fop-areatree outfile.at"
(don't forget to to include your fonts in the fop.conf for the
areatree-renderer, too). Give your content elements an id, so you later
know where they have been rendered to.
2. write a XSL that extracts the information about position, sizes,
number of elements per page, whatever. In my boring example it's just
retrieving the side of a page, but you can retrieve any data that is
known to fop.
...
<xsl:template match="areaTree/pageSequence/pageViewport">
<xsl:variable name="nr" select="@nr"></xsl:variable><!-- get
page-number -->
<xsl:variable name="page_format">
<xsl:choose>
<xsl:when test="number($nr) mod 2 = 0">left</xsl:when>
<xsl:when test="number($nr) mod 2 = 1">right</xsl:when>
</xsl:choose>
</xsl:variable>
<page nr="{$nr}" format="{$page_format}">
<xsl:apply-templates
select="page/regionViewport/regionBody/mainReference/span/flow/block" />
</page>
</xsl:template>
<xsl:template
match="page/regionViewport/regionBody/mainReference/span/flow/block">
<xsl:variable name="id" select="@prod-id"></xsl:variable>
<!-- the id is passed to areatree as @prod-id, you need it later -->
<workshop_ref id='{$id}' />
</xsl:template>
...
-> save output in structure.xml
If you're a genius (I'm not), you can skip step 2. and do it directly in 3.
3. second pass: use the information in the second pass-stylesheet. You
have to pass the context you're working in or you will be stuck in the
included document.
...
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates
select="document('structure.xml')/pages/page/workshop_ref">
<xsl:with-param name="context" select="." /><!-- keep
context -->
</xsl:apply-templates>
</fo:flow>
...
<xsl:template match="workshop_ref">
<xsl:param name="context"></xsl:param>
<xsl:variable name="id" select="@id" />
<xsl:choose>
<!-- now i know which side I'm on -->
<xsl:when test="../@format='left'"><xsl:apply-templates
select="$context/workshop[@id=$id]" mode="left" /></xsl:when>
<xsl:when test="../@format='right'"><xsl:apply-templates
select="$context/workshop[@id=$id]" mode="right" /></xsl:when>
</xsl:choose
</xsl:template>
4. That's it. I hope even if the example isn't very exciting, you see
the power behind this.
cons: It doubles your rendering time, you have a complicated
workflow (automate it with ant), you have to write several stylesheets.
pros: you can do things you can't do with standard XSL-FO.
I hope I'm not spamming here, but I was happy getting this done.
Thanks Jeremias, for this cool idea.
Hannes
Jeremias Maerki wrote:
> On 07.03.2006 20:37:53 Johannes Künsebeck wrote:
>
>> Hi,
>> I try to build a complex design with fop, the design-template can be
>> seen here :
>>
>> http://yucca-net.de/data/gild.pdf
>>
>> After toying around with fop, I'm not sure if it is possible to realize
>> this design with fop.
>> I got alternating page-masters and the background-design working.
>> I can format a fo:block with the design for the even page, I can format
>> a fo:block with the design for the odd page, but I can't specify when to
>> use which (the problem you can't see in the template is that it must be
>> possible to put two or more workshops on one page).
>>
>> My thoughts so far (not very far):
>> - use float="inside|outside" (XSL1.1) but that's not supported in fop
>>
>
> Right. That would probably have been the best approach if it were
> implemented.
>
>
>> - put date and time infos in region-start/end, but how can I synchronize
>> startpositions with the flow?
>>
>
> You can't. Not with multiple workshops on one page.
>
>
>> So my questions are
>> - Do you think it is possible to realize this with XSLT-FO (& maybe
>> extensions)
>>
>
> Yes, I think so.
>
>
>> - Do you think it is possible to realize this with fop?
>>
>
> Not without difficulties. If you can restrict to one workshop per page,
> it's easy. If you want to have multiple workshops you will probably need
> to do a detour. Just an idea: Render the text for the individual
> workshops using a special reduced XSLT using the area tree XML renderer
> with the latest FOP version. You can then determine the height of each
> workshop from the generated XML format. Based on that knowledge you can
> define the distribution of the individual workshops yourself and put one
> page per page-sequence so you can control yourself whether you have a
> left or a right page. Then put the time info in a table together with
> the workshop info, either on the left or right side.
>
> I haven't tried but you may be able to emulate side floats using
> absolutely positioned block-containers with the latest FOP release.
>
>
>> - If yes, what do I have to read, to get it working
>> thanks in advance, Hann*
>> *
>>
>
> Good luck!
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> 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
Re: alternatives to floats in fop
Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I don't think that works in Johannes' case since you can't account for
the left/right pages (inside/outside).
On 21.03.2006 10:47:52 Joachim Pfaff wrote:
> Hello Johannes,
>
> I read this thread and wondered if there is no other way. I don't
> like it to interrupt the fo-rendering, doing some stuff and then keep
>
> on going ;)
>
> Now it turned out, that i had to create a very simple list. During
> studying the definition of Formating Objects for Lists [1] i asked
> myself if this would not be a much more 'nicer' way in creating what
> you want to.
>
> As the compliance-page [2] indicates, all needed objects are
> implemented.
>
> What do you, and what does Jeremias think about this way?
>
> Greetings,
>
> Joachim
>
> [1] http://www.w3.org/TR/xsl/slice6.html#section-N17076-Formatting-
> Objects-for-Lists
> [2] http://xmlgraphics.apache.org/fop/compliance.html#fo-object-list-
> section
>
>
> On 20 Mar 2006 at 14:42, Johannes Künsebeck wrote:
>
> > Thank you Jeremias, that's the solution!
> > This "2-pass"-approach is very cool, I can't imagine designs that aren't
> > possible with it.
> > If you can't wait for XSL-FO2.0, use this as a hack for "layout-driven"
> > documents.
> > I just summarize it for the list, because I think it can be helpful in
> > other situations, too.
> > [...]
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: alternatives to floats in fop
Posted by Joachim Pfaff <Jo...@gmx.net>.
Hello Johannes,
I read this thread and wondered if there is no other way. I don't
like it to interrupt the fo-rendering, doing some stuff and then keep
on going ;)
Now it turned out, that i had to create a very simple list. During
studying the definition of Formating Objects for Lists [1] i asked
myself if this would not be a much more 'nicer' way in creating what
you want to.
As the compliance-page [2] indicates, all needed objects are
implemented.
What do you, and what does Jeremias think about this way?
Greetings,
Joachim
[1] http://www.w3.org/TR/xsl/slice6.html#section-N17076-Formatting-
Objects-for-Lists
[2] http://xmlgraphics.apache.org/fop/compliance.html#fo-object-list-
section
On 20 Mar 2006 at 14:42, Johannes Künsebeck wrote:
> Thank you Jeremias, that's the solution!
> This "2-pass"-approach is very cool, I can't imagine designs that aren't
> possible with it.
> If you can't wait for XSL-FO2.0, use this as a hack for "layout-driven"
> documents.
> I just summarize it for the list, because I think it can be helpful in
> other situations, too.
> [...]
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org