unique-id-configurations

Type: Array<Object>

Set to an array of objects to determine the identifying attributes for which a GUID will be generated automatically.

Each object should have the following properties:

  • selector, the XPathTest that determines which elements receive the attribute. The ID attribute will only be set on elements that allow it per schema; the selector self::element() can safely be used to express "any element allowing the given ID attribute".

  • namespaceURI, determines together with localName the name of the attribute used to store the generated ID. Make sure you have registered this URI with NamespaceManager#addNamespace. This may be set to null if your attribute is in the null namespace (aka has no prefix).

  • localName, determines together with namespaceURI the name of the attribute used to store the generated ID.

  • strategy, determines whether we always generate new IDs This can be 'always-regenerate', this is the default value, or if we re-use old id's 'unique-for-document'. always-regenerate will regenerate an id if it was used before in the same document and make sure it is unique per document. Furthermore, if an element is pasted at another place in the same document, in an other document, or in an other browser tab, its id attribute will also be regenerated. Also, ids will never be re-used. unique-for-document will only regenerate an id if it is already present in the same document. It will allow copying and pasting an element from one document to another while retaining their ids.

Note that references to ids will be ignored while regenerating them. Use the registerPastedNodesFilter to redistribute ids manually if you expect to copy-paste pairs of elements and you want to keep references intact.

This defaults to an empty array which causes no identifiers to be generated.

Example

configurationManager.set('unique-id-configurations', [
  {
    selector: 'self::section or self::fig or self::table',
    namespaceURI: null,
    localName: 'id',
    strategy: 'unique-for-document'
  }
]);
Was this page helpful?