級別: 初級
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)
:
Name
和
Address
是
PersonalInfo
的子節點。它們也有自己的子節點。
<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 標記的表單
附錄 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:output
的
version
屬性。
-
indent
:對應于
xsl:output
的
indent
屬性。
-
encoding
:對應于
xsl:output
的
encoding
屬性。
-
mediaType
:對應于
xsl:output
的
media-type
屬性。
-
omitXMLDeclaration
:對應于
xsl:output
的
omit-xml-declaration
屬性。
-
standalone
:對應于
xsl:output
的
standalone
屬性。
-
CDATASectionElements
:對應于
xsl:output
的
cdata-section-elements
屬性。
-
replace
:指定應用提交之后如何返回信息。
根據 W3C XForms 文檔,
<submission>
“對如何提交、何處提交以及提交什么進行編碼”。這些屬性中的許多是 XSLT,但 XForms 處理卻不支持 XSLT 的
doctype-system
和
doctype-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。
-
submission
:
submission
元素必需的引用。
根據 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
:范圍的下界。
-
step
:
valueFrom
的遞增或遞減步長。
根據 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。語法為:
-
recalculate
:重新計算需要重新計算的域。語法為:
-
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
類型的屬性。
- 鏈接屬性:
- 單節點綁定屬性:
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 聯系。
|