Edit online

The DefaultElementLocatorProvider implementation is used by default to find link target references. It offers support for the most common types of links:

The method getElementLocator determines what ElementLocator should be used. In the default implementation, it checks if the link is an XPointer element() scheme. Otherwise, it assumes it is an ID. A non-null IDTypeVerifier will always be provided if a schema is associated with the document type.

The link string argument is the anchor part of the of the URL that is composed from the value of the link property specified for the link element in the CSS.

public ElementLocator getElementLocator(IDTypeVerifier idVerifier, 
               String link) {
  ElementLocator elementLocator = null;
  try {
    if(link.startsWith("element(")){
      // xpointer element() scheme
      elementLocator = new XPointerElementLocator(idVerifier, link);
    } else {
      // Locate link element by ID
      elementLocator = new IDElementLocator(idVerifier, link);
    }
  } catch (ElementLocatorException e) {
    logger.warn("Exception when create element locator for link: " 
        + link + ". Cause: " + e, e);
  }
  return elementLocator;
}