服务器端 XForms 表单验证和集成到 ASP.NET
我最近一直在研究为 ASP.NET Web 应用程序创建基于 Web 的表单的方法,该表单可以在运行时编辑和管理。例如,管理员可能希望添加新的验证规则或一组新的字段。
圣杯将提供一种指定表单以及(可能非常复杂)任意验证规则以及为每个字段分配数据源的方法。然后,该规范将用于更新 Web 应用程序中部署的表单,然后验证客户端和服务器端的提交。
我的调查让我发现了 Xforms 和许多支持它的技术。一种解决方案似乎是 IBM Lotus Forms,但这需要非常大的投资就基础设施而言,这使得它不可行,尽管表单设计器可能作为创建表单的独立工具很有用。我还对浏览器插件打了折扣,因为表单必须公开可见并且跨浏览器兼容。
我注意到有许多 JavaScript 库提供给定 Xforms 模式的客户端实现。这些将提供部分解决方案,但服务器端验证仍然是一个要求。
另一种选择似乎涉及使用服务器端解决方案,例如 Java 应用程序 Orbeon。 Orbeon 提供了一个用于指定表单的工具(虽然不像 Lotus Forms Designer 那样丰富),但最有趣的一点是它可以将 XForms 模式转换为带有验证的 XHTML 表单。如果可以与现有的 ASP.NET 应用程序集成,那么它是用 Java 编写的,这并不是一个大问题。
所以我的问题是以前是否有人这样做过。这听起来像是一个应该解决的问题,但本质上非常复杂。似乎可以使用现成的工具来设计表单并将其导出到 Xforms 架构和 xhtml 表单,并且似乎可以采用该 xforms 架构和表单并使用客户端库发布它。似乎困难的是提供一种在服务器端验证表单提交并将该过程与 .NET 很好地集成的方法(尽管 .NET 社区似乎并不参与 XForms;如果我错了,请纠正我)就这一点而言)。
如果一个产品提供了一些简单的东西,比如可以根据模式验证提交的 Web 服务,我会非常高兴。也许 Orbeon 会这样做,但如果有知情者能在我进一步研究之前为我指出正确的方向,我将不胜感激。
非常感谢。
I have recently been investigating methods of creating web-based forms for an ASP.NET web application that can be edited and managed at runtime. For example an administrator might wish to add a new validation rule or a new set of fields.
The holy grail would provide a means of specifying a form along with (potentially very complex) arbitrary validation rules, and allocation of data sources for each field. The specification would then be used to update the deployed form in the web application which would then validate submissions both on the client side and on the server side.
My investigations led me to Xforms and a number of technologies that support it. One solution appears to be IBM Lotus Forms, but this requires a very large investment in terms of infrastructure, which makes it infeasible, although the forms designer may be useful as a stand-alone tool for creating the forms. I have also discounted browser plug-ins as the form must be publicly visible and cross-browser compliant.
I have noticed that there are numerous javascript libraries that provide client side implementations given an Xforms schema. These would provide a partial solution but server side validation is still a requirement.
Another option seems to involve the use of server side solutions such as the Java application Orbeon. Orbeon provides a tool for specifying the forms (although not as rich as Lotus Forms Designer), but the most interesting point is that it can translate an XForms schema into an XHTML form complete with validation. The fact that it is written in Java is not a big problem if it is possible to integrate with the existing ASP.NET application.
So my question is whether anyone has done this before. It sounds like a problem that should have been solved but is inherently very complex. It seems possible to use an off-the-shelf tool to design the form and export it to an Xforms schema and xhtml form, and it seems possible to take that xforms schema and form and publish it using a client side library. What seems to be difficult is providing a means of validating the form submission on the server side and integrating the process nicely with .NET (although it seems the .NET community doesn't involve themselves with XForms; please correct me if I'm wrong on this count).
I would be more than happy if a product provided something simple like a web service that could validate a submission against a schema. Maybe Orbeon does this but I'd be grateful if somebody in the know could point me in the right direction before I research it further.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能错过了一些东西,但是......
我在传递中完成此类事情的方式是为表单声明和创建一个模式。一个 xslt 将该 xml 转换为 html。然后,您可以根据您设计的 xml 架构添加各种验证。不过,我通常缺少的是表单设计师。
I'm probably missing something but...
The way I've done this sort of thing in the pass is to create a schema for form declaration & an xslt to convert that xml to html. You can then add all sorts of validation, based on the xml schema you've designed. What I am usually missing is the form designer though.
您可以使用 XHTML 作为表单,或者像 Simon 建议的那样,使用自定义语言作为抽象层。应用程序可以在运行时加载表单,对其进行转换/设计样式并将其提供给用户。您可以编辑表单并进行更改,而无需重新编译/重新部署。
对于验证,您可以使用 Schematron,也可以使用 XML 感知工具在运行时轻松编辑。
您可以使用 Javascript 在浏览器中生成 XML 数据,也可以在服务器上将
application/x-www-form-urlencoded
转换为 XML(这就是我在 此页面)。You can use XHTML for the forms, or like Simon suggested, a custom language as an abstraction layer. The application can load the form at runtime, transform/style it and serve it to the user. You can edit the form and make changes without the need to recompile/redeploy.
For validation you can use Schematron, this can also be easily edited at runtime using XML-aware tools.
You can use Javascript to produce XML data in the browser, or you can transform
application/x-www-form-urlencoded
to XML on the server (that is what I do on this page).