Vincent.Chan‘s Blog

常用链接

统计

积分与排名

网站

最新评论

XForms 附录:从这里获取 XForms 规范信息和样本代码

级别: 初级

Joel Rivera, 暑假实习生, IBM Research
Len Taing, 暑假实习生, IBM Research

2002 年 9 月 01 日

本文是 developerWorks文章“ 准备使用 XForms”的附录。

返回文章


附录 A:样本代码清单:完整的订货单示例


												
														


<HTML xmlns="http://www.w3.org/1999/xhtml"

xmlns:xforms=http://www.w3.org/2002/01/xforms

xmlns:ev="http://www.w3.org/2001/xml-events"

xmlns:xlink="http://www.w3.org/1999/xlink">

<head>

<title>XForms: Order Form</title>

<link rel="stylesheet" type="text/css" href="AES.css">
<xforms:model id="data">

<xforms:instance>

<OrderInfo>

<PersonalInfo>

<Name>

<First></First>

<Middle></Middle>

<Last></Last>

</Name>

<Address>

<Street></Street>

<City></City>

<State></State>

<Zip></Zip>

</Address>

</PersonalInfo>

<PriceInfo>

<SubTotal></SubTotal>

<TaxTotal></TaxTotal>

<TaxRate></TaxRate>

<Total></Total>

</PriceInfo>

<TaxInfo>

<CT>.060</CT>

<NY>.085</NY>

<NJ>.083</NJ>

</TaxInfo>

<ShoppingCart>

<ProductInfo name="itm1">

<Quantity>5</Quantity>

<Description>Wht. Chocolate Bars</Description>

<UnitPrice>1.45</UnitPrice>

<ItemTotal>7.25</ItemTotal>

</ProductInfo>

<ProductInfo name="itm2">

<Quantity>8</Quantity>

<Description>Blk. Chocolate Bars</Description>

<UnitPrice>1.45</UnitPrice>

<ItemTotal>11.40</ItemTotal>

</ProductInfo>

<ProductInfo name="itm3">

<Quantity>2</Quantity>

<Description>Car. Filled Choc</Description>

<UnitPrice>1.80</UnitPrice>

<ItemTotal>3.60</ItemTotal>

</ProductInfo>

</ShoppingCart>

</OrderInfo>

</xforms:instance>

<!--Data Bindings-->

<xforms:bind ref="/OrderInfo/PriceInfo/TaxRate"

calculate="/OrderInfo/TaxInfo/CT"

relevant="/OrderInfo/PersonalInfo/Address/

State = 'CT'"/>

<xforms:bind ref="/OrderInfo/PriceInfo/TaxRate"

calculate="/OrderInfo/TaxInfo/NY"

relevant="/OrderInfo/PersonalInfo/Address/

State = 'NY'"/>

<xforms:bind ref="/OrderInfo/PriceInfo/TaxRate"

calculate="/OrderInfo/TaxInfo/NJ"

relevant="/OrderInfo/PersonalInfo/Address/

State = 'NJ'"/>

<xforms:bind ref="/OrderInfo/PriceInfo/SubTotal"

type="xsd:decimal"/>

<xforms:bind ref="/OrderInfo/PriceInfo/TaxTotal"

calculate="/OrderInfo/PriceInfo/TaxRate *

/ OrderInfo/PriceInfo/SubTotal"/>

<!--Submit Info-->

<xforms:submission id="submit1" action=http://www.example/

method="post"/>



</xforms:model>

</head>

<body>

<xforms:group>

<div>

<xforms:input class="First" id="first"

ref="OrderInfo/PersonalInfo/Name/First">

<div>

<xforms:label>First Name</xforms:label>

</div>

<xforms:hint>Enter First Name</xforms:hint>

</xforms:input>

<xforms:input class="Middle" id="middle"

ref="OrderInfo/PersonalInfo/Name/Name/Middle">

<xforms:label class="label">Middle Initial</xforms:label>

<xforms:hint>Enter Middle Initial</xforms:hint>

</xforms:input>

<xforms:input class="Last" id="last"

ref="OrderInfo/PersonalInfo/Name/Name/Last">

<xforms:label class="label">Last Name</xforms:label>

<xforms:hint>Enter Last Name</xforms:hint>

</xforms:input>

</div>

<div>

<xforms:input class="Street" id="street"

ref="OrderInfo/PersonalInfo/Address/Street">

<div>

<xforms:label>Street Address</xforms:label>

</div>

<xforms:hint>Enter Street Address</xforms:hint>

</xforms:input>

<br>

<xforms:input class="City" id="city"

ref="OrderInfo/PersonalInfo/Address/City">

<xforms:label class="label">City</xforms:label>

<xforms:hint>Enter City Name</xforms:hint>

</xforms:input>

<xforms:input class="State" id="state"

ref="OrderInfo/PersonalInfo/Address/State">

<xforms:label class="label">State</xforms:label>

<xforms:hint>Enter State Initials</xforms:hint>

</xforms:input>

<xforms:input class="ZipCode" id="zipcode"

ref="OrderInfo/PersonalInfo/Address/ZipCode">

<xforms:label class="label">Zip Code</xforms:label>

<xforms:hint>Enter The Zip Code</xforms:hint>

</xforms:input>

</div>

<br>

<div>

<xforms:label class="label">Sub Total $</xforms:label>

<xforms:output class="Amount" id="subtotal"

ref="OrderInfo/PriceInfo/SubTotal" />

<br>

<xforms:label class="label">Tax Amount $</xforms:label>

<xforms:output class="Amount" id="taxtotal"

ref="OrderInfo/PriceInfo/TaxTotal" />

<br>

<xforms:label class="label">Total $</xforms:label>

<xforms:output class="Amount" id="total"

ref="OrderInfo/PriceInfo/Total" />

</div>

<br>

<div>

<xforms:label class="label">Shopping Cart</xforms:label>

<xforms:repeat id="shoppingcart"

nodeset="OrderInfo/ShoppingCart/ProductInfo">

<xforms:output ref="Quantity" />

<xforms:output ref="Description" />

<xforms:output ref="UnitPrice" />

<xforms:output ref="ItemTotal" />

</xforms:repeat>

</div>

<br>

<xforms:submit id="submit1">

<xforms:label>Send Payment</xforms:label>

</xforms:submit>

<xforms:trigger>

<xforms:label>Cancel</xforms:label>

<xforms:action event="click" >

<xforms:refresh ev:event="xforms:activate"/>

</xforms:action>

</xforms:trigger>

</xforms:group>

</body>

</HTML>



返回文章





回页首


附录 B:主文章中提及的标记(按字母排序)


附录 B1:action


语法:

												
														


<action>

(Common Attributes)

(Events)

</action>



用于:在模型中,封装操作。

属性:

根据 W3C XForms 文档, <action> “用于对多个操作进行分组”。操作列表应该列在元素 <action> 中,而不是列在所包含的操作中。

												
														


<trigger>

<label>Clear</label>

<action ev:event="xforms:activate">

<resetInstance />

</action>

</trigger>



ev:event="xforms:activate" 必须在 <action> 标记内。如果在 resetInstance 标记内使用它,则不会起作用。

附录 B2:bind


语法:

												
														


<bind

nodeset = binding-expression

(model item properties )

(Content)>

</bind>



用于:模型中。

属性:

  • nodeset :是一个绑定表达式,它选择该 <bind> 所要操作的节点集合。
  • 模型项特性:参阅 附录 H

根据 W3C XForms 文档, <bind> “对选自实例数据的 nodeset 进行操作”。 <bind> 是 XForms 的关键部分。其元素对那些应用于 nodeset 的模型项特性进行编码。每个 <bind> 元素从实例数据选择一个 nodeset,并应用指定的模型项特性。

												
														


<bind ref="my:PersonalInfo/Address/Zip" required="true" />



附录 B3:group


语法:

												
														


<group

(single node binding attributes)

(common attributes)>

(XML/HTML)

</group>



用于:在用户界面中,编排信息。

属性:

W3C XForms 规范将 <group> 标记描述为“定义表单控件层次结构的容器”。它被用于将数据组织成树状的格式(假定数据可以嵌套)。

												
														


<group xmlns="http://www.w3.org/2002/01/XForms">

<label>People List</label>

<repeat id="lineset" nodeset="Customer/PersonalInfo">

<group xmlns="http://www.w3.org/2002/01/XForms">

<group xmlns="http://www.w3.org/2002/01/XForms">

<p> <output ref="Name/FirstName"></output>

<output ref="Name/MI"></output>

<output ref="Name/LastName"></output></p>

<p> <output ref="Address/Street"></output>

<output ref="Address/HouseNumber"> </output></p>

<p> <output ref="Address/City"></output>

<output ref="Address/State"></output>

<output ref="Address/Zip"></output></p>

</group>

</group>

</repeat>

</group>



上面的清单显示了组织数据是多么的容易。第一个 <group> 封装所有客户的信息。接下来的子 <group> 保存每个客户项的信息。

附录 B4:input


语法:

												
														


<input

(Single node binding attributes)

(Common attributes)

(UI Common attributes)

inputMode = xsd:string


incremental>

(label, (help|hint|alert|action|extension))

</input>



用于:在用户界面中,获取用户数据。

属性:

  • nodeset 绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • inputMode :提供用户代理为文本输入选择适当的输入方式的提示。应当尽可能多地使用它。
  • incremental :为 true 时,这个表单控件生成 xforms-value-changing 事件。

根据 W3C XForms 文档, <input> “支持自由格式的数据项”。


图 A1. 输入框
输入框

附录 B5:instance


语法:

												
														


<instance

(Common Attributes)

(Linking)

schema = xsd:anyURI >

(Any Content)

</instance>



用于:模型中。

属性:

  • 通用属性:参阅 附录 H
  • 链接:参阅 附录 H
  • schema :到外部定义的实例数据的可选链接。

根据 W3C XForms 文档, <instance> “包含提供初始实例数据的框架实例文档”。无须内联实现该实例定义的数据。可以在外部 URI 中指定这些数据。

												
														


<instance>

<PersonalInfo>

<Name>

<FirstName></FirstName>

<MI></MI>

<LastName></LastName>

</Name>

<Address>

<Zip></Zip>

<State></State>

<City></City>

<HouseNumber></HouseNumber>

<Street></Street>

</Address>
<Taxes>

<Amount></Amount>

<Rate></Rate>

<Pay></Pay>

</Taxes>

</PersonalInfo>

</instance>



<instance> 可能只指定了数据结构,也可能包含初始值。

附录 B6:model


语法:

												
														


<model

(Common Attributes)

functions = list of QNames>

(elements)

</model>



用于:HTML 表单头。

属性:

  • functions :该 XForms <model> 所使用的可选 XPath 扩展函数列表。
  • 通用属性:参阅 附录 C

根据 W3C XForms 文档, <model> “被用作定义 XForms 模型的 XForms 元素的容器”。 <model> 是 XForms 的关键标记之一,它是完成 XForms 文档所必须的。可以添加其它可以完成模型的标记( 元素)。这些标记是:

  • <instance> (此标记是必需的)
  • <schema>
  • <submission>
  • <bind>
  • <privacy>
  • 操作事件处理程序
  • <extension>

以下清单中说明了此标记:

												
														


<model id="data" xmlns="http://www.w3.org/2002/01/xforms">

<instance>

<AddressInfo>

<Name>

<FirstName></FirstName>

<MI></MI>

<LastName></LastName>

</Name>

<Address>

<Zip></Zip>

<State></State>

<City></City>

<HouseNumber></HouseNumber>

<Street></Street>

</Address>

</AddressInfo>

</instance>

<submission action=

"http://summer2/AddressServices/AddrServices.asmx/GetCustomer
"

method="post" replace="all" id="get" />

</model>



该示例显示了如何构建简单模型。 AddressInfo 是表单上使用的数据结构。

附录 B7:output


语法:

												
														


<output

(Common Attributes)

(single node binding attributes)

appearance >

(Empty content)

</output>



用于:在用户界面中显示信息。

属性:

  • 单节点绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • appearance :这一表单控件不使用 UI 通用属性组。

W3C 文档对 <output> 进行了如下描述:“...显示来自实例数据的值,但不提供输入数据或更改数据的方法”。该标记仅用于显示目的。


图 A2. 输出框
输出框

附录 B8:repeat


语法:

												
														


<repeat

(node binding attributes)

(common attributes)

startIndex = xsd:positiveInteger : 1

number = xsd:nonNegativeInteger >

(XML/HTML)

</repeat>



用于:在用户界面中,作为表单控件。

属性:

  • Nodeset 绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • startIndex :指示将显示集合中的哪个起始元素;最小值是 1。
  • number :提示 XForms 处理器该显示多少元素。

根据 W3C XForms 规范,“ <repeat> 表示重复的同构集合 ? 换言之,就是一个完全由类似的表单控件组成的集合”。以合适的方式显示(如数据模型中所示的)类似信息时,该标记十分有用。它看起来可能很复杂,但使用起来却极其容易。

												
														


<!--in user interface-->

<repeat id="lineset" nodeset="Customer/PersonalInfo">

<p> <output ref="Name/FirstName"></output>

<output ref="Name/MI"></output>

<output ref="Name/LastName"></output></p>

<p> <output ref="Address/Street"></output>

<output ref="Address/HouseNumber"></output></p>

<p> <output ref="Address/City"></output>

<output ref="Address/State"></output>

<output ref="Address/Zip"></output></p>

</repeat>



在上面的示例中,您可以看到创建 <repeat> 结构是多么的容易。其结构如下:

  • Customer/PersonalInfo :结构的顶层节点。它定义在数据模型中。 Customer 是父节点, PersonalInfo 是子节点。
  • Name/(FirstName/MI/LastName)Address/(Street/HouseNumber/City/State/Zip)NameAddressPersonalInfo 的子节点。它们也有自己的子节点。
												
														


<xforms:repeat id="shoppingcart"

nodeset="OrderInfo/ShoppingCart/ProductInfo">

<xforms:output ref="Quantity"/>

<xforms:output ref="Description"/>

<xforms:output ref="UnitPrice"/>

<xforms:output ref="ItemTotal"/>

</xforms:repeat>




图 A3. 具有 repeat 标记的表单
具有 repeat 标记的表单

附录 B9:submission


语法:

												
														


<submission

(Common Attributes)

(single node binding attributes)

action = xsd:anyURI

mediaTypeExtension = "none" | qname-but-not-ncname : "none"

method = "post" | "get" | qname-but-not-ncname : "post"

version = xsd:NMTOKEN

indent = xsd:boolean

encoding = xsd:string

mediaType = xsd:string

omitXMLDeclaration = xsd:boolean

standalone = xsd:boolean

CDATASectionElements = list of xsd:QName

replace = "all" | "instance" | "none" | qname-but

not-ncname : "all">

(XForms Actions)

</submission>



用于:在用户界面中作为提交操作的控件。

属性:

  • 通用属性:参阅 附录 H
  • 单节点绑定属性:参阅 附录 H
  • action :提交实例数据所需的目的地。
  • mediaTypeExtension :描述序列化格式的可选信息。这是对 mediaType 的补充。
  • method :有关用于传输序列化的实例数据的协议的可选指示符。
  • version :对应于 xsl:outputversion 属性。
  • indent :对应于 xsl:outputindent 属性。
  • encoding :对应于 xsl:outputencoding 属性。
  • mediaType :对应于 xsl:outputmedia-type 属性。
  • omitXMLDeclaration :对应于 xsl:outputomit-xml-declaration 属性。
  • standalone :对应于 xsl:outputstandalone 属性。
  • CDATASectionElements :对应于 xsl:outputcdata-section-elements 属性。
  • replace :指定应用提交之后如何返回信息。

根据 W3C XForms 文档, <submission> “对如何提交、何处提交以及提交什么进行编码”。这些属性中的许多是 XSLT,但 XForms 处理却不支持 XSLT 的 doctype-systemdoctype-public 。此标记提供了许多控制表单提交机制的参数。

												
														


<submission action=

"http://summer2/AddressServices/AddrServices.asmx/GetCustomer"

method="post" replace="all" id="get" />



action 指示做什么, method 指示如何做,而 id 指定如何从主体访问它。

附录 B10:submit


语法:

												
														


<submit

(Common Attributes)

(single node binding attributes)

(UI Common Attributes)

submission >

(label, (help|hint|alert|action|extension))

</submit>



用于:此标记用作主体内发送数据的控件。

属性:

  • nodeset 绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • submissionsubmission 元素必需的引用。

根据 W3C XForms 文档, <submit> “启动它所绑定的全部或部分实例数据的提交”。 <submit> 完成与 HTML 的 <submit> 相同的任务。它分派一个由 <submission> 元素处理的 xforms:activate 事件。如果在 <submit> 标记中没有指定该元素,那么就使用文档中指定的第一个 <submission> 元素。不可能对这个控件进行绑定。


图 A4. 提交触发器
提交触发器

附录 B11:switch 和 case


语法:

												
														


<switch

(common attributes)>

[Case]

</switch>

<case

(common attributes)

selected = xsd:boolean>

(XML)

</case>



用于:在用户界面中,作为 UI 选择器。

属性:

  • 通用属性:参阅 附录 H
  • selected :case 的可选的选择状态。

根据 W3C XForms 文档, <switch><case> “允许创建可以随用户和事件的不同而变化的用户界面”。当一些备选界面有不同的对应操作时使用 <switch>

												
														


<switch id="sw">

<case id="in" selected="true">

<input ref="yourname">

<label>Please tell me your name</label>

<action ev:event="activate">

<toggle case="out" />

</action>

</input>

</case>

<case id="out" selected="false">

<p>Hello <output ref="yourname"></output>

<trigger id="editTrigger">

<label>Edit</label>

<action id="editAction" ev:event="activate">

<toggle case="in" />

</action>

</trigger></p>

</case>

</switch>



上面的清单是非常简单的示例。表单请求姓名直到用户输入姓名。一旦用户输入姓名,switch 的 case 发生改变然后出现带有用户姓名的欢迎信息。

附录 B12:trigger


语法:

												
														


<trigger

(Common Attributes)

(single node binding attributes)

(UI Common Attributes)>

label

</trigger>



用于:在用户界面中显示触发器。

属性:

根据 W3C XForms 文档, <trigger> “允许用户触发的操作”。它非常类似于同名的 HTML 标记。此标记需要 <action> 子元素来执行操作。

												
														

<trigger>

<label>Clear</label>

<action ev:event="activate">

<resetInstance />

</action>

</trigger>



该标记应该有 <label> 标记来指示触发器的标签。

返回文章





回页首


附录 C:主文章中未提及的通用标记。


附录 C1:extension


语法:

												
														


<extension>

(Content)

</extension >



用于:模型中。

根据 W3C XForms 文档, <extension> 是“用于来自除 XForms 名称空间之外的任何名称空间的、特定于应用程序的扩展元素的容器”。对元素的处理不是用该标记指定的。在下面的示例中,RDF 是元数据,它被附加到另一个表单控件上。

												
														


<input ref="dataset/user/email" id="email-input">

<label>Enter your email address</label>

<extension>

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf- syntax-ns#">

<rdf:Description rdf:about="#email-input">

<my:addressBook>personal</my:addressBook>

</rdf:Description>

</rdf:RDF>


</extension>

</input>



附录 C2:range


语法:

												
														


<range

(single node binding attributes)

(common attributes)

(common UI)

start = datavalue

end = datavalue

step = datavalue-difference>

(label, (help|hint|alert|action|extension))

</range>



用于:该标记用于在用户界面上选择值的范围。

属性:

  • 单节点绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • start :范围的词法上界。
  • end :范围的下界。
  • stepvalueFrom 的递增或递减步长。

根据 W3C XForms 文档, <range> “允许从连续范围的值上进行选择”。它仅限于某些数据类型。输入应该与 dataType 相同。通过使用不同属性,该标记可以实现许多不同功能。

												
														


<range ref="/stats/balance" start="-2.0" end="2.0" stepSize="0.5">

<label>Balance</label>

</range>



附录 C3:select


语法:

												
														


<select

(single node binding attributes)

(common attributes)

(common UI)

incremental>

(label, (choices|item|itemset), (help|hint|alert|action|extension))

</ select >



用于:在用户界面中需要从列表中选择多个选项时。

属性:

  • 单节点绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • incremental :为 true 时,此表单控件生成 xforms-value-changing 事件。

根据 W3C XForms 文档, <select> “允许用户从一组选择中选择多个选项”。当用户必须对一个问题或一项任务选择多个答案时,这一功能尤为有用。标记必须绑定到一个能够保存序列的 simpleContent

												
														


<select ref="my:icecream/my:flavors">

<label>Flavors</label>

<choices>

<item>

<label>Vanilla</label>

<value>v</value>

</item>

<item>

<label>Strawberry</label>

<value>s</value>

</item>

<item>

<label>Chocolate</label>

<value>c</value>

</item>

</choices>

</select>



附录 C4: select1


语法:

												
														


<select1

(single node binding attributes)

(common attributes)

(common UI)

selection = "open" | "closed" : "closed"

incremental>

(label, (choices|item|itemset), (help|hint|alert|action|extension))

</select1>



用于:在用户界面中需要从列表进行单项选择时。

属性:

  • 单节点绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • selection :确定列表中是否允许空项的属性。
  • incremental :为 true 时,此表单控件生成 xforms-value-changing 事件。

根据 W3C XForms 文档, <select1> “允许用户从多个选择中进行单项选择”。当您需要一个表单使得用户只能对一个问题或一项任务选择一个答案时,这一功能非常有用。此标记绑定到任何 simpleContent 。对于每个选项,必须给出一个标签。

												
														


<select1 ref="my:icecream/my:flavor">

<label>Flavor</label>

<item>

<label>Vanilla</label>

<value>v</value>

</item>

<item>

<label>Strawberry</label>

<value>s</value>

</item>

<item>

<label>Chocolate</label>

<value>c</value>

</item>

</select1>



附录 C5:textarea


语法:

												
														


<textarea

(single node binding attributes)

(common attributes)

(common UI)

incremental

inputMode = xsd:string>

(label, (help|hint|alert|action|extension))

</textarea>



用于:在用户界面上编写大量数据。

属性:

  • 单节点绑定属性:参阅 附录 H
  • 通用属性:参阅 附录 H
  • UI 通用属性:参阅 附录 H
  • incremental :为 true 时,此表单控件生成 xforms-value-changing 事件。
  • InputMode :提示用户为文本输入选择适当的输入方式。应该尽可能多地使用它。

根据 W3C XForms 文档, <textarea> “支持自由格式的数据项,并旨在用于输入多行内容”。它是 XForms 标记中同其 HTML 对应标记最相似的一个标记。对于 XForms 标记,您可以选择允许输入多少数据,还可以执行其它控件操作。

												
														


<textarea ref="message/body">

<label>Message Body</label>

<hint>Enter the text of your message here</hint>

</textarea>



返回文章





回页首


附录 D:计算所支持的原始函数


  • 基本算术功能:
    • 加( +
    • 减( -
    • 乘( *
    • 除( div/
  • boolean-from-string(string) :如果字符串与字符串“true”相同则返回 true ,而如果字符串与字符串“false”相同则返回 false 。对于其它所有情况,都会返回一个致命错误。
  • if (boolean, string1, string2) :如果布尔求值为 true 则返回 string1 ;否则,就返回 string2
  • avg(nodeset) :返回 nodeset 的算术平均值。
  • min(nodeset) :返回 nodeset 中的最小值。
  • max(nodeset) :返回 nodeset 中的最大值。
  • count(nodeset) :返回 nodeset 中的节点数。
  • count-non-empty(nodeset) :返回 nodeset 中的非空节点数。
  • sum(nodeset) :返回 nodeset 中节点的和。
  • cursor(string) :string 参数应该是对 repeat 语句的 id 引用。cursor 返回重复光标的当前位置。
  • property(string) :string 参数应该是一个有效的 XForms 特性; property 返回 XForms 特性的值。
  • now() :以字符串形式返回当前日期和时间。

返回文章





回页首


附录 E:XForms 约束


注:这些 XForms 约束通常用作 <bind> 标记内的属性。

  • type :指定数据绑定的 XSD/数据类型。
  • readOnly :对值进行限制,使得对它只能读而不能改。
  • required :强制用户在域中输入数据。
  • relevant :定义何时数据绑定可应用的条件。
  • calculate :将值绑定到一个表达式(参阅 附录 D以获取可以包含在表达式中的合法函数的完整列表)。
  • isValid :根据 W3C XForms 规范,“指定一个谓词,如果要使相关实例数据被认为是合法的,那么必须满足此谓词”。
  • maxOccurs :用于重复结构,定义允许的子结构的最大数目。
  • minOccurs :用于重复结构,定义所需的子结构的最小数目。

返回文章





回页首


附录 F:通用子元素


下列子元素有助于用表单控件标记添加元数据:

  • label :标注表单控件。
  • help :给表单控件附加额外帮助信息,当用户陷入困境或迷惑不解时会发现这些帮助信息非常有用。
  • hint :附加表单控件的提示。类似于 help,但更简单。
  • alert :提供一种在事件发生时通知用户的方法。
  • extension :用开发人员创建的标记扩展 XForms 定义。

返回文章





回页首


附录 G:XForms 操作


  • dispatch :将 XML 事件分派给目标元素。可以分派两类事件:预先定义的 XForms 事件或用户定义的 XForms 事件。然而,XForms 处理器只处理 XForms 事件;用户定义的事件被忽略了。语法为:

    																
    																		


    <dispatch name = name of the event to dispatch

    target = id of the target element

    bubbles = boolean of whether the event bubbles

    cancelable = boolean of whether the event is cancelable />



  • refresh :刷新 XForms。语法为:

    																
    																		


    <refresh/>



  • recalculate :重新计算需要重新计算的域。语法为:

    																
    																		


    <recalculate/>



  • revalidate :重新验证实例数据。语法为:

    																
    																		


    <revalidate/>



  • setFocus :将输入焦点移到 idref 中指定的表单控件。语法为:

    																
    																		


    <setfocus idref = id of the form control to set the focus on />



  • submitInstance :将实例数据提交到后端。这是 <submit> 调用的操作。语法为:

    																
    																		


    <submitInstance submission = id of submission />



  • resetInstance :将实例数据重置为其缺省值。语法为:

    																
    																		


    <resetInstance model = id of model />



  • setRepeatCursor :将重复结构的位置设置为一个指定位置。语法为:

    																
    																		


    <setRepeatCursor repeat = id of repeat structure cursor = new position />



  • action :XForms 操作的事件处理程序。语法为:

    																
    																		


    <action>

    Set of XForms actions

    </action>



关于下列操作,请参考 XForms 规范以获取详细信息:

  • loadURI :遍历指定的 XLink。
  • setValue :设置实例节点的值。
  • insert :在 nodeset 中插入新项。
  • delete :从 nodeset 中删除节点。
  • toggle :从一组条件中选择一种条件;用于 <switch> 标记。
  • script :使用开发人员设置的来自其它脚本语言的事件处理程序。
  • message :显示消息。

返回文章





回页首


附录 H:常用属性


  • 通用属性:
    • anyAttribute: 所有的 XForms 元素上都允许的外来属性。包含文档语言必须在每个 XForms 元素上包含一个 xsd:ID 类型的属性。
  • 链接属性:
    • src: 指定将要被自动检索的 URI。
  • 单节点绑定属性:
    • ref :绑定表达式。
    • model :XForms 模型选择器。
    • bind :对 <bind> 元素的引用。
  • Nodeset 绑定属性:
    • nodeset :绑定表达式。
    • model :XForms 模型选择器。
    • bind :对绑定元素的引用。
  • UI 通用属性:
    • help :将帮助信息附加到表单控件。
    • hint :将提示信息附加到表单控件。
    • alert :将警告或错误信息附加到表单控件。




回页首






回页首


作者简介


Joel Rivera 是 IBM 在纽约州霍索恩(Hawthorne)的 T.J. Watson Research Lab 实习的暑假实习生。2001 年,他在 Angel Diaz 领导下工作,开发用于 Web 服务的浏览器。2002 年,他回到由 Lauretta Jones 领导的下一代 HCI 组件(Next Generation HCI Components)团队工作。2002 年 5 月,他从波多黎各大学(University of Puerto Rico)马亚圭斯(Mayaguez)分校获得学士学位。他对分布式系统和高性能汽车感兴趣。可以通过 joelr@ece.uprm.edu和 Joel 联系。



Len Taing 是 IBM 在纽约州霍索恩(Hawthorne)的 T.J. Watson Research Lab 实习的暑假实习生。今年是他在暑假为 IBM Research 工作的第三个年头:1999 年他在位于纽约州霍索恩的、由 Roy Byrd 领导的文本分析小组(Text Analysis Group)工作;2000 年他在位于麻萨诸塞州坎布里奇市的、由 Charles Wiecha 领导的通用交互(Universal Interaction)小组工作;2002 年他在位于纽约州霍索恩市的、由 Lauretta Jones 领导的下一代 HCI 组件团队工作。他在哈佛大学主修计算机科学,即将升入毕业班。他对人工智能和中国电影感兴趣。可以通过 taing@fas.harvard.edu和 Len 联系。

posted on 2006-03-21 23:47 Vincent.Chen 阅读(496) 评论(0)  编辑  收藏 所属分类: XML


只有注册用户登录后才能发表评论。


网站导航: