在客户端使用JavaScript通过XSD验证XML [英] Validate XML against XSD with JavaScript on client side

查看:52
本文介绍了在客户端使用JavaScript通过XSD验证XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以友好的方式向用户显示XMLfile,因此我正在创建树状结构,例如: http://thecodeplayer.com/walkthrough/css3-family-tree ,而不是向用户显示原始XML.

I am required to show a user an XMLfile in a friendly way as a result I am creating a tree like structure such as: http://thecodeplayer.com/walkthrough/css3-family-tree instead of showing the user the raw XML.

现在,当创建一个新节点时,我正在服务器端对其进行验证.如果服务器验证了新提议的XML(tree),那么我将继续创建一个新节点.

Right now when creating a new node I am validating that on the server side. If the server validates the new proposed XML(tree) then I go ahead and create a new node for example.

无论如何,现在我想允许用户拖动这些节点.当拖动节点时,如果我在服务器端验证了提议,那将会很慢.所以我的问题是如何针对客户端的架构验证XML文件,这样,在拖动节点时,我可以根据验证是否成功来允许拖动节点.

Anyways now I will like to allow the user to drag these nodes. When dragging the nodes if I validate the proposed on the server side it will be to slow. So my question is how can I validate an XML file against a schema on the client side so that when dragging a node I can allow dragging the node or not depending whether or not the validation succeeds.

推荐答案

请参见 xml.js 程序包,该程序包会导出通过 libxml2 .

See the xml.js package, which exports an xmllint object ported via Emscripten from libxml2.

这篇关于在客户端使用JavaScript通过XSD验证XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆