Create a customized XML validator

Oxygen general issues.
naughtyson
Posts: 4
Joined: Tue Oct 15, 2013 10:14 pm

Create a customized XML validator

Post by naughtyson »

I implemented a customized XML validator and I would like to integrate it into the oXygen UI. After reading some related documents, I learnt I need to: 1) create a Customized Validation Engine by selecting 'options'->'Preference'->'Custom Validation Engine', then 2) create a validation scenario by selecting my engine.

At the step 1, I have to give the "Executable Path" to my customized validating engine(a .bat for Windows platform OR a .sh for Linux/Solaris). Question here, how can I make this platform independent? Because I need to support both Windows and Linux/Solaris. How can I let the oXygen load the correct executable file based on the platform oXygen is running?
ionela
Posts: 407
Joined: Mon Dec 05, 2011 6:08 pm

Re: Create a customized XML validator

Post by ionela »

Hello,

Unfortunately, it is not possible insert a platform independent executable path for the custom validation engine. oXygen cannot load a different executable file based on the platform it is running.

Let us know if you need further assistance.

Regards,
Ionela
Ionela Istodor
oXygen XML Editor and Author Support
naughtyson
Posts: 4
Joined: Tue Oct 15, 2013 10:14 pm

Re: Create a customized XML validator

Post by naughtyson »

Thanks for the quick response.

So, is there any other way to add my customized validator into oXygen? Is it possible to wrap it as a plug-in? The purpose is to run the customized validator against the XML file being edited and report warnings/errors to the result panel(just like pre-integrated validator).
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Create a customized XML validator

Post by Radu »

Hi,

If you could perform that validation using Schematron checks you could add it as a default validation for the XML documents. Could you elaborate a little bit on what checks you want to add?

You can try to build a Workspace Access plugin. Our Plugins SDK and a sample Workspace Access plugin can be found here:

http://www.oxygenxml.com/oxygen_sdk.htm ... er_Plugins

Such a plugin allows you to add a validation problems filter on each opened editor:

ro.sync.exml.workspace.api.editor.WSEditor.addValidationProblemsFilter(ValidationProblemsFilter)

Such a filter receives each time the automatic validation kicks in (each time the user edits the document) a list of problems detected in the document from the default validation engines. You can then perform your own validation and add problems to that list.

This topic in our usermanual explains how to add such a filter to achieve a different goal but maybe it would be of interest to you as well:

http://www.oxygenxml.com/doc/ug-oxygen/ ... louts.html

Maybe you can try this approach and I can give you more hints when you run into problems.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
naughtyson
Posts: 4
Joined: Tue Oct 15, 2013 10:14 pm

Re: Create a customized XML validator

Post by naughtyson »

Thanks for the suggestions here, Radu.

<< Could you elaborate a little bit on what checks you want to add?

I implemented a customized validator(Java app) to validate the XML files against our company's special requirement, for example, validate the book(Docbook) title against DB record and validate <ulink> target. Document writers will use this tool to check their document before publication, idealy run this tool through the oXygen UI as an additional checking beside oXygen's integrated Xerces.

After creating a customized validation engine and associate it as an validation scenario, I can successfully run my validator by clicking that "validation" button, the output is displayed in the message panel since I followed the rule here, http://www.oxygenxml.com/doc/ug-editor/ ... nal-engine. Now the only problem is that I need to create different executable files for different platform, .bat for Windows, .sh for Mac and Solaris.

As you suggested here, implementing this customized validator as a "validation problems filter" maybe a solution. My concern is that, my validator takes more than 6 seconds to validate the document(send http request to validate <ulink> target URL), it may introduce the problem because you mentioned that the validator will be invoked each time the user edits the document.

Thanks.
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Create a customized XML validator

Post by Radu »

Hi,
After creating a customized validation engine and associate it as an validation scenario, I can successfully run my validator by clicking that "validation" button, the output is displayed in the message panel since I followed the rule here, http://www.oxygenxml.com/doc/ug-editor/ ... nal-engine. Now the only problem is that I need to create different executable files for different platform, .bat for Windows, .sh for Mac and Solaris.
Yes, that would be one option and indeed you would probably need to have an executable for each platform. This would probably mean defining 3 engines, one for each platform and have each user choose what's best.
As you suggested here, implementing this customized validator as a "validation problems filter" maybe a solution. My concern is that, my validator takes more than 6 seconds to validate the document(send http request to validate <ulink> target URL), it may introduce the problem because you mentioned that the validator will be invoked each time the user edits the document.
The callbacks to contribute to the list of problems would be given on a thread so you would not block the UI. Indeed 6 seconds seems quite a lot of time, maybe you could send the content zipped to the server or profile your code to see what takes so long. Of course, you could also try to move all the processing on the client side in the plugin and avoid sending the XML to the server.

The validation problems filter callback gives you a list of already found problems and you can also determine if the problems were detected during automatic (user editing) or manual validation (user clicked Validate toolbar action).

ValidationProblems.getValidationType()

So you could perform your custom code only when user chose to manually validate the XML document.

Another option using our Workspace Access plugin API would be for you to add a custom button to the toolbar for performing this validation. But you would also need to add your custom view in which the problems would appear as well with functionality to double click a problem and select the proper place in the document.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
naughtyson
Posts: 4
Joined: Tue Oct 15, 2013 10:14 pm

Re: Create a customized XML validator

Post by naughtyson »

The validation problems filter callback gives you a list of already found problems and you can also determine if the problems were detected during automatic (user editing) or manual validation (user clicked Validate toolbar action).

ValidationProblems.getValidationType()

So you could perform your custom code only when user chose to manually validate the XML document.
Thank you. I will try this one first.
Post Reply