Type: Function

How to get addAttributeIndex?


import addAttributeIndex from 'fontoxml-indices/src/addAttributeIndex.js'

Adds an attribute index and registers a XPath function to access it. The XPath function will be registered with the provided functionNamespaceURI and functionLocalName.

This will index all elements which have the attribute providing a quick lookup.

We recommend this to be done in the configureSxModule.js of a package, this allows XQuery modules to use the attribute index. If you instead add the attribute index in the install.js it will be loaded later making it unavailable in XQuery modules.


This example registers the function app:id(xs:anyAtomicType) as element()*: a function that accepts any atomic type (xs:string, xs:numeric, etc) and returns zero or more elements. In this example, the editor instance registers the app prefix to the application-specific namespace URI of By executing this function we get the element(s) with the provided id ("123").


import addAttributeIndex from 'fontoxml-indices/src/addAttributeIndex.js';


const node = evaluateXPathToFirstNode(`app:id("123")`);


  1. attributeNamespaceURI


    Type: String | NULL

    The namespace URI of the attribute.

  2. attributeLocalName


    Type: String

    The local name of the attribute.

  3. functionNamespaceURI


    Type: String

    The namespace URI of the function.

  4. functionLocalName


    Type: String

    The local name of the function.