TransID

TransID.xsl — Enables fine-grained fixup of xml:id attributes after transclusion.

Parameters

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

Input

An XML document containing extended links to fix up transcluded XML IDs as described below.

Output

An XML document, identical to the input except that XML IDs are fixed up.

Description

This stylesheet is useful if you have a subdocument which contains XML IDs and which must be transcluded into 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. Other ID fixup mechanisms take a blanket approach to fixup, e.g. by adding a suffix to each ID in the transcluded subdocuments. This stylesheet is useful for cases when a fine-grained approach is required. It enables you to specify by hand how each transcluded ID should be fixed up, using XLinks.

In the assembly file or master document, at each point where you want to transclude the target subdocument, you must add an extended link element with the xl:role attribute set to the specified fixup role URI. For each ID that will need fixing up, this extended link should contain:

  1. A locator element with an xl:label attribute unique within the extended link, whose xl:href attribute points to one xml:id attribute in the subdocument.

  2. A locator element with an xl:label attribute unique within the extended link, whose xl:href attribute points to the new ID that you want the target subdocument 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 xml:id attribute, the stylesheet looks for the nearest ancestor element which contains an extended link whose xl:role attribute is set to the specified ID fixup role URI and which contains a locator element whose xl:href attribute points to the current xml:id attribute. If it finds a matching locator, the stylesheet follows the arc to the target locator and replaces the value of the current xml:id attribute with the value indicated by the target locator’s xl:href attribute.

You should run this stylesheet immediately after transclusion. If any of your translation strings contain xml:id attributes, you may need to run this stylesheet again immediately after translation.

After you have fixed up IDs, you may also need to fix up cross references or links that point to those IDs. See TransLinks.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.