从 xpath 表达式创建 Web 表单
我想构建一个应用程序来编辑复杂 xml 文档中的某些字段。 (ISO19139)。 其想法是识别配置文件中应使用 xpath 表达式编辑的字段并自动生成相应的表单。
因此,应用程序将使用 xpath 从 xml 中提取字段的当前值,将其显示在表单中,并在提交表单时放置新值。
提取和写入值是通过创建、修改和写出 DOM 来完成的,但我想知道你们中是否有人有好的建议,如何自动从 xpath 表达式列表中创建 Web 表单并将表单字段绑定到 xml 字段由 xpath 引用。
有一些工具可以为已知语法的 xml 文档生成 XForms,但它们不是解决方案,因为相应的语法太复杂。
这是一个草图。我们有一个包含个人信息的 XML 文档,我们要在其中编辑街道地址和兄弟。配置文件中的 xpath 表达式标识应可编辑的字段。
配置文件:(xml 中的示例)
<config>
<field>
<xp>/person/home/street/</xp>
<name>Address</name>
</field>
<field>
<xp>/person/family/brother/</xp>
<name>Family (brother)</name>
</field>
</config>
应用程序:
将生成一个 Web 表单,其中包含地址和兄弟的文本字段。
谢谢 库尔特
I want to build an application to edit some fields in complex xml documents. (iso19139).
The idea is to identify the fields that should be edited with xpath expressions in a configuration file and to generate the corresponding form automatically.
So, the application would extract the current values of the fields from the xml using xpath, display it in a form and put the new values when the form is submitted.
Extracting and writing the values is done by creating, modifying and writing out the DOM, but I am wondering if any of you has a good suggestion how I can automatically create the webform off the list of xpath expressions and tie the formfields to the xml fields referenced by the xpath.
There are tools to generate XForms for xml documents for which the grammar is known, but they are not a solution as the corresponding grammar is too complex.
Here is a sketch. we have a XML document containing personal info, in which we want to edit the street address and the brother. The xpath expressions in the config file identify the fields that should be editable.
configuration file: (example in xml)
<config>
<field>
<xp>/person/home/street/</xp>
<name>Address</name>
</field>
<field>
<xp>/person/family/brother/</xp>
<name>Family (brother)</name>
</field>
</config>
application:
would generate a webform with a textfield for the address and the brother.
thanks
Kurt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 ASP.Net 中的一个简单版本...
该页面将具有以下控件。
这是构建表单然后将数据保存回 Xml 的代码
Here is a simple version in ASP.Net...
The page would have the following controls.
Here is the code to build the form and then save the data back to the Xml