Re: [xep-support] Inter-document references

From: Nikolai Grigoriev (grig@renderx.com)
Date: Thu Apr 17 2003 - 23:47:45 PDT

  • Next message: Jim Melton: "Re: [xep-support] Inter-document references"

    Jim,

    > The only idea I've had so far is to write a new XSLT stylesheet that
    > processes each of my documents (one at a time, manually --- since I
    haven't
    > gotten around to worrying about scripting issues) and outputs some sort of
    > file containing nothing beyond the "values" of every symbol in that
    > document. Then, when I'm processing document 5 through my "real"
    > stylesheet, it would somehow access all of the "symbol" files and pick up
    > the chapter/section number and title.
    >
    > Question 1) Does that seem like a reasonable approach? Are there better
    > approaches that I have managed to overlook or suppress?

    I wonder why do you need a separate"symbol" file. If all parts are similar
    in their structure, you can set up a generic template to exract
    section/chapter
    references from both local and remote documents. To automate the thing,
    you will need an index of all parts to map numbers to file names,
    conveniently
    specified in a separate XML file. More or less like this (untested, just to
    show
    the idea):

    parts-index.xml:

    <parts>
       <part number="1" file="SQL-20030418-part1-rev3"/>
       <part number="2" file="SQL-20030310-part2-rev12"/>
       ...
    </parts>

    Stylesheet (very roughly):

    <!-- Global variable to store an array of part names -->
    <xsl:variable name="parts"
                  select="document('parts-index')/parts/part"/>

    <!-- Template to build section name -->
    <xsl:template name="get-section-name">
        <xsl:param name="root" select="/">
        <xsl:param name="ref"/>

        <xsl:for-each select="$root//*[@id=$ref][self::chapter or
    self::section]">
            <xsl:number format="1.1.1.1.1.1. " level="multiple"
                        count="chapter | section" from="$root" />
            <xsl:value-of select="title"/>
        </xsl:for-each>
    </xsl:template>

    <!-- Local link: root is /, internal destination -->
    <xsl:template match="docref">
        <fo:basic-link color="blue"
                       internal-destination={@ref}>
            <xsl:call-template name="get-section-name">
                <xsl:with-param name="ref" select="@ref"/>
            </xsl:call-template>
        </fo:basic-link>
    </xsl:template>

    <!-- Remote link: root is retrieved by document(), external destination -->
    <xsl:template match="docref">
        <xsl:variable name="filename" select="$parts[@part]/@file"/>
        <fo:basic-link color="blue"

    external-destination="url(file://{$filename}.pdf#{@ref})">
            <xsl:call-template name="get-section-name">
                <xsl:with-param name="root" select="document(concat($filename,
    ".xml")"/>
                <xsl:with-param name="ref" select="@ref"/>
            </xsl:call-template>
        </fo:basic-link>
    </xsl:template>

    > Question 2) Would it be better if that "symbol" file were a plain text
    file
    > (how would I access such information in XSLT?) or an XML file (something
    > like <part2References><reference number="4"
    > title="Concepts/><reference.../></part2References>)? I assume that the
    > information contained in an XML file would be more easily accessed in my
    XSLT.

    That's true. But my suggestion is to work directly from source files,
    without
    intermediate data. Using document() function, you can work conveniently
    with multiple source files.

    > Question 3) Once I have that information, how can I turn the text (e.g.,
    > Section 4.2, "Data types", in Part 2) into a "hot link" that will cause
    > Acrobat to open the file containing part 2 and position it at the start of
    > Section 4.2 --- or at least on the same page? (I'm aware of the
    > external-destination attribute, but have not been successful at making
    > referenced PDF documents open at the right place.)

    This requires support for named destinations in PDF files produced
    by XEP. It is not yet available in the current version, but already
    implemented and under final testing; so in few weeks at most it will
    be delivered to XEP users. The syntax will be as follows:

    external-destination="url(file://somefile.pdf#someplace)"

    will open PDF file 'somefile.pdf' in the same Acrobat window (without
    going to a browser) and jump to a named destination 'someplace' inside it.
    Named destinations will be created by @id attributes in the source FO;
    so the above URL would bring you to the same place as
    internal-destination="someplace" in somefile.fo. That's what I tried
    to show in the above sample code.

    (I can unveil a secret: the above syntax for file links works even in the
    current version. Named destinations are not created however;
    so referenced PDF documents always open at the first page).

    Best regards,
    Nikolai Grigoriev
    RenderX

    -------------------
    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html



    This archive was generated by hypermail 2.1.5 : Thu Apr 17 2003 - 23:39:38 PDT