xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Schraitle <tom_s...@web.de>
Subject Re: Cross references
Date Mon, 05 Oct 2015 14:08:58 GMT

On Mon, 5 Oct 2015 13:16:35 +0000
Franz de Copenhague <franzdecopenhague@outlook.com> wrote:

> Thank you for the information. I am writing XML directly without any
> XSLT transformation.

Just to be clear: you write the FO *manually*? Without any input XML?

> Based on your comments, My application must know
> in advance the content of the fo:block target in order to populate
> the cross reference (aka basic-link) with the target content.

Yes, your application has to retrieve the target element somehow.
However, I 

In case you would use XSLT, here is the general approach:

I don't know your XML input, but I guess, it has some kind of id
attribute which is unique. With xsl:key you can create a kind of array
of all ids in your document:

  <xsl:key name="id" match="*" use="@id"/>

Of course, you need an element that is used for cross references. Let's
play this example with DocBook's <xref/> element and its linkend
attribute. For example, in your input XML, you could point to somewhere
else in your document like this:

  <xref linkend="intro"/>

In the xref-template, to retrieve the target element is simply an

  <xsl:template match="xref">
    <xsl:variable name="target" select="key('id', @linkend)"/>
    <!-- ... --->

That will give you the element node where the <xref/> is pointing to.

Depending on how your target element is structured, it is probably not
difficult to extract a title or any other relevant information that you
need to insert its content as text into <fo:basic-link>.

> I understand that it is hard to implement by FOP because the target
> with the content could be in any part of the fo:flow, inclusive the
> target can be in a different page-sequence.

Yes. There are issues that are better delegated to FO and its formatter.
On the other hand, with XSLT you can use templates and the right XPath
to transform your input XML into the correct FO representation.

Hope that helps. :)

    Thomas Schraitle

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

View raw message