Custom validation without Schematron
Are you missing a feature? Request its implementation here.
-
- 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!
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!
-
- 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:
Best,
Cristian
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?
- How do you block users from saving an invalid element in other cases? Are you using this plugin https://github.com/oxygenxml/web-author ... if-invalid ?
- 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?
Best,
Cristian
-
- 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:
Thanks!
Vitor
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.
Thanks!
Vitor
-
- 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:
Cristian
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:
- You can use AuthorIdIndex to identify a node without searching it in the document -https://www.oxygenxml.com/InstData/Edit ... Index.html
- You can use EditingSessionContext to store information related to a particular AuthorDocumentModel - https://www.oxygenxml.com/InstData/Edit ... ntext.html
Cristian
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service