当前位置: 首页 > 网络学院 > XML相关教程 > XForms > XForms 模型

XForms
XForms 介绍
XForms 模型
XForms 命名空间
XForms 实例
XForms XPath
XForms 输入控件
XForms 选择控件
XForms 数据类型
XForms 属性
XForms 行为(Actions)
XForms 函数
Xforms 数据类型参考

XForms 模型


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 574 ::
收藏到网摘: n/a

The XForms model defines a template for the data to be collected in a form.
XForms 模型为集中于表单中的数据定义了一个模板。


The XForms Framework
XForms框架

The purpose of an HTML form is to collect data. XForms has the same purpose.
HTML 表单的作用是搜集数据。XForms 的作用是相同的。

With XForms, input data is described in two different parts:
通过 XForms,输入数据被描述在两个不同的部分中:

  • The XForm model (to describe the data and the logic)
    ?? XForms 模型(描述数据和逻辑)
  • The XForm user interface (to display and input the data)
    ?? XForms 用户界面(显示和输入数据)

The XForms model defines what the form is, what data it contains, and what it should do.
XForms model(XForms模型)定义了什么是表单,它包含什么数据,以及它应该做什么。

The XForms user interface defines the input fields and how they should be displayed.
XForms user interface(XForms用户界面)定义了输入域,以及它们如何被显示。


The XForms Model
XForm 模型

The XForms model is used to describe the data.
XForms模型用于描述数据。

The data model is an instance (a template) of an XML document.
数据模型是 XML 文档的一个实例(一个模板)。

The XForms model defines a data model inside a <model> element:
XForms 模型定义了一个 <model> 元素内部的一个数据模型:

<model>
<instance>

<person>
<fname/>
<lname/>
</person>
</instance>
<submission id="form1"

action="submit.asp"
method="get"/>
</model>

From the example above, you can see that the XForms model uses an <instance> element to define the XML template for data to be collected, and a <submission> element to describe how to submit the data.
从上面的例子,您可以看到 XForms 模型使用 一个 <instance> 元素来为需要收集的数据定义 XML 模板,并使用一<submission> 元素来描述如何提交数据。

The XForms model does not say anything about the visual part of the form (the user interface).
<submission> 模型没有表达任何有关表单可见部分(用户界面)的信息。


XForms Namespace
XForms命名空间

If you are missing the XForms namespace in these examples, or if you don't know what a namespace is, it will be introduced in the next chapter.
假如您忽略了这些例子中的 XForms 命名空间,或者假如您不清楚命名空间的概念,我们会在下一节介绍这个内容。


The <instance> Element
<instance>元素

The XForms model uses an <instance> element to define the data to be collected.
XForms 模型<instance> 元素来定义数据收集的数据。

XForms is always collecting data for an XML document. The <instance> element in the XForms model defines the XML document.
XForms 是为某个XML文档进行数据收集的。在这个 XForms 模型中的 <instance> 元素定义了这个 XML 文档。

In the example above the "data instance" (the XML document) the form is collecting data for looks like this:
上述案例中的"data instance"(XML文档)里,窗口是像这样采集数据的:

<person>
<fname/>
<lname/>
</person>

After collecting the data, the XML document might look like this:
数据收集完毕之后,XML文档也许会看起来像这样:

<person>
<fname>John</fname>
<lname>Smith</lname>

</person>

??


The <submission> Element
<submission>元素

The XForms model uses a <submission> element to describe how to submit the data.
XForms 模型使用 <submission> 元素来描述如何提交数据。

The <submission> element defines a form and how it should be submitted. In the example above, the id="form1" attribute identifies the form, the action="submit.asp" attribute defines the URL to where the form should be submitted, and the method="get" attribute defines the method to use when submitting the data.
<submission> 元素可定义表单以及如何提交表单。在上面的例子中,id="form1" 用于标示此表单,action="submit.asp" 属性表单被提交到的 URL,而 method="get" 属性定义了在表单提交过程中使用的方法。


The XForms User Interface
XForms用户界面

The XForms user interface is used to display and input the data.
XForms 用户界面用于显示和输入数据。

The user interface elements of XForms are called controls (or input controls):
XForms 的用户界面元素被称为控件或输入控件:

<input ref="fname"><label>First Name</label></input>
<input ref="lname"><label>Last Name</label></input>

<submit submission="form1"><label>Submit</label></submit>

In the example above the two <input> elements define two input fields. The ref="fname" and ref="lname" attributes point to the <fname> and <lname> elements in the XForms model.
在上面的例子中,两个 <input> 元素定义了两个输入域。ref="fname" 和 ref="lname" 属性指向了 XForms 模型中的 <fname> 和 <lname> 元素。

The <submit> element has a submission="form1" attribute which refers to the <submission> element in the XForms model. A submit element is usually displayed as a button.
<submit> 元素中的 submission="form1" 属性可引用 XForms 模型中的 <submission> 元素。submit 元素通常被显示为按钮。

Notice the <label> elements in the example. With XForms every input control element has a required <label> element.
请留意例子中的 <label> 元素。使用 XForms 的话,每个输入控件元素都必须有 <label> 元素。


You'll Need A Container
你会需要一个“容器”

XForms is not designed to work alone. There is no such thing as an XForms document.
XForms 没有被设计为单独工作的方式。也没有所谓的 XForms 文档。

XForms has to run inside another XML document. It could run inside XHTML 1.0, and it will run inside XHTML 2.0.
XForms 必须工作在另外一个 XML 文档中。它可运行在 XHTML 1.0 中,同时它也将工作在 XHTML 2.0 中。


All Together Now
现在全部组合起来

If we put it all together the document will look like this:
如果我们把它组合起来,此文档是这样的:

<xforms>
<model>
<instance>
<person>
<fname/>
<lname/>

</person>
</instance>
<submission id="form1"
action="submit.asp"
method="get"/>
</model>
<input ref="fname"><label>First Name</label></input>
<input ref="lname"><label>Last Name</label></input>
<submit submission="form1"><label>Submit</label></submit>
</xforms>

And the page will display pretty much like this:
页面会这样显示:

First Name
Last Name
?? ??
??

??


The XForms Processor
XForms处理器

An XForms Processor built into the browser will be responsible for submitting the XForms data to a target.
内建于浏览器中的 XForms 处理器将负责向目标提交 XForms 数据。

The data can be submitted as XML and could look something like this:
数据可作为 XML 来提交,类似这样:

<person>
<fname>Hege</fname>
<lname>Refsnes</lname>

</person>

Or it can be submitted as text, looking something like this:
或作为文本来提交,类似这样:

fname=Hege;lname=Refsnes

评论 (0) All

登陆 | 还没注册?