IDElementLocator Implementation
The IDElementLocator is an implementation of the abstract class ro.sync.ecss.extensions.api.link.ElementLocator for links that
use an id.
The constructor only assigns field values and the method endElement is
empty for this implementation.
The method startElement checks each of the element's attribute values and
when one matches the link, it considers the element found if one of the following
conditions
is satisfied:
-
the qualified name of the attribute is
xml:id -
the attribute type is ID
The attribute type is checked with the help of the method
IDTypeVerifier.hasIDType.
public boolean startElement(String uri, String localName,
String name, Attr[] atts) {
boolean elementFound = false;
for (int i = 0; i < atts.length; i++) {
if (link.equals(atts[i].getValue())) {
if("xml:id".equals(atts[i].getQName())) {
// xml:id attribute
elementFound = true;
} else {
// check if attribute has ID type
String attrLocalName =
ExtensionUtil.getLocalName(atts[i].getQName());
String attrUri = atts[i].getNamespace();
if (idVerifier.hasIDType(localName, uri, attrLocalName, attrUri)) {
elementFound = true;
}
}
}
}
return elementFound;
}