Custom validation without Schematron

Are you missing a feature? Request its implementation here.
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

Custom validation without Schematron

Post by vitorhugovm »

Hello,
I'm trying to implement a validation for the following process:
A request to an external endpoint is made when a document is opened in Author mode to fetch additional information to some custom XML tags. The retrieved content is not inserted in the XML after the request, it is inserted in the HTML just for the user visualization, what makes the use of Schematron not possible. What I'm trying to accomplish is to set an error to an element programmatically when the request is not successful, showing the error in the document validation tab and blocking the user from saving the document. Therefore I wanted the problem to be inserted in an specific moment and to be removed if the node in question is deleted or if the information comes to be retrieved successfully. I tried some workarounds, as using an extension for ValidationProblemsFilter and overriding the "filterValidationProblems" function, but it's not working as expected. Is there an easier way of doing this?
Thanks!
cristi_talau
Posts: 513
Joined: Thu Sep 04, 2014 4:22 pm

Re: Custom validation without Schematron

Post by cristi_talau »

Hello,

Let me make sure I understand your use-case. I understood that you have an XML document, and in order to render it in Oxygen XML Web Author you have to make requests to an external service. If the external service gives an error you want to show it in the document and in the Validation side-view.

If that is correct I have several questions:
  • Are you using a custom form control? Or how are you using the service response during rendering?
  • Are these requests to the external service made from the Web Author frontend or from the backend?
  • Are these requests made only during document loading, or they an also be done after an edit?
  • What did you try to do with the ValidationProblemsFilter and how it failed?
Without more details, one option that I could think of would be to make these requests (also) from the ValidationProblemsFilter.

Best,
Cristian
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

Re: Custom validation without Schematron

Post by vitorhugovm »

Hello Cristian,

Yes, you understood correctly.
Now answering your questions:
  • Yes, I am using a custom form control which extends WebappFormControlRenderer. The content retrieved from the external service is appended to the Writer out as HTML from an overwritten renderControl function.
  • I'm not using this plugin, i'm using a custom plugin that uses almost the same code, but in Java.
  • The request process starts in the frontend by using CSS to add oxy_editor, which calls a custom renderer in the backend. Then the request is made inside renderControl for each type of XML tag that was specified in CSS.
  • Yes, the requests are also made after an edit.
  • In ValidationProblemsFilter I tried getting the problems list, then adding a new problem and setting the list with the modifications. The issue was that the error was not removed when the fragment was deleted. For this problem I managed to create a listener for when a node is deleted, checking if there was a problem for this node to remove from the list. It worked, but the performance was not so good.
So I wonder if there is a correct way to get this to work with a good performance and without any workaround.

Thanks!
Vitor
cristi_talau
Posts: 513
Joined: Thu Sep 04, 2014 4:22 pm

Re: Custom validation without Schematron

Post by cristi_talau »

Hello,
So, I understand that it worked but there was a performance problem. Can you explain the performance problem in more detail? Did it happen during validation, or during editing?
Without understanding the code, I can offer you some general suggestions: Best,
Cristian
Post Reply