Copyright (C) 2000-2012 |
Whole document tree Understanding OLinkThe semantics of OLink are effected by both the OLink tag and the ModeSpec tag. OLinkOLink is a wrapper around the text which forms the head of the link. It has four relevant attributes:
ModeSpecAn OLink element can refer to a ModeSpec element to further modify the semantics of the link. Two aspects of the ModeSpec element are relevant:
OLinking in HTMLConstructing 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. Early BindingTo use early binding, you must know the mapping from entities to URLs in advance. The base URL is supplied in the content of the ModeSpec element and that is what the processor uses to construct the HTML “href”. For example, given the document in , the stylesheet would generate something like this for the link: <A CLASS="OLINK" HREF="http://nwalsh.com/otherdocs/myotherdoc.htm#idval">This is an OLink</a> Note that the LocalInfo is used as the fragment identifier. Late BindingLate binding delays the resolution of entity to URL mapping until the link is followed. It does this by requiring that a web server process resolve the link. “Out of the box,” the DocBook stylesheets assume that a cgi-bin script on the server called /cgi-bin/olink is responsible for the resolution. Given the document in , late binding would produce a link something like this: <A CLASS="OLINK" HREF="/cgi-bin/olink?pubid=-//Norman%20Walsh //DOCUMENT%20My%20Other%20Document%20V1.0//EN&fragid=idval"> This is an OLink</a> (without the line break in the middle of the public identifier, of course). Again, note that the LocalInfo is used as the fragment identifier. If a public identifier is used to declare the entity, then it is passed to the link resolution script; otherwise the system identifier is passed. OLink Generated TextEven 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 OLinksIf 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 OLinksSimple 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 OLinksThe 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:
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 OLinksIf 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. ExamplesThe examples that follow are all links into the document shown in . The ModeSpecs in this document are shown in . Example 0. An OLink with Content Source: <olink targetdocent=olinktarget>some text</olink> Result: some text Example 0. A Simple OLink Source: <olink targetdocent=olinktarget></olink> Result: OLink Test Document Example 0. An OLink to a Document Source: <olink targetdocent=olinktarget linkmode=ms1></olink> Result: Name: 'Article', Label: '', Title: 'OLink Test Document' |