Ref Validation of Image href

SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Ref Validation of Image href

Post by SNO » Tue Oct 06, 2020 3:22 pm

Hi,

In our CMS we have an alternate location of images while editing content. So we implemented an StylesFilter to alter the reference either to the alternate location or to the document location.

Now the problem in DITA is that there is a validation on the href of the image tag causing this warning:
File not found: "C:$ALTERNATE_LOCATION$\Oxygen_Internal\X000003\1200px-lego_logo000169ml.svg2.png".
after saving the document.

Is there a possibility to remove this single validation?

Best Regards
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH

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

Re: Ref Validation of Image href

Post by Radu » Tue Oct 06, 2020 4:19 pm

Hi Stefan,

If you look in our plugin's plugin.xml, it has an extension point named "com.oxygenxml.editor.workspaceAccessPlugin" which is called when the plugin is started. You can use it to add a listener which will be notified when an XML document is opened, and on the XML document to add a validation problems filter:

https://www.oxygenxml.com/InstData/Edit ... emsFilter-

We have a sample Javascript-based plugin for the Oxygen standalone which does validation errors filtering here, and the Java code for the Eclipse plugin should be similar:

https://github.com/oxygenxml/wsaccess-j ... sAccess.js

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Re: Ref Validation of Image href

Post by SNO » Wed Oct 07, 2020 11:30 am

Hi Radu,

is there an Interface I must implement for this extension? And is there a possibility to get all ValidationFilters?

Regards,
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH

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

Re: Ref Validation of Image href

Post by Radu » Wed Oct 07, 2020 1:18 pm

Hi Stefan,

Your Java code would need to look something like this:

Code: Select all

import java.net.URL;
import java.util.List;

import com.oxygenxml.workspace.api.eclipse.EclipsePluginWorkspace;
import com.oxygenxml.workspace.api.eclipse.EclipseWorkspaceAccessPluginExtension;

import ro.sync.document.DocumentPositionedInfo;
import ro.sync.exml.workspace.api.PluginWorkspace;
import ro.sync.exml.workspace.api.editor.WSEditor;
import ro.sync.exml.workspace.api.editor.validation.ValidationProblems;
import ro.sync.exml.workspace.api.editor.validation.ValidationProblemsFilter;
import ro.sync.exml.workspace.api.listeners.WSEditorChangeListener;

/**
 * @author raducoravu
 *
 */
public class EclipseWSPlugin implements EclipseWorkspaceAccessPluginExtension {

  /**
   * @see com.oxygenxml.workspace.api.eclipse.EclipseWorkspaceAccessPluginExtension#pluginStarted(com.oxygenxml.workspace.api.eclipse.EclipsePluginWorkspace)
   */
  @Override
  public void pluginStarted(EclipsePluginWorkspace pluginWorkspaceAccess) {
    pluginWorkspaceAccess.addEditorChangeListener(new WSEditorChangeListener() {
      /**
       * @see ro.sync.exml.workspace.api.listeners.WSEditorChangeListener#editorOpened(java.net.URL)
       */
      @Override
      public void editorOpened(URL editorLocation) {
       //An XML document was opened.
        WSEditor openedEditor = pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
        openedEditor.addValidationProblemsFilter(new ValidationProblemsFilter() {
          @Override
          public void filterValidationProblems(ValidationProblems validationProblems) {
            List<DocumentPositionedInfo> problemsList = validationProblems.getProblemsList();
            if(problemsList != null && ! problemsList.isEmpty()) {
              //Maybe iterate the problems, add them in another list, skip the problems that you do not want to report and then
//              validationProblems.setProblemsList(newProblems);
            }
          }
        });
      }
    }, PluginWorkspace.MAIN_EDITING_AREA);
  }

  /**
   * @see com.oxygenxml.workspace.api.eclipse.EclipseWorkspaceAccessPluginExtension#pluginStopping()
   */
  @Override
  public void pluginStopping() {
    //
  }

}{code}

and you would add it as an extension of the "com.oxygenxml.editor.workspaceAccessPlugin" extension point provided by our plugin.
So on each opened XML document you can add an individual problems filter.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SNO
Posts: 51
Joined: Mon Oct 01, 2012 3:05 pm

Re: Ref Validation of Image href

Post by SNO » Wed Oct 07, 2020 3:00 pm

Hi Radu,

thanks for the example code ... My problem here is that I can not distinguish between problems comming from different references.

I would like only to filter reference problems comming from the href in image tags not comming from other reference tags. How would I do that?

Is there no possibility to configure the validation in the framework? (DITA)

Regards
Stefan
Stefan Nöbauer
Senior Solution Architect
KGU-Consulting GmbH

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

Re: Ref Validation of Image href

Post by Radu » Wed Oct 07, 2020 4:04 pm

Hi Stefan,
I would like only to filter reference problems comming from the href in image tags not comming from other reference tags. How would I do that?
Each "ro.sync.document.DocumentPositionedInfo" object you receive in the validation problems filter has start and end line and column information. And you can also obtain a reader over the editor content "ro.sync.exml.workspace.api.editor.WSEditorBase.createContentReader()".
Also maybe as an alternative, the message of each error should contain the path to the invalid reference. And if the path to the invalid reference has an image extension, you could suppose the error comes from a reference to an image.
Is there no possibility to configure the validation in the framework? (DITA)
If you edit your DITA framework extension, in the "Validation" tab you have a default validation scenario named "DITA". If you edit it, it has about 5 stages, one of those stages is named "DITA Validation". It is not configurable, if you remove it completely you will remove this specific validation error but along with other validation errors which might be useful (for example reports for invalid key references, errors for broken table structure). So this "DITA Validation" stage does not yet have the possibility to set up precisely what it should and what it should not do, if in the future we add some checkboxes to control what exact problems it should report I will try to update this forum post.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Cosmin Duna
Site Admin
Posts: 51
Joined: Wed Dec 12, 2018 5:33 pm

Re: Ref Validation of Image href

Post by Cosmin Duna » Tue Oct 19, 2021 5:01 pm

Hello,

I just wanted to let you know that Oxygen 24.0 is out now and it contains a new validation engine named "DITA Map Validation and Completeness Check" that can be configured:
https://www.oxygenxml.com/doc/versions/ ... __d572e145

Best regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply