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 Trevor Nicholls <tr...@castingthevoid.com> on 2010/06/03 17:31:14 UTC

anchors/bookmarks problem

Hi

I am having a little trouble with FOP 0.95 and <fox:destination> elements in
list items.

XML fragment is something like the following, where a step is a numbered
list item, and a target is a potential bookmark or hyperlink target:

 ----
 <steps>
  <step>
   <target id="one">One</target>
   <target id="first">First</target>
   <para>First step.</para>
  </step>
 </steps>
 ----

XSL-FO for "steps" generates a standard list block, and for "list" a
standard list-item. Targets generate an <fo:inline id="ID"> element which
contains a zero width space (because an empty inline element causes FOP to
crash with a NPE), and each group of targets is enclosed in an <fo:block>
(because fo:inline cannot be a direct child of fo:flow, and some targets
are.

So here's the target bit of my XSL-FO:

 ----
 <xsl:template match="target">
  <xsl:choose>
   <xsl:when test="preceding-sibling::*[1][self::target]" />
   <xsl:otherwise>
    <xsl:apply-templates select="." mode="first-anchor" />
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="target" mode="first-anchor">
  <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
font-size="1">
   <xsl:apply-templates select="." mode="anchor" />
  </fo:block>
 </xsl:template>

 <xsl:template match="target" mode="anchor">
  <xsl:variable name="tid" as="xs:string" select="@id" />
  <fo:inline id="{$tid}">&#8203;</fo:inline>
  <fox:destination internal-destination="{$tid}" />
  <xsl:apply-templates select="following-sibling::*[1][self::target]"
mode="anchor" />
 </xsl:template>
 ----

The def.space-none attribute set ensures that space-before and space-after
is zero. I have a named template for normal blocks which detects when it is
the first block after a group of targets and sets space-before to zero. So
the only thing disturbing the alignment of the list-item-label and the first
list-item-block content is the 1px line-height block containing the id'ed
inline(s) and the fox:bookmark(s).

Is there a way of eliminating the vertical space contributed by that block
so that the list item aligns properly with its label?

Or am I tackling this all wrong?

Cheers
Trevor



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


Re: anchors/bookmarks problem

Posted by Pascal Sancho <pa...@takoma.fr>.
Trevor,

the 2 successive fo:block/fox:destination work fine for me, even with
FOP 0.95.
If you get an NPE, there is something else that interacts.

--
Pascal


Le 08/06/2010 10:20, Trevor Nicholls a écrit :
> Hi Pascal
>
> That's what I started with: one target (one fo:block/fox:destination) was
> fine, but a second would crash fop with an NPE. (I'm using 0.95).
> Experimenting I found that if I put something, anything, in the fo:block
> then the NPE went away - but then I had the alignment issue to deal with.
>
> Cheers
> T
>
> -----Original Message-----
> From: Pascal Sancho [mailto:pascal.sancho@takoma.fr] 
>
> Hi Trevor,
> you can use a simpler construction:
> <fo:block id="one"><fox:destination internal-destination="one"/></fo:block>
> <fo:block id="first"><fox:destination
> internal-destination="first"/></fo:block>
> That should not generate any area (since empty blocks), so that should
> do the trick.
>
> Note that 'px' is not a recommended unit as it is relative to ... screen.
>
> --
> Pascal
>
> Le 07/06/2010 19:46, Trevor Nicholls a écrit :
>   
>> Hi Georg
>>
>> Here is the fo fragment produced by the stylesheet in my first post.
>>  ----
>>  <fo:list-block space-before.minimum="0.8em" space-before.optimum="1em"
>> space-before.maximum="1.2em" space-after.minimum="0.8em"
>> space-after.optimum="1em" space-after.maximum="1.2em"
>> provisional-label-separation="0.85mm"
>> provisional-distance-between-starts="8.47mm">
>>  <fo:list-item space-before.minimum="0.8em" space-before.optimum="1em"
>> space-before.maximum="1.2em" relative-align="baseline">
>>  <fo:list-item-label end-indent="label-end()">
>>  <fo:block text-align="start">1.</fo:block>
>>  </fo:list-item-label>
>>  <fo:list-item-body start-indent="body-start()">
>>  <fo:block space-before="0em" space-after="0em">
>>  <fo:block space-before="0px" space-after="0px" line-height="1px"
>> font-size="1">
>>  <fo:inline id="one"> </fo:inline>
>>  <fox:destination internal-destination="one"/>
>>  <fo:inline id="first"> </fo:inline>
>>  <fox:destination internal-destination="first"/>
>>  </fo:block>
>>  <fo:block space-before.minimum="0em" space-before.optimum="0em"
>> space-before.maximum="0em" space-after.minimum="0.4em"
>> space-after.optimum="0.5em" space-after.maximum="0.6em">First
>> step.</fo:block>
>>  </fo:block>
>>  </fo:list-item-body>
>>  </fo:list-item>
>>  </fo:list-block>
>>  ----
>>
>> Since that post I have modified the block which contains the
>>     
> fox:destination
>   
>> elements so that it has negative space-after, and that appears to allow
>>     
> the
>   
>> list item labels to line up with the list items proper. That may be a
>> pragmatic solution but am I doing this the best way? Without the target
>> elements in the XML, the block containing the text "First step." would
>>     
> have
>   
>> the standard space-before of 0.5+/-0.1em, and this space would be
>>     
> collapsed
>   
>> (or ignored) at the top of list items. The code has had to become a lot
>>     
> more
>   
>> complex to change those space-before's to 0, and I would be a lot more
>> confident if I hadn't had to do that :-)
>>
>> Cheers
>> T
>>
>> -----Original Message-----
>> From: Georg Datterl [mailto:georg.datterl@geneon.de] 
>> Sent: Monday, 7 June 2010 7:04 p.m.
>> To: fop-users@xmlgraphics.apache.org; trevor@castingthevoid.com
>> Subject: AW: anchors/bookmarks problem
>>
>> Hi Trevor,
>>
>> Can you post the final fo code as well, please?
>>
>> Regards,
>>
>> Georg Datterl
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Trevor Nicholls [mailto:trevor@castingthevoid.com]
>>
>> Hi
>>
>> I am having a little trouble with FOP 0.95 and <fox:destination> elements
>>     
> in
>   
>> list items.
>>
>> XML fragment is something like the following, where a step is a numbered
>> list item, and a target is a potential bookmark or hyperlink target:
>>
>>  ----
>>  <steps>
>>   <step>
>>    <target id="one">One</target>
>>    <target id="first">First</target>
>>    <para>First step.</para>
>>   </step>
>>  </steps>
>>  ----
>>
>> XSL-FO for "steps" generates a standard list block, and for "list" a
>> standard list-item. Targets generate an <fo:inline id="ID"> element which
>> contains a zero width space (because an empty inline element causes FOP to
>> crash with a NPE), and each group of targets is enclosed in an <fo:block>
>> (because fo:inline cannot be a direct child of fo:flow, and some targets
>> are.
>>
>> So here's the target bit of my XSL-FO:
>>
>>  ----
>>  <xsl:template match="target">
>>   <xsl:choose>
>>    <xsl:when test="preceding-sibling::*[1][self::target]" />
>>    <xsl:otherwise>
>>     <xsl:apply-templates select="." mode="first-anchor" />
>>    </xsl:otherwise>
>>   </xsl:choose>
>>  </xsl:template>
>>
>>  <xsl:template match="target" mode="first-anchor">
>>   <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
>> font-size="1">
>>    <xsl:apply-templates select="." mode="anchor" />
>>   </fo:block>
>>  </xsl:template>
>>
>>  <xsl:template match="target" mode="anchor">
>>   <xsl:variable name="tid" as="xs:string" select="@id" />
>>   <fo:inline id="{$tid}">&#8203;</fo:inline>
>>   <fox:destination internal-destination="{$tid}" />
>>   <xsl:apply-templates select="following-sibling::*[1][self::target]"
>> mode="anchor" />
>>  </xsl:template>
>>  ----
>>
>> The def.space-none attribute set ensures that space-before and space-after
>> is zero. I have a named template for normal blocks which detects when it
>>     
> is
>   
>> the first block after a group of targets and sets space-before to zero. So
>> the only thing disturbing the alignment of the list-item-label and the
>>     
> first
>   
>> list-item-block content is the 1px line-height block containing the id'ed
>> inline(s) and the fox:bookmark(s).
>>
>> Is there a way of eliminating the vertical space contributed by that block
>> so that the list item aligns properly with its label?
>>
>> Or am I tackling this all wrong?
>>
>> Cheers
>> Trevor
>>     


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


RE: anchors/bookmarks problem

Posted by Trevor Nicholls <tr...@castingthevoid.com>.
Hi Pascal

That's what I started with: one target (one fo:block/fox:destination) was
fine, but a second would crash fop with an NPE. (I'm using 0.95).
Experimenting I found that if I put something, anything, in the fo:block
then the NPE went away - but then I had the alignment issue to deal with.

Cheers
T

-----Original Message-----
From: Pascal Sancho [mailto:pascal.sancho@takoma.fr] 
Sent: Tuesday, 8 June 2010 7:35 p.m.
To: fop-users@xmlgraphics.apache.org
Subject: Re: anchors/bookmarks problem

Hi Trevor,
you can use a simpler construction:
<fo:block id="one"><fox:destination internal-destination="one"/></fo:block>
<fo:block id="first"><fox:destination
internal-destination="first"/></fo:block>
That should not generate any area (since empty blocks), so that should
do the trick.

Note that 'px' is not a recommended unit as it is relative to ... screen.

--
Pascal

Le 07/06/2010 19:46, Trevor Nicholls a écrit :
> Hi Georg
>
> Here is the fo fragment produced by the stylesheet in my first post.
>  ----
>  <fo:list-block space-before.minimum="0.8em" space-before.optimum="1em"
> space-before.maximum="1.2em" space-after.minimum="0.8em"
> space-after.optimum="1em" space-after.maximum="1.2em"
> provisional-label-separation="0.85mm"
> provisional-distance-between-starts="8.47mm">
>  <fo:list-item space-before.minimum="0.8em" space-before.optimum="1em"
> space-before.maximum="1.2em" relative-align="baseline">
>  <fo:list-item-label end-indent="label-end()">
>  <fo:block text-align="start">1.</fo:block>
>  </fo:list-item-label>
>  <fo:list-item-body start-indent="body-start()">
>  <fo:block space-before="0em" space-after="0em">
>  <fo:block space-before="0px" space-after="0px" line-height="1px"
> font-size="1">
>  <fo:inline id="one"> </fo:inline>
>  <fox:destination internal-destination="one"/>
>  <fo:inline id="first"> </fo:inline>
>  <fox:destination internal-destination="first"/>
>  </fo:block>
>  <fo:block space-before.minimum="0em" space-before.optimum="0em"
> space-before.maximum="0em" space-after.minimum="0.4em"
> space-after.optimum="0.5em" space-after.maximum="0.6em">First
> step.</fo:block>
>  </fo:block>
>  </fo:list-item-body>
>  </fo:list-item>
>  </fo:list-block>
>  ----
>
> Since that post I have modified the block which contains the
fox:destination
> elements so that it has negative space-after, and that appears to allow
the
> list item labels to line up with the list items proper. That may be a
> pragmatic solution but am I doing this the best way? Without the target
> elements in the XML, the block containing the text "First step." would
have
> the standard space-before of 0.5+/-0.1em, and this space would be
collapsed
> (or ignored) at the top of list items. The code has had to become a lot
more
> complex to change those space-before's to 0, and I would be a lot more
> confident if I hadn't had to do that :-)
>
> Cheers
> T
>
> -----Original Message-----
> From: Georg Datterl [mailto:georg.datterl@geneon.de] 
> Sent: Monday, 7 June 2010 7:04 p.m.
> To: fop-users@xmlgraphics.apache.org; trevor@castingthevoid.com
> Subject: AW: anchors/bookmarks problem
>
> Hi Trevor,
>
> Can you post the final fo code as well, please?
>
> Regards,
>
> Georg Datterl
>
> ------ Kontakt ------
>
> Georg Datterl
>
> Geneon media solutions gmbh
> Gutenstetter Straße 8a
> 90449 Nürnberg
>
> HRB Nürnberg: 17193
> Geschäftsführer: Yong-Harry Steiert
>
> Tel.: 0911/36 78 88 - 26
> Fax: 0911/36 78 88 - 20
>
> www.geneon.de
>
> Weitere Mitglieder der Willmy MediaGroup:
>
> IRS Integrated Realization Services GmbH:    www.irs-nbg.de
> Willmy PrintMedia GmbH:                            www.willmy.de
> Willmy Consult & Content GmbH:                 www.willmycc.de
>
> -----Ursprüngliche Nachricht-----
> Von: Trevor Nicholls [mailto:trevor@castingthevoid.com]
> Gesendet: Donnerstag, 3. Juni 2010 17:31
> An: fop-users@xmlgraphics.apache.org
> Betreff: anchors/bookmarks problem
>
> Hi
>
> I am having a little trouble with FOP 0.95 and <fox:destination> elements
in
> list items.
>
> XML fragment is something like the following, where a step is a numbered
> list item, and a target is a potential bookmark or hyperlink target:
>
>  ----
>  <steps>
>   <step>
>    <target id="one">One</target>
>    <target id="first">First</target>
>    <para>First step.</para>
>   </step>
>  </steps>
>  ----
>
> XSL-FO for "steps" generates a standard list block, and for "list" a
> standard list-item. Targets generate an <fo:inline id="ID"> element which
> contains a zero width space (because an empty inline element causes FOP to
> crash with a NPE), and each group of targets is enclosed in an <fo:block>
> (because fo:inline cannot be a direct child of fo:flow, and some targets
> are.
>
> So here's the target bit of my XSL-FO:
>
>  ----
>  <xsl:template match="target">
>   <xsl:choose>
>    <xsl:when test="preceding-sibling::*[1][self::target]" />
>    <xsl:otherwise>
>     <xsl:apply-templates select="." mode="first-anchor" />
>    </xsl:otherwise>
>   </xsl:choose>
>  </xsl:template>
>
>  <xsl:template match="target" mode="first-anchor">
>   <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
> font-size="1">
>    <xsl:apply-templates select="." mode="anchor" />
>   </fo:block>
>  </xsl:template>
>
>  <xsl:template match="target" mode="anchor">
>   <xsl:variable name="tid" as="xs:string" select="@id" />
>   <fo:inline id="{$tid}">&#8203;</fo:inline>
>   <fox:destination internal-destination="{$tid}" />
>   <xsl:apply-templates select="following-sibling::*[1][self::target]"
> mode="anchor" />
>  </xsl:template>
>  ----
>
> The def.space-none attribute set ensures that space-before and space-after
> is zero. I have a named template for normal blocks which detects when it
is
> the first block after a group of targets and sets space-before to zero. So
> the only thing disturbing the alignment of the list-item-label and the
first
> list-item-block content is the 1px line-height block containing the id'ed
> inline(s) and the fox:bookmark(s).
>
> Is there a way of eliminating the vertical space contributed by that block
> so that the list item aligns properly with its label?
>
> Or am I tackling this all wrong?
>
> Cheers
> Trevor
>   


---------------------------------------------------------------------
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: anchors/bookmarks problem

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi Trevor,
you can use a simpler construction:
<fo:block id="one"><fox:destination internal-destination="one"/></fo:block>
<fo:block id="first"><fox:destination
internal-destination="first"/></fo:block>
That should not generate any area (since empty blocks), so that should
do the trick.

Note that 'px' is not a recommended unit as it is relative to ... screen.

--
Pascal

Le 07/06/2010 19:46, Trevor Nicholls a écrit :
> Hi Georg
>
> Here is the fo fragment produced by the stylesheet in my first post.
>  ----
>  <fo:list-block space-before.minimum="0.8em" space-before.optimum="1em"
> space-before.maximum="1.2em" space-after.minimum="0.8em"
> space-after.optimum="1em" space-after.maximum="1.2em"
> provisional-label-separation="0.85mm"
> provisional-distance-between-starts="8.47mm">
>  <fo:list-item space-before.minimum="0.8em" space-before.optimum="1em"
> space-before.maximum="1.2em" relative-align="baseline">
>  <fo:list-item-label end-indent="label-end()">
>  <fo:block text-align="start">1.</fo:block>
>  </fo:list-item-label>
>  <fo:list-item-body start-indent="body-start()">
>  <fo:block space-before="0em" space-after="0em">
>  <fo:block space-before="0px" space-after="0px" line-height="1px"
> font-size="1">
>  <fo:inline id="one"> </fo:inline>
>  <fox:destination internal-destination="one"/>
>  <fo:inline id="first"> </fo:inline>
>  <fox:destination internal-destination="first"/>
>  </fo:block>
>  <fo:block space-before.minimum="0em" space-before.optimum="0em"
> space-before.maximum="0em" space-after.minimum="0.4em"
> space-after.optimum="0.5em" space-after.maximum="0.6em">First
> step.</fo:block>
>  </fo:block>
>  </fo:list-item-body>
>  </fo:list-item>
>  </fo:list-block>
>  ----
>
> Since that post I have modified the block which contains the fox:destination
> elements so that it has negative space-after, and that appears to allow the
> list item labels to line up with the list items proper. That may be a
> pragmatic solution but am I doing this the best way? Without the target
> elements in the XML, the block containing the text "First step." would have
> the standard space-before of 0.5+/-0.1em, and this space would be collapsed
> (or ignored) at the top of list items. The code has had to become a lot more
> complex to change those space-before's to 0, and I would be a lot more
> confident if I hadn't had to do that :-)
>
> Cheers
> T
>
> -----Original Message-----
> From: Georg Datterl [mailto:georg.datterl@geneon.de] 
> Sent: Monday, 7 June 2010 7:04 p.m.
> To: fop-users@xmlgraphics.apache.org; trevor@castingthevoid.com
> Subject: AW: anchors/bookmarks problem
>
> Hi Trevor,
>
> Can you post the final fo code as well, please?
>
> Regards,
>
> Georg Datterl
>
> ------ Kontakt ------
>
> Georg Datterl
>
> Geneon media solutions gmbh
> Gutenstetter Straße 8a
> 90449 Nürnberg
>
> HRB Nürnberg: 17193
> Geschäftsführer: Yong-Harry Steiert
>
> Tel.: 0911/36 78 88 - 26
> Fax: 0911/36 78 88 - 20
>
> www.geneon.de
>
> Weitere Mitglieder der Willmy MediaGroup:
>
> IRS Integrated Realization Services GmbH:    www.irs-nbg.de
> Willmy PrintMedia GmbH:                            www.willmy.de
> Willmy Consult & Content GmbH:                 www.willmycc.de
>
> -----Ursprüngliche Nachricht-----
> Von: Trevor Nicholls [mailto:trevor@castingthevoid.com]
> Gesendet: Donnerstag, 3. Juni 2010 17:31
> An: fop-users@xmlgraphics.apache.org
> Betreff: anchors/bookmarks problem
>
> Hi
>
> I am having a little trouble with FOP 0.95 and <fox:destination> elements in
> list items.
>
> XML fragment is something like the following, where a step is a numbered
> list item, and a target is a potential bookmark or hyperlink target:
>
>  ----
>  <steps>
>   <step>
>    <target id="one">One</target>
>    <target id="first">First</target>
>    <para>First step.</para>
>   </step>
>  </steps>
>  ----
>
> XSL-FO for "steps" generates a standard list block, and for "list" a
> standard list-item. Targets generate an <fo:inline id="ID"> element which
> contains a zero width space (because an empty inline element causes FOP to
> crash with a NPE), and each group of targets is enclosed in an <fo:block>
> (because fo:inline cannot be a direct child of fo:flow, and some targets
> are.
>
> So here's the target bit of my XSL-FO:
>
>  ----
>  <xsl:template match="target">
>   <xsl:choose>
>    <xsl:when test="preceding-sibling::*[1][self::target]" />
>    <xsl:otherwise>
>     <xsl:apply-templates select="." mode="first-anchor" />
>    </xsl:otherwise>
>   </xsl:choose>
>  </xsl:template>
>
>  <xsl:template match="target" mode="first-anchor">
>   <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
> font-size="1">
>    <xsl:apply-templates select="." mode="anchor" />
>   </fo:block>
>  </xsl:template>
>
>  <xsl:template match="target" mode="anchor">
>   <xsl:variable name="tid" as="xs:string" select="@id" />
>   <fo:inline id="{$tid}">&#8203;</fo:inline>
>   <fox:destination internal-destination="{$tid}" />
>   <xsl:apply-templates select="following-sibling::*[1][self::target]"
> mode="anchor" />
>  </xsl:template>
>  ----
>
> The def.space-none attribute set ensures that space-before and space-after
> is zero. I have a named template for normal blocks which detects when it is
> the first block after a group of targets and sets space-before to zero. So
> the only thing disturbing the alignment of the list-item-label and the first
> list-item-block content is the 1px line-height block containing the id'ed
> inline(s) and the fox:bookmark(s).
>
> Is there a way of eliminating the vertical space contributed by that block
> so that the list item aligns properly with its label?
>
> Or am I tackling this all wrong?
>
> Cheers
> Trevor
>   


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


RE: anchors/bookmarks problem

Posted by Trevor Nicholls <tr...@castingthevoid.com>.
Hi Georg

Here is the fo fragment produced by the stylesheet in my first post.
 ----
 <fo:list-block space-before.minimum="0.8em" space-before.optimum="1em"
space-before.maximum="1.2em" space-after.minimum="0.8em"
space-after.optimum="1em" space-after.maximum="1.2em"
provisional-label-separation="0.85mm"
provisional-distance-between-starts="8.47mm">
 <fo:list-item space-before.minimum="0.8em" space-before.optimum="1em"
space-before.maximum="1.2em" relative-align="baseline">
 <fo:list-item-label end-indent="label-end()">
 <fo:block text-align="start">1.</fo:block>
 </fo:list-item-label>
 <fo:list-item-body start-indent="body-start()">
 <fo:block space-before="0em" space-after="0em">
 <fo:block space-before="0px" space-after="0px" line-height="1px"
font-size="1">
 <fo:inline id="one"> </fo:inline>
 <fox:destination internal-destination="one"/>
 <fo:inline id="first"> </fo:inline>
 <fox:destination internal-destination="first"/>
 </fo:block>
 <fo:block space-before.minimum="0em" space-before.optimum="0em"
space-before.maximum="0em" space-after.minimum="0.4em"
space-after.optimum="0.5em" space-after.maximum="0.6em">First
step.</fo:block>
 </fo:block>
 </fo:list-item-body>
 </fo:list-item>
 </fo:list-block>
 ----

Since that post I have modified the block which contains the fox:destination
elements so that it has negative space-after, and that appears to allow the
list item labels to line up with the list items proper. That may be a
pragmatic solution but am I doing this the best way? Without the target
elements in the XML, the block containing the text "First step." would have
the standard space-before of 0.5+/-0.1em, and this space would be collapsed
(or ignored) at the top of list items. The code has had to become a lot more
complex to change those space-before's to 0, and I would be a lot more
confident if I hadn't had to do that :-)

Cheers
T

-----Original Message-----
From: Georg Datterl [mailto:georg.datterl@geneon.de] 
Sent: Monday, 7 June 2010 7:04 p.m.
To: fop-users@xmlgraphics.apache.org; trevor@castingthevoid.com
Subject: AW: anchors/bookmarks problem

Hi Trevor,

Can you post the final fo code as well, please?

Regards,

Georg Datterl

------ Kontakt ------

Georg Datterl

Geneon media solutions gmbh
Gutenstetter Straße 8a
90449 Nürnberg

HRB Nürnberg: 17193
Geschäftsführer: Yong-Harry Steiert

Tel.: 0911/36 78 88 - 26
Fax: 0911/36 78 88 - 20

www.geneon.de

Weitere Mitglieder der Willmy MediaGroup:

IRS Integrated Realization Services GmbH:    www.irs-nbg.de
Willmy PrintMedia GmbH:                            www.willmy.de
Willmy Consult & Content GmbH:                 www.willmycc.de

-----Ursprüngliche Nachricht-----
Von: Trevor Nicholls [mailto:trevor@castingthevoid.com]
Gesendet: Donnerstag, 3. Juni 2010 17:31
An: fop-users@xmlgraphics.apache.org
Betreff: anchors/bookmarks problem

Hi

I am having a little trouble with FOP 0.95 and <fox:destination> elements in
list items.

XML fragment is something like the following, where a step is a numbered
list item, and a target is a potential bookmark or hyperlink target:

 ----
 <steps>
  <step>
   <target id="one">One</target>
   <target id="first">First</target>
   <para>First step.</para>
  </step>
 </steps>
 ----

XSL-FO for "steps" generates a standard list block, and for "list" a
standard list-item. Targets generate an <fo:inline id="ID"> element which
contains a zero width space (because an empty inline element causes FOP to
crash with a NPE), and each group of targets is enclosed in an <fo:block>
(because fo:inline cannot be a direct child of fo:flow, and some targets
are.

So here's the target bit of my XSL-FO:

 ----
 <xsl:template match="target">
  <xsl:choose>
   <xsl:when test="preceding-sibling::*[1][self::target]" />
   <xsl:otherwise>
    <xsl:apply-templates select="." mode="first-anchor" />
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="target" mode="first-anchor">
  <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
font-size="1">
   <xsl:apply-templates select="." mode="anchor" />
  </fo:block>
 </xsl:template>

 <xsl:template match="target" mode="anchor">
  <xsl:variable name="tid" as="xs:string" select="@id" />
  <fo:inline id="{$tid}">&#8203;</fo:inline>
  <fox:destination internal-destination="{$tid}" />
  <xsl:apply-templates select="following-sibling::*[1][self::target]"
mode="anchor" />
 </xsl:template>
 ----

The def.space-none attribute set ensures that space-before and space-after
is zero. I have a named template for normal blocks which detects when it is
the first block after a group of targets and sets space-before to zero. So
the only thing disturbing the alignment of the list-item-label and the first
list-item-block content is the 1px line-height block containing the id'ed
inline(s) and the fox:bookmark(s).

Is there a way of eliminating the vertical space contributed by that block
so that the list item aligns properly with its label?

Or am I tackling this all wrong?

Cheers
Trevor



---------------------------------------------------------------------
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


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


AW: anchors/bookmarks problem

Posted by Georg Datterl <ge...@geneon.de>.
Hi Trevor,

Can you post the final fo code as well, please?

Regards,

Georg Datterl

------ Kontakt ------

Georg Datterl

Geneon media solutions gmbh
Gutenstetter Straße 8a
90449 Nürnberg

HRB Nürnberg: 17193
Geschäftsführer: Yong-Harry Steiert

Tel.: 0911/36 78 88 - 26
Fax: 0911/36 78 88 - 20

www.geneon.de

Weitere Mitglieder der Willmy MediaGroup:

IRS Integrated Realization Services GmbH:    www.irs-nbg.de
Willmy PrintMedia GmbH:                            www.willmy.de
Willmy Consult & Content GmbH:                 www.willmycc.de

-----Ursprüngliche Nachricht-----
Von: Trevor Nicholls [mailto:trevor@castingthevoid.com]
Gesendet: Donnerstag, 3. Juni 2010 17:31
An: fop-users@xmlgraphics.apache.org
Betreff: anchors/bookmarks problem

Hi

I am having a little trouble with FOP 0.95 and <fox:destination> elements in
list items.

XML fragment is something like the following, where a step is a numbered
list item, and a target is a potential bookmark or hyperlink target:

 ----
 <steps>
  <step>
   <target id="one">One</target>
   <target id="first">First</target>
   <para>First step.</para>
  </step>
 </steps>
 ----

XSL-FO for "steps" generates a standard list block, and for "list" a
standard list-item. Targets generate an <fo:inline id="ID"> element which
contains a zero width space (because an empty inline element causes FOP to
crash with a NPE), and each group of targets is enclosed in an <fo:block>
(because fo:inline cannot be a direct child of fo:flow, and some targets
are.

So here's the target bit of my XSL-FO:

 ----
 <xsl:template match="target">
  <xsl:choose>
   <xsl:when test="preceding-sibling::*[1][self::target]" />
   <xsl:otherwise>
    <xsl:apply-templates select="." mode="first-anchor" />
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="target" mode="first-anchor">
  <fo:block xsl:use-attribute-sets="def.space-none" line-height="1px"
font-size="1">
   <xsl:apply-templates select="." mode="anchor" />
  </fo:block>
 </xsl:template>

 <xsl:template match="target" mode="anchor">
  <xsl:variable name="tid" as="xs:string" select="@id" />
  <fo:inline id="{$tid}">&#8203;</fo:inline>
  <fox:destination internal-destination="{$tid}" />
  <xsl:apply-templates select="following-sibling::*[1][self::target]"
mode="anchor" />
 </xsl:template>
 ----

The def.space-none attribute set ensures that space-before and space-after
is zero. I have a named template for normal blocks which detects when it is
the first block after a group of targets and sets space-before to zero. So
the only thing disturbing the alignment of the list-item-label and the first
list-item-block content is the 1px line-height block containing the id'ed
inline(s) and the fox:bookmark(s).

Is there a way of eliminating the vertical space contributed by that block
so that the list item aligns properly with its label?

Or am I tackling this all wrong?

Cheers
Trevor



---------------------------------------------------------------------
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