开发者

Is there ANY cross-platform way of validating xml against an xsd in javascript?

开发者 https://www.devze.com 2023-01-04 16:26 出处:网络
As far as I can tell, the only way of doing 开发者_开发技巧it is to use the Microsoft DOM object, but as far as I\'m aware this isn\'t universally available, if you\'re browsing with Firefox on Linux

As far as I can tell, the only way of doing 开发者_开发技巧it is to use the Microsoft DOM object, but as far as I'm aware this isn't universally available, if you're browsing with Firefox on Linux for example.

For reasons of security and minimizing network traffic I can't pass the xml to an external tool to validate (much as I wish I could). Is there any way of getting javascript to do this regardless of the browser/platform being used?


Might be a tad late for you but maybe it'll help future searchers: http://syssgx.github.io/xml.js/


For browsers that provide it, you can use ActiveX and MSXML. This blog provides a tutorial on using it to do validation.

For Mozilla there is SchemaValidation developed as part of the XForms extension.

Beyond that, there was an SO user asking about his own validator. His question and information may be a place to start if you end up going that route.

See also the javascript and xsd tags on SO when used together.

However I'd suggest that you may want to look into an alternative - validating server-side, perhaps, or checking business logic by using XSLT to transform your XML and thereby prove that it meets your needs.


Ok, after a fair amount of research, it seems the simple answer to this one is 'no', unless I write my own validator in javascript.

0

精彩评论

暂无评论...
验证码 换一张
取 消