在浏览器中突出显示和编辑XML [英] Highlight and Edit XML in a browser

查看:137
本文介绍了在浏览器中突出显示和编辑XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在浏览器中向用户提供可编辑的XML页面。

Trying to provide a user with editable XML page in a browser.

例如,以下是XML的一部分。

For example, the following is part of an XML.

<Employee name="John Doe" type="contract" ID="1000"> 
    <Salary>10000</Salary>  
    <Email>johndoe@johndoe.com</Email>  
</Employee>

当上述内容在浏览器(IE或FF)中呈现给用户时,能够突出显示一个属性或值。当突出显示并按下第二个鼠标按钮时,将弹出一个菜单进行编辑。对于属性和标签,它可以是像ID-TEST-PRESENT或ID-TEST-OPTIONAL。现在代替ID,当选择时属性应该改变为ID-TEST-PRESENT。

When the above is presented to the user in a brower (either IE or FF), the user should be able to highlight an attribute or the value. When highlighted and the second mouse button is pressed, this would pop up a menu for editing. For attributes and tags, it could be something like ID-TEST-PRESENT or ID-TEST-OPTIONAL. Now instead of ID, the attribute should change to ID-TEST-PRESENT when selected.

同样,对于值,可以呈现文本框,用户可以在其中输入一个新的值。然后,此更新的XML文件需要发送到后端并保存。

Likewise, for values, a text box can be presented, where the user can enter a new value. Then this updated XML file needs to be sent to the back end and saved.

这是否可行?如果是,最简单的方法是什么。

Is this doable? If yes, what would be the easiest way.

我一直编写嵌入式应用程序。这是我第一次在网络浏览器方面。任何帮助是赞赏。

I have always written embedded applications. This is my first foray on the web browser side. Any help is appreciated.

推荐答案

创建用于在特定XML词汇表中编辑信息的界面的一种方法是使用XForms。 (我认为这是迄今为止最简单和最好的,但YMMV。)给定一个适当的基础设施(见下文),使用XForms你所描述的将涉及:

One way to to create an interface for editing information in a particular XML vocabulary is to use XForms. (I think it is by far the easiest and best, but YMMV.) Given an appropriate infrastructure (see below), using XForms for what you describe would involve:


  1. 使用XHTML + XForms编写表单。为要让用户编辑的XML部分指定编辑窗口小部件;使XML的其他部分为只读(或不显示它们)。定义要如何提交编辑的数据。

  2. 当用户打开窗体时,XForms处理器会自动加载XML文档,并提供在第1步中指定的XForm中指定的编辑窗口小部件。用户编辑。 / li>
  3. 当用户单击提交按钮时,浏览器以XML格式将数据发送回服务器,服务器上的软件执行必要的验证(这是来自开放Web的用户输入,

正如你所看到的,它比使用AJAX滚动更简单一点(至少一旦你设置了基础结构)。

As you can see, it's a little simpler than rolling your own using AJAX (at least once you have the infrastructure set up).

XForms所需的基础设施部分取决于你使用的XForms实现。

What infrastructure is necessary for XForms depends in part on which XForms implementation you are using.

对于基于客户端的XForms实现(例如来自AgenceXML的XSLTForms或EMC的公式),您需要(a)服务器上的软件副本XSLTForms的情况,这意味着一个XSLT样式表,一个Javascript库和一个CSS文件),(b)可能在表单本身中的一个适当的链接(这需要做什么随着实现而变​​化),和(c)服务器愿意接受PUT请求。在某些上下文中,(c)这是最难设置的,但任何提供WebDAV接口的服务器都会做,所以SVN有自动版本化,Apache(单独或在Subversion之上)和其他工具

For client-based implementations of XForms (such as XSLTForms from AgenceXML, or Formula from EMC), you need (a) a copy of the software on your server (in the case of XSLTForms, this means one XSLT stylesheet, one Javascript library, and one CSS file), (b) possibly an appropriate link in the form itself (how this needs to be done varies with the implementation), and (c) a server willing to accept PUT requests. In some contexts, it will be (c) that is the hardest to get set up, but any server that provides a WebDAV interface will do, so SVN with auto-versioning, Apache (alone or on top of Subversion), and other tools can all be used.

对于基于服务器的实现(如Orbeon Forms或BetterForm),您需要安装XForms实现并在Web服务器上运行它;因为它们通常是servlet,您需要将它们放在servlet引擎中。一般来说,他们将带有某种形式的WebDAV服务器。

For server-based implementations (such as Orbeon Forms or BetterForm), you need to install the XForms implementation and run it on your Web server; since they are typically servlets, you will need to put them in a servlet engine. In general, they will ship with some form of WebDAV server included.

W3C和CWI的Steven Pemberton写了一个有用的 XForms教程简介;我维护一个指针列表,以及其他XForms-相关资料也可能有所帮助。

Steven Pemberton of W3C and CWI has written a helpful tutorial introduction to XForms; I maintain a list of pointers to that and to other XForms-related materials that may also be helpful.

这篇关于在浏览器中突出显示和编辑XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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