$annotation-collection — An external collection of annotations.

Defined in:
Used in:


  |$annotation-collection as xs:string := ''


Because annotations can be applied by pointing from the annotation to the element they annotate, they can be stored and managed externally. If $annotation-collection points to a collection of annotations, the stylesheets will add them to the document before it is processed.

To achieve this:

  1. Create a collection of shared annotations and store them somewhere. The stylesheets will copy only the top-level annotation elements (/*/annotation). The document element doesn’t matter.

  2. Use the annotates attribute on the annotations to point at elements in the document you’re transforming.

    Annotations can point in either direction, but you will get ID/IDREF validation errors if you attempt to point from the document into the annotation collection because the annotation collection won’t be present when you validate. If your use case requires pointing in that direction, you will have better luck with a pipeline that combines the two documents before validating.

  3. Run your transformation with $annotation-collection set to the URI of the document that contains your collection of annotations.

The stylesheets will apply annotations to the elements identified. Extra annotations, annotations that don’t point to elements that actually exist in the document being transformed, will be ignored.