Page 1 of 1

Issue with ValidationProblemsFilter

Posted: Fri Jan 07, 2022 6:07 pm
by Isabelle
Hello,

We work with the version 24.0.0 of Oxygen sdk.

We need to check the xsd validity of the current document before start an action.
Currently we do it this way :

Code: Select all

	final isDocumentXsdValid = false;
        authorAccess.getEditorAccess().getParentEditor().addValidationProblemsFilter(new ValidationProblemsFilter() {
            public void filterValidationProblems(ValidationProblems validationProblems) {
                isDocumentXsdValid = validationProblems.getProblemsList().stream().noneMatch(p -> p.getEngineName().equals("Xerces"));
            }
        });
        authorAccess.getEditorAccess().getParentEditor().checkValid();
But sometimes validationProblems.getProblemsList() is null.
How it is possible ? Is it a normal behavior ?

Is there a more efficient way to check the validity of the current document ?

Thanks,
Regards,
Isabelle

Re: Issue with ValidationProblemsFilter

Posted: Mon Jan 10, 2022 10:08 am
by Radu
Hi Isabelle,

If the method "validationProblems.getProblemsList()" returns null it means there are no validation errors found by Oxygen so the document is valid. I will update the Javadoc on the method to state this more clearly.

The "ro.sync.exml.workspace.api.editor.WSEditor.checkValid()" method returns a boolean result but from your code I guess you want to ignore certain validation errors and look only for the Xerces related errors. You should also try to avoid calling "addValidationProblemsFilter" multiple times as you will keep adding listeners on the editor, or after calling "WSEditor.checkValid()" use the "removeValidationProblemsFilter" API to remove your listener.

Regards,
Radu

Re: Issue with ValidationProblemsFilter

Posted: Mon Jan 10, 2022 12:53 pm
by Isabelle
Hello Radu,

Thanks for the answer.
Radu wrote: Mon Jan 10, 2022 10:08 am If the method "validationProblems.getProblemsList()" returns null it means there are no validation errors found by Oxygen so the document is valid. I will update the Javadoc on the method to state this more clearly.
Most of the times, I have "validationProblems.getProblemsList()" initialized with size to 0.
Is there a difference with null response or empty list response ?

Regards,
Isabelle

Re: Issue with ValidationProblemsFilter

Posted: Mon Jan 10, 2022 12:56 pm
by Radu
Hi Isabelle,

You should treat the cases in which the list is null or has zero size in exactly the same way.

Regards,
Radu

Re: Issue with ValidationProblemsFilter

Posted: Mon Jan 10, 2022 12:58 pm
by Isabelle
Ok,

Thank you.

Regards,
Isabelle