How can I use a customized java service for xml validation ?

This should cover W3C XML Schema, Relax NG and DTD related problems.
sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

How can I use a customized java service for xml validation ?

Post by sebastienlavandier »

Hello,

We have a specific xml document, that contains a list of rules, with for each case : an xpath, a test and a warning message which must appear if the test are wrong. It's a normed document we can't make otherwise !
The problem is that document is not a standard xml validation format like .xsd, or schematron, ...

So, I want to know if it's possible to use a custom java api (or an other solution) in Oxygen Author to validate xml documents.

Do you have some ideas ?
Thanks in advance for your answers.
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: How can I use a customized java service for xml validation ?

Post by Radu »

Hi Sebastien,

This is for the standalone version of Oxygen, right?
Have you implemented a Workspace Access plugin until now using our Plugins SDK?

One possibility would be to use for validation a very simple XML Schema in order for Oxygen to automatically validate the file each time the user modifies it.

Then we have some API like:

Code: Select all

ro.sync.exml.workspace.api.editor.WSEditor.addValidationProblemsFilter(ValidationProblemsFilter)
which would notify you each time Oxygen is validating the document and allow you to add additional errors in the list of detected errors.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

Re: How can I use a customized java service for xml validation ?

Post by sebastienlavandier »

Hi Radu,

Thanks you for your answer.
I trying to implement your solution, and for do that I must instantiate a "DocumentPositionedInfo".
Now my problem is how to know what are the parameters of the DocumentPositionedInfo constructor ?
I don't find informations for this class.

Do you have an example or some informations about the attributes of the class ?

Thanks in advance.
sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

Re: How can I use a customized java service for xml validation ?

Post by sebastienlavandier »

Radu wrote: Then we have some API like:

Code: Select all

ro.sync.exml.workspace.api.editor.WSEditor.addValidationProblemsFilter(ValidationProblemsFilter)
which would notify you each time Oxygen is validating the document and allow you to add additional errors in the list of detected errors.

Regards,
Radu
Hello Radu,
I'm trying again your solution and I want to know, how I can detected when Oxygen is validating the document.
Thanks you for your answer.
seb.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How can I use a customized java service for xml validation ?

Post by sorin_ristache »

Hi Sebastien,
sebastienlavandier wrote:I trying to implement your solution, and for do that I must instantiate a "DocumentPositionedInfo".
Now my problem is how to know what are the parameters of the DocumentPositionedInfo constructor ?
I don't find informations for this class.
The DocumentPositionedInfo class was missing from the javadoc of the Plugins API. Now we updated the javadoc on the website and also the Plugins SDK to include this class. You can download the SDK again if you want to have the new complete javadoc also on your computer.

As you can see in the documentation of the DocumentPositionedInfo class there are many constructors that allow you to create one message for adding it to one output view (in your case the Errors view where the validation error messages are displayed). Depending on the number of details that you have about an error (the location of the validated file, line and column of the error, the text of the error message, the severity of the message - warning, error, etc) you should call the appropriate constructor in your Workspace plugin for each message that will go in the output view.


Regards,
Sorin
sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

Re: How can I use a customized java service for xml validation ?

Post by sebastienlavandier »

Hello,

Thanks you for your answer.

When the XML document is validated (automaticaly / Manualy), a list of messages is generated in the error widget.

Now I want to put some others messages in this list.
To do that, I must detected when Oxygen is validating the XML document.

How I can do that ?
I don't find a corresponding listener or other solution.

Thanks in advance for your answer.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How can I use a customized java service for xml validation ?

Post by sorin_ristache »

Hi Sébastien,
sebastienlavandier wrote:I'm trying again your solution and I want to know, how I can detected when Oxygen is validating the document.
Your implementation of the listener interface ValidationProblemsFilter (which is part of your Workspace plugin and which is registered by calling the WSEditor.addValidationProblemsFilter() method) is called every time there is a validation in the editor panel where the validated document is edited. The validation can be manual (started by the Oxygen user pressing the Validate button on the Toolbar or going to menu Document -> Validate -> Validate) or automatic (the automatic validation is enabled from menu Options -> Preferences -> Editor -> Document Checking -- Enable automatic validation). In both types of validation you (as the implementer of the Workspace plugin) don't (and can't) do anything to start the validation. Your listener of type ValidationProblemsFilter is simply called when a validation takes place in an Oxygen editor panel. You can add, remove or modify the marker messages displayed in the output Oxygen view (in your case the Errors view) by modifying the list returned by ro.sync.exml.workspace.api.editor.validation.ValidationProblems.getProblemsList() which you can call inside your implementation of ValidationProblemsFilter.filterValidationProblems().


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How can I use a customized java service for xml validation ?

Post by sorin_ristache »

Hi Sébastien,

Your listener of type ValidationProblemsFilter will be called by Oxygen only when a validation takes place in the editor panel(s) for which you registered the listener, that is only for the editor panel(s) for which you called the WSEditor.addValidationProblemsFilter() method. In your Workspace plugin you decide for which editor panels (WSEditor instances) you want to be notified.


Regards,
Sorin
sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

Re: How can I use a customized java service for xml validation ?

Post by sebastienlavandier »

Hi Sorin,

It work well !
Thank you for your help.
Bye
Post Reply