Issue with ValidationProblemsFilter

Post here questions and problems related to oXygen frameworks/document types.
Isabelle
Posts: 96
Joined: Fri Jan 20, 2017 1:11 pm

Issue with ValidationProblemsFilter

Post 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
Radu
Posts: 7967
Joined: Fri Jul 09, 2004 5:18 pm

Re: Issue with ValidationProblemsFilter

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 96
Joined: Fri Jan 20, 2017 1:11 pm

Re: Issue with ValidationProblemsFilter

Post 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
Radu
Posts: 7967
Joined: Fri Jul 09, 2004 5:18 pm

Re: Issue with ValidationProblemsFilter

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Isabelle
Posts: 96
Joined: Fri Jan 20, 2017 1:11 pm

Re: Issue with ValidationProblemsFilter

Post by Isabelle »

Ok,

Thank you.

Regards,
Isabelle
Post Reply