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:[email protected]] 
>
> 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:[email protected]] 
>> Sent: Monday, 7 June 2010 7:04 p.m.
>> To: [email protected]; [email protected]
>> 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:[email protected]]
>>
>> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to