TransLinks

TransLinks.xsl — Enables fine-grained fixup of simple link attributes after transclusion.

Parameters

[linkRole]
  • linkRole (URI) — A URI which identifies the link fixup XLink role. Default is http://stanleysecurity.github.io/PACBook/role/link.

Input

An XML document containing extended links to fix up simple link attributes as described below.

Output

An XML document, identical to the input except that simple link attributes are fixed up.

Description

This stylesheet is useful in two scenarios:

  1. If you have a subdocument which contains XML IDs and which must be included in an assembly file or master document in two or more places. In order to avoid validation errors, each ID must be unique. The process of making duplicate IDs unique is called ID fixup. After you have fixed up IDs, you may also need to fix up inbound cross references or links that point to those IDs.

  2. If you want to include a subdocument containing outbound cross references or links to IDs in other subdocuments which are not present in the current assembly file or master document. You can fix up these links to redirect them to other IDs which are known to be present.

This stylesheet enables you to specify by hand how links should be fixed up, using XLink.

In the assembly file or master document, at the start of each section where you want to fix up links or cross references, you must add an extended link element with the xl:role attribute set to the specified link fixup role URI. For each link or cross-reference that needs fixing up, the extended link should contain:

  1. A locator element with an xl:label attribute unique within the extended link, whose xl:href attribute is set to a link location that you want to fix up.

  2. A locator element with an xl:label attribute unique within the extended link, whose xl:href attribute is set to the link location that you want the link or cross reference to use.

  3. An arc element whose xl:from attribute is set to the xl:label attribute of the start locator and whose xl:to attribute is set to the xl:label attribute of the fixup locator.

When run, the stylesheet recurses through the document and copies each element. If any element has an xl:href attribute, the stylesheet looks for the nearest ancestor element which contains an extended link whose xl:role attribute is set to the specified link fixup role URI and which contains a locator element whose xl:href attribute is the same as the current xl:href attribute. If it finds a matching locator, the stylesheet follows the arc to the target locator and replaces the value of the current xl:href attribute with the value indicated by the target locator’s xl:href attribute.

For DocBook documents, this stylesheet also fixes up linkend attributes and the content of arearefs attributes in the same way.

You should run this stylesheet after transclusion. If any of your translation strings contain simple links, you may need to run this stylesheet after translation instead.

For fixing up IDs after transclusion, see TransID.xsl.

Roadmap

At present this stylesheet requires that the extended links, locators and arcs are DocBook extendedlink, locator and arc elements, meaning that the stylesheet only works with DocBook. In future releases, this stylesheet will be updated to work with any elements with attributes xl:type='extended', xl:type='locator' or xl:type='arc'. This will make the stylesheets work with any XLink-compliant XML schema, including DocBook 5.1.