OLink Semantics in the DocBook DSSSL Stylesheets

Norman Walsh

10 Sep 1998


Understanding OLink

The semantics of OLink are effected by both the OLink tag and the ModeSpec tag.

OLinking in HTML

Constructing cross-document links with entities in the authoring system is all well and good, but how does it work on the web? The heart of the matter is mapping from the SGML/XML entity in the TargetDocEnt to the base URL on the web, and there are two options: early binding and late binding.

OLink Generated Text

Even when links span across documents, it's useful to have the stylesheet generate appropriate cross-reference text. This greatly reduces the “fragility” of the links at the expense of some complexity in the OLink processing system.

If you supply content in an OLink, that content is always used and generated text processing does not apply.

The format of generated text is controlled by the XRefLabel attribute on the ModeSpec pointed to by the OLink. The text of the XRefLabel attribute is used for the generated text, with the following substitutions:

Suppose, for example, that the link target is the second section in the first chapter of a book and that it has the title “My Test Title”. If the XRefLabel attribute contains the text “see %g %n, %t”, then the generated content would be “see Section 1.3, My Test Title”.

Really Simple OLinks

If the author provides content in the OLink element, that's the content that is used and no extra processing is required. The sections that follow each deal with variations in the level of processing required for generated text in OLinks.

Simple OLinks

Simple OLinks avoid some of the gory machinery required to handle general OLinks at the expense of most semantic variation.

The simple semantics come into play when an OLink has the following form:

<olink targetdocent="entity"></olink>

In particular, note that there is no LinkMode. The generated text in this case is derived entirely from the public and system identifiers by the (olink-resource-title) function. By default, this is simply the title of the document derived from the description field in the public identifier. The first and last “words” of the public identifier description field are trimmed off, leaving what is presumably just the document title. For example, given “-//Norman Walsh//DOCUMENT My Document Title V1.0//EN”, the derived title would be “My Document Title”.

General OLinks

The generated text for general OLinks comes from the XRefLabel attribute on the relevant ModeSpec. The hard part is locating the appropriate replacement text: the name, label, and title of the element pointed to by the combination of the TargetDocEnt and LocalInfo.

One way to do this would be to load the TargetDocEnt, find the element with the ID mentioned in LocalInfo and extract the data directly. I chose something else because I see two significant problems with this approach:

  1. Loading and parsing potentially large documents potentially many times appears to have the potential for significant performance problems.

  2. It would not be possible to form OLink references to documents written in DTDs other than DocBook.

Instead of loading the actual target document, the stylesheets load a summary of that document's content. For DocBook documents, this summary can be generated by another DSSSL stylesheet, olink.dsl, supplied with the DocBook Stylesheet distribution. The first few lines of the summary for this document is shown in looks like this:.

The basic organization of the summary document is a nested series of divs and objs with titles (ttls). Attributes on these elements provide the IDs, labels, and names of the elements. The GI of the element is also provided. (If you find objects that you think are missing from the summary, please let me know).

The stylesheets locate this document by resolving the system identifier of the target document and replacing the SGML or XML extension with %olink-outline-ext% (.olink, by default).

Intra-document OLinks

If the TargetDocEnt attribute is missing, it seems reasonable to assume that the link refers to the current document. This actually offers a feature, you can customize the generated cross reference text for a particular reference.

When the OLink is an intra-document link, it is possible to use additional %-substitutions in the cross reference template. See (auto-xref) in dbcommon.dsl for more details.

Examples

The examples that follow are all links into the document shown in .

The ModeSpecs in this document are shown in .