OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] 'endterm' with olinks?


This is not a feature that is currently supported, so something original is called for here. I can think of two approaches, the former more complex but more complete than the latter.

Approach 1. The olink element allows an attribute named 'localinfo' which is described in The Definitive Guide as "Holds additional information that may be used by the application when resolving the link". You could use that to indicate the id of the olink text, something like localinfo="endterm: otherid". The localinfo attribute is not currently processed, so it is free for some customization like this.

To make it work, though, you would need to customize the template named 'olink.hottext' from common/olink.xsl. That is a big, complex template because of the many olink features (but unfortunately, not this feature). That customization would parse the localinfo attribute on the olink if it is present, and look up the 'otherid' in the olink database instead of looking up the targetptr of the olink.

Approach 2. Create a nested olink with a role attribute, and customize its behavior. When an olink element is processed, if the olink element is not empty, then the stylesheet just does <xsl:apply-templates/> to that content and does not look up the text in the olink database. So you could do this:

<olink targetptr="chapterid"><olink targetptr="otherid" role="endterm"/></olink>

In order to not create a nested link, you would need to add a template like this to your customization:


<xsl:template match="olink[@role = 'endterm']">
 <xsl:variable name="content">
   <xsl:apply-imports/>
 </xsl:variable>
 <xsl:value-of select="string($content)"/>
</xsl:template>

You would also want to set this param so the role attribute is not interpreted as an xrefstyle, which would generate warning messages.

 <xsl:param name="use.role.as.xrefstyle" select="0"/>

This template matches the nested olink because of the role value. It then processes that olink with xsl:apply-imports, which would generate a normal active link to the "otherid" element, with text generated from the olink database for "otherid". Then it takes the string value of the result. The outer olink supplies the linking wrapper for that text. With this approach, when you take the string value of the inner olink, you lose any inline formatting, but that's the price of simplicity. 8^)

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


----- Original Message ----- From: Giuseppe Monticelli
To: docbook-apps@lists.oasis-open.org
Sent: Wednesday, February 01, 2012 3:06 PM
Subject: [docbook-apps] 'endterm' with olinks?


Is there a possibility to emulate with 'olink' the behavior of the attributes 'linkend' and 'endterm' used together in the 'xref' element?

I would like that a couple of my olinks (necessarily used instead of 'xref' in modular documents with XInclude) receive a dedicated cross reference text coming from a particular element, while the cross reference destination should be the beginning of the section in which the element providing the reference text is contained (similarly to Example 15.2 "Xref to a question in qandaentry" at the bottom of http://www.sagehill.net/docbookxsl/CrossRefs.html#OptsGenXref).

Thank you in advance for every hint,

   Giuseppe

--
Giuseppe Monticelli :: Funambol, Inc. :: http://docs.funambol.com

MediaHub - Connect Everything Mobile via the Cloud, powered by open source

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]