Custom extension to DITA Map validation?

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 229
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Custom extension to DITA Map validation?

Post by Patrik » Thu Jun 08, 2017 5:04 pm

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

Radu
Posts: 6326
Joined: Fri Jul 09, 2004 5:18 pm

Re: Custom extension to DITA Map validation?

Post by Radu » Fri Jun 09, 2017 9:52 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Patrik
Posts: 229
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Custom extension to DITA Map validation?

Post by Patrik » Fri Jun 09, 2017 10:36 am

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

Radu
Posts: 6326
Joined: Fri Jul 09, 2004 5:18 pm

Re: Custom extension to DITA Map validation?

Post by Radu » Fri Jun 09, 2017 2:00 pm

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply