Type: Function

How to get addAttributeIndex?


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

Note: This feature is experimental and subject to change.

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.


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.