Custom extension to DITA Map validation?

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 216
Location: Hamburg/Germany

Custom extension to DITA Map validation?

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: 5093

Re: Custom extension to DITA Map validation?

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/Editor/SDK/javadoc/ro/sync/exml/workspace/api/editor/WSEditor.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/Editor/SDK/javadoc/ro/sync/document/DocumentPositionedInfo.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-javascript-sample-plugins/tree/master/validationProblemsFilter

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 216
Location: Hamburg/Germany

Re: Custom extension to DITA Map validation?

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: 5093

Re: Custom extension to DITA Map validation?

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests