Validate document

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Validate document

Post by SmitaPatil »

Hi Team,
Can you please tell me if there is any method using which we can validate the content at selected caret position in document.

Thanks & Regards,
Smita
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Validate document

Post by cristi_talau »

Hello,
In Web Author there is the notion of a "valid document". I am not sure if you want to validate smaller pieces of content inside the document (you mentioned the caret position), and how would you determine the validity of such a fragment - XML Schemas validate entire documents only.

If you want to validate the entire document, you can draw some inspiration from this plugin which blocks saving a document when it is invalid: https://github.com/oxygenxml/web-author ... if-invalid .
Best,
Cristian
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Validate document

Post by SmitaPatil »

Hi Cristian,
Suppose user has removed the tag in that case, after this change if document is not valid I can see red lines in the document.
can you tell which api we can use to check whether current document is valid or not based on schema.

Thanks & Regards,
Smitz
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Validate document

Post by cristi_talau »

Hello,

The Java API is the following: WebappDocumentValidator.getValidationTask() (details here: https://www.oxygenxml.com/InstData/Edit ... tionTask--). You can see here how it is used: https://github.com/oxygenxml/web-author ... ess.js#L26

Best,
Cristian
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Validate document

Post by SmitaPatil »

Hi Cristian,
I wonder how we can access authorDocumentModel at javascript side or client side.
Can you please tell me how we can access authorDocumentModel at js side. I want to call this method using js.

Thanks & Regards,
Smita
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Validate document

Post by cristi_talau »

Hello,
The sample plugin I mentioned in the previous posts uses JS code that is run on the server using the Rhino JS engine. This code cannot run on the browser as it uses objects that are implemented in Java.
To call this API from JS code in browser, you can invoke AuthorOperations implemented in Java as described here: https://www.oxygenxml.com/maven/com/oxy ... esult.html .

Best,
Cristian
Post Reply