Page 1 of 1

Ref Validation of Image href

Posted: Tue Oct 06, 2020 3:22 pm
by SNO
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

Re: Ref Validation of Image href

Posted: Tue Oct 06, 2020 4:19 pm
by Radu
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

Re: Ref Validation of Image href

Posted: Wed Oct 07, 2020 11:30 am
by SNO
Hi Radu,

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

Regards,
Stefan

Re: Ref Validation of Image href

Posted: Wed Oct 07, 2020 1:18 pm
by Radu
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

Re: Ref Validation of Image href

Posted: Wed Oct 07, 2020 3:00 pm
by SNO
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

Re: Ref Validation of Image href

Posted: Wed Oct 07, 2020 4:04 pm
by Radu
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

Re: Ref Validation of Image href

Posted: Tue Oct 19, 2021 5:01 pm
by Cosmin Duna
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