Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate an xml against xsd with JS/jQuery [duplicate]

Tags:

jquery

xsd

I need to know, if there is a solution which works in all major browsers for validating an xml against an xsd. I don't have the time for creating the actual validation functionality myself. It's for a project which needs to be done in 2 weeks as an exam for my apprenticeship.

Doing an xml validator as a jQuery login would be nice. So i got 2 Questions.

Is there a pre-made xml validation plugin/functionality in JS or jQuery like PHP's http://php.net/manual/de/domdocument.schemavalidate.php ? No ActiveX, since ActiveX is just supported by IE (afaik). And it is unhandy, if i remember correctly, the user always has to agree with it.

I always just found, selfmade validation of XML (no schemas) or stuff made with ActiveX. So, if there is no xml validation plugin/functionality to which i just can pass a xml and a xsd, i would like to get a quick introduction on how i would do it myself, so i can imagen it better. Probably it's quick a lot of work for making my own xml validation against xsd, right?

Thanks

like image 358
handy Avatar asked Nov 22 '11 08:11

handy


3 Answers

I would suggest to perform an Ajax request, validate on the server, and return the response to JS.

like image 192
ilyes kooli Avatar answered Nov 10 '22 12:11

ilyes kooli


I know that you prefer a jQuery solution, but there is something that it was developed in JS, and performs just the way you want.

http://syssgx.github.io/xml.js/

This link gives 3 ways of interaction:

  • (via browser) drag-and-drop XML files and then validate;
  • (via browser) copy&paste XML content into "textareas" and then validate;
  • (import/inlcude) adding the JS file to your webapp and then validate (as shown on page).
like image 28
Paulo Oliveira Avatar answered Nov 10 '22 14:11

Paulo Oliveira


The best answer I found so far was Is there ANY cross-platform way of validating xml against an xsd in javascript?
But that's not very satisfying and nearly two years old - ages for the fast developmet that's going on on the browser side

like image 3
Chris Avatar answered Nov 10 '22 12:11

Chris