Custom IDElementLocator
Posted: Wed Oct 30, 2013 7:53 pm
Hi,
I implemented in my css this :
and I want to link this to an element ID name "KEY". To do that,I have add in my file.framewok :
Also, I implemented this :
And of course, this :
But unfortunately,these classes are never called... and I don't understand why
Do you have an idea ?
Thanks in advance for your help.
Sébastien
I implemented in my css this :
Code: Select all
GRPHCREF:before {
link:attr(REFID);
color: #1e91ca;
content: "Graphic Ref : " attr(REFID);
}
Code: Select all
<field name="elementLocatorExtension"> <String>com.author.framework.CustomElementLocatorProvider</String>
</field>
Code: Select all
public class CustomElementLocatorProvider extends DefaultElementLocatorProvider {
@Override
public ElementLocator getElementLocator(IDTypeVerifier idVerifier, String link) {
// Locate link element by ID
return new CustomIDElementLocator(idVerifier, link);
}
}
Code: Select all
public class CustomIDElementLocator extends IDElementLocator {
public CustomIDElementLocator(IDTypeVerifier idTypeVerifier, String s) {
super(idTypeVerifier, s);
}
/**
* @see ro.sync.ecss.extensions.api.link.ElementLocator#startElement(java.lang.String, java.lang.String, java.lang.String, ro.sync.ecss.extensions.api.link.Attr[])
*/
@Override
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("KEY".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;
}
}
Do you have an idea ?
Thanks in advance for your help.
Sébastien