Implementing UniqueAttributesRecognizer for multiple attribute types
Post here questions and problems related to oXygen frameworks/document types.
Implementing UniqueAttributesRecognizer for multiple attribute types
Our implementation of (x)html5 requires some governance over what attributes' values are allowed to be copied on split, and on paste. In particular, we have two attributes, id and data-aid, that need to be recognized as "unique" so their values aren't replicated, causing validation errors. Extending the DefaultAttributesRecognizer class seems to only allow a single attribute type to be passed to the constructor. Any suggestions? Has anyone solved this issue for their own implementations?
By the way, this may be easily solved for those more fluent in Java than me. I'm working on it ... thanks for your patience ...
By the way, this may be easily solved for those more fluent in Java than me. I'm working on it ... thanks for your patience ...
Re: Implementing UniqueAttributesRecognizer for multiple attribute types
Hi,
How about if you create your own implementation of the UniqueAttributesRecognizer interface which delegates to two default recognizers?
Something like:
Or as an alternative based on the Java code of the default unique attributes recognizer which you should find in the SDK you can create your own unique attributes recognizer changing the original code in certain places.
Regards,
Radu
How about if you create your own implementation of the UniqueAttributesRecognizer interface which delegates to two default recognizers?
Something like:
Code: Select all
public class UniqueAttrsRecognizerWrapper implements UniqueAttributesRecognizer, ClipboardFragmentProcessor {
private DefaultUniqueAttributesRecognizer rec1;
private DefaultUniqueAttributesRecognizer rec2;
public UniqueAttrsRecognizerWrapper() {
rec1 = new DefaultUniqueAttributesRecognizer("id");
rec2 = new DefaultUniqueAttributesRecognizer("data-aid");
}
@Override
public void activated(AuthorAccess authorAccess) {
rec1.activated(authorAccess);
rec2.activated(authorAccess);
}
@Override
public void deactivated(AuthorAccess authorAccess) {
rec1.deactivated(authorAccess);
rec2.deactivated(authorAccess);
}
@Override
public String getDescription() {
return "Recognizer";
}
/**
* @see ro.sync.ecss.extensions.api.UniqueAttributesProcessor#copyAttributeOnSplit(java.lang.String, ro.sync.ecss.extensions.api.node.AuthorElement)
*/
@Override
public boolean copyAttributeOnSplit(String attrQName, AuthorElement element) {
return rec1.copyAttributeOnSplit(attrQName, element) && rec2.copyAttributeOnSplit(attrQName, element);
}
@Override
public void assignUniqueIDs(int startOffset, int endOffset, boolean forceGeneration) {
//Probably not interesting, you do not want to generate unique IDs.
}
@Override
public boolean isAutoIDGenerationActive() {
return false;
}
@Override
public void process(ClipboardFragmentInformation fragmentInformation) {
rec1.process(fragmentInformation);
rec2.process(fragmentInformation);
}
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service