Page 1 of 1

Custom extension to DITA Map validation?

Posted: Thu Jun 08, 2017 5:04 pm
by Patrik
Hi,

I have custom elements in my DITA framework referencing additional XML files. I'd like to have these validated as well since their content is being integrated into the publication (by a customized coderef). Is there any way for me to extend the validation process through Java?

Thanks and regards,
Patrik

Re: Custom extension to DITA Map validation?

Posted: Fri Jun 09, 2017 9:52 am
by Radu
Hi Patrik,

Once a WSEditor is opened in Oxygen you can add a "ValidationProblemsFilter" to it:

https://www.oxygenxml.com/InstData/Edit ... ditor.html

The filter can be used to either add more problems to the problems list or to filter problems that you do not want to present to the end user.
A problem is an instance of https://www.oxygenxml.com/InstData/Edit ... dInfo.html, it has a message, severity and it also needs some kind of line-column location that you will need to figure out on your own.
This filter is called each time automatic validation is done (about 1-2 seconds after each modification is made to the document) so your extra code should not induce too much delay.

A sample Javascript-based plugin implementing a ValidationProblemsFilter can be found here:

https://github.com/oxygenxml/wsaccess-j ... lemsFilter

Regards,
Radu

Re: Custom extension to DITA Map validation?

Posted: Fri Jun 09, 2017 10:36 am
by Patrik
Thanks for the explanation. But I did not mean the automatic validation (although I might add it there as well) but the "Validate and Check for Completeness" in the DITA Maps Manager.

Regards,
Patrik

Re: Custom extension to DITA Map validation?

Posted: Fri Jun 09, 2017 2:00 pm
by Radu
Hi Patrik,

The code would look like this:

Code: Select all

    PluginWorkspaceProvider.getPluginWorkspace().addEditorChangeListener(new WSEditorChangeListener(){
/**
* @see ro.sync.exml.workspace.api.listeners.WSEditorChangeListener#editorOpened(java.net.URL)
*/
@Override
public void editorOpened(URL editorLocation) {
WSEditor ditaMapEditorAccess = PluginWorkspaceProvider.getPluginWorkspace().getEditorAccess(editorLocation, PluginWorkspace.DITA_MAPS_EDITING_AREA);
ditaMapEditorAccess.addValidationProblemsFilter(new ValidationProblemsFilter(){
public void filterValidationProblems(ValidationProblems validationProblems) {
if(validationProblems.getValidationType() == ValidationProblems.VALIDATION_DITA_MAP_CHECK_FOR_COMPLETENESS){
//Enjoy....
}
}
});
}
}, PluginWorkspace.DITA_MAPS_EDITING_AREA);
Regards,
Radu