Decks and cards

WML 的資料結構為card的集合.部分card集合為一個WML deck. 每個 card 含有content和瀏覽說明.邏輯上,使用者瀏覽一系列的card, 回顧每個的 contents,鍵入需要的資訊,做出選擇進入下一個card,或是回到上一個card

Common attributes

所有的 WML elements 有兩種核心屬性" id and class" ,可以被serer端用來轉換工作. id 屬性提供在deck中唯一的name .  class 屬性聯繫 element ,包括一或數種以上classes.

Multiple elements 可以有相同的class name.所有在single deck的 elements 包括一個common class name被分為同一個class 的部分. 一個 element 可以有多個class,每個class name都列在class屬性中.不同的class name但是有同一種屬性必須用空白隔開.多餘的class name會被移除,WML agent 會忽略這些屬性.

所有有文字的 elements 會包含 xml:lang 這個屬性. xml:lang 說明element所用的語言,告訴 user agent 去使用什麼語言 , 包括element 的 content 和屬性值.

Document header

一個正確的 WML deck 必須是XML 文件,所以要含有XML的宣告以及文件型態的宣告.典型的文件開頭含有

<?xml ersion="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">

注意下面文件的identifier:

        The SGML public identifier is "-//WAPFORUM//DTD WML 1.1//EN".

        The WML media type identifier is:

                — In textual form: "text/nd.wap.wml"

                — In tokenized form: "application/nd.wap.wmlc"

!注意 : 這些並未在IANA註冊 , 只是實驗性質而已.

wml element

  • Description

    wml element定義一個 deck 並且把所有資訊和cards封入deck.

  • Contained elements

            head ?

            template ?

            card +

  • Syntax

    wml element 的 xml:lang 屬性解釋如下

    Attribute Explanation
    xml:lang=nmtoken 這屬性說明文件中所使用的語言,詳細內容請參照"Common attributes"文件第23頁.

    Example [16.]

    下面的例子含有兩個card,在讀入deck後,user agent會展示第一個card,如果user啟動element,user agent會展示第二個card

    xml:lang 屬性說明下面文件使用 US English.

    <wml xml:lang="en-us">
        <card id="card1" title="Card 1">
            <do type="accept">
                <go href="#card2"/>
            </do>
            <p>
                Hello world!
                This is the first card...
            </p>
        </card>
        <card id="card2" title="Card 2">
            <p>
                This is the second card.
                Goodbye.
            </p>
        </card>
    </wml>

    產生結果如下圖所示

    card element

  • Description

    WML deck 包含許多種card的集合,每種card說明與使用者不同形式的互動.card element 是 text 和 input elements 的容器,可以展示多樣化的內容,使用多種deices. card element 表明一般的 layout 和需要的 input fields, 自由的完成 layout 和 input schemes 在user agent中.舉個例子, 一個 card 可以表示在一個 single page 在一個大螢幕,或許多頁在一個小螢幕上.

    card 可以包含 markup, input fields 和 elements 表示其結構. card 的順序是有意義的, 你可以使用card 的 id當作fragment anchor. 相關資訊請參照 "Fragment anchors" 文件第20頁.

  • Contained elements

    oneent *

    timer ?

    do *

    p *

    !注意: oneent elements必須放在第一個,timer element, the timer 必須跟隨在 oneent elements 之後和 do 或 p elements之前.

  • Syntax

    card element 的屬性如下表

    Attribute Explanation
    title=data 這屬性說明card的諮詢資訊
    newcontext=boolean 如果你把此屬性設為true,瀏覽器將會初始化此card,並且執行下列運作:

        清除naigational history state.

        重設implementation-specific state 為一般值.

    newcontext 只在 go task中使用.詳細用法請參考 Example [46.] 文件第85頁.default 值為 false.

    ordered=boolean 這屬性告訴user agent,card content是如何組織的.此屬性可以用來指出要如何組成content presentation或是 o其他有關card中 layout的敷T.

    ordered="true"     表示card由線性的 field elements組成,舉例來說, questions 或 fields 的集合,由使用者案順序的處理.這型式最好用短 forms 以及沒有選擇的fields.舉例來說,送個 email訊息,需要 To: address, 目標和訊息,而且按順序指明.

    ordered="false"  表示card由非線性的 field elements組成.適用於有選擇性的field和不具順序的components 或 simple record 由使用者所輸入的更新資料.

    因為deices有限的容量,通常必須insert screen flips 或其他使用者在fields之間傳遞.當實行時, user agent必須在field中選擇正確的boundaries. User agents使用下面的方式找尋 screen flip 的位置:

        fieldset 在field之間定義 logical boundary.

    Fields 可以個別執行. the line of markup (flow) immediately preceding the field is treated as a field prompt and displayed with the input element. The table must be treated differently than input and select. The user agent must insert a line break before each table element,except when it is the first non-whitespace markup in a card. The user agent must insert a line break after each table element, excpt when it is the final element in a card.

    onenterforward=href onenterforward eent 發生在當使用者用go task瀏覽進入一個card時,詳細資訊請參考“onenterforward eent”文件第39頁.
    onenterbackward=href onenterbackward eent 發生在當使用者用prev task瀏覽進入一個card,詳細資訊請參考“onenterbackward eent”文件第40頁.
    ontimer=href ontimer eent 發生在timer 到期.詳細資訊請參考“ontimer event”文件第38頁.
    xml:lang 請參考"Common attributes" 文件第 23頁.
    id 請參考"Common attributes" 文件第 23頁.
    class 請參考"Common attributes" 文件第 23頁.

    Example [17.]

    下面是 simple card embedded 的簡單例子. card包含由user agent所展示的text,當使用者瀏覽 card, 瀏覽器的內容會重新初始化,包括變數以及stack.

    <wml>
        <template>
            <do type="accept" name="exit" label="EXIT">
                <pre/>
            </do>
        </template>
        <card id="card_1" title="Welcome" newcontext="true">
            <p>
                Hello World!
            </p>
        </card>
    </wml>

    結果展示如下圖

    template element

  • Description

    template element 是在deck中替card宣告一個 template . Eent bindings在 template 中說明(例如 do 或 oneent),應用在deck中所有的 cards . 但card element 優先酈版鏒emplate. 注意下面特別的規則:

        do elements 在template中的定義優先於個別的 cards

        Intrinsic eent bindings 在template中的定義優先於個別的 card.

  • Contained elements

    do *

    oneent *

  • Syntax

    template element 的屬性說明如下表

    Attribute Explanation
    onenterforward=href 說明內部的 eent ,當使用者進入card,user agent 將說明其URL.詳細資訊請參考“onenterforward eent”文件第39頁.
    onenterbackward=href 說明內部的 eent ,當使用者回到原來的card,user agent將說明其URL,就如同使用 pre task. 詳細資訊請參考“onenterbackward event”文件第40頁.
    ontimer=href 說明內部的 eent ,當timer時間到,user agent將指明其URL.詳細資訊請參考“ontimer eent”文件第38頁.
    id 請參考 "Common attributes" 文件第 23頁.
    class 請參考"Common attributes" 文件第23頁.

    Example [18.]

    下面template element 包括一個do element 指示如何去瀏覽deck的上一個card

    <template>
        <do type="pre" label="Previous">
            <pre/>
        </do>
    </template>

    head element

  • Description

    head element 包括所有有關於deck的資訊, 如 meta-data 和 access control elements.

    你寫的head element 至少需包括下面其中一個 elements :

    access

    meta

  • Contained elements

    (access|meta) +

    Example [19.]

    access 和 meta element 的例子:

        access: Example [20.] 第32頁.

        meta: Example [21.] 第34頁.

    access element
    存取原素(access element)

    存取元素(access element):

       存取元素定義整個deck的存取控制資訊,值得注意的是一個deck只會有一個存取元素,否則會造成WML的文法錯誤。假如在一個deck中,你沒有把存取元素加進來(include),那麼存取控制就是不可使用的(disabled)。當存取控制是不可使用的(disabled)時,在任何一個deck上的card都可以存取這個deck

        在系統預設的存取控制設定是讓你可以存取任何一個和你在同一個domainURIs。使用者代理程式(user agent)會使用一個先行比對(prefix match)去比較在deck上的URIs,而且試著去存取你定義在deck上的屬性的值。

        下面這個表會列出可以讓你在不同deck中移動的元素,而目標deck的相關存取設定必須要事先定義好。

     

    Element                   Access requirements

     


    prev                     None .

    go href=href  deck必須位在定義的URIs,那就必須要定義URIdomain

                      和路徑

  • Contained elements

    None.

  • Syntax

    下面的表說明存取元素的屬性:

    Attribute  Explanation

     


    domain=cdata

    path=cdata

    Deck’s domain 和路徑的屬性定義可以存取它的decks。當使用者代理程式從一個deck移到另一個deck上時,它就會執行存取控制的檢查,去決定目的的deck是否準許目前的deck存取。

    假如deck有一個domain 跟路徑的屬性,那麼參考的URL必須符合屬性值。

    Matching是依照下面的方法:

    Domain的存取是suffix-matchedpath的存取是prefix-matchedDomain suffix matching是用sub-domain的所有元素而且必須要每一個元素都正確。舉例來說,

     www.acmecorp.com matches acmecorp.com, 但並沒有match corp.com. Path prefix matching是用path的所有元素而且必須要每一個元素都正確。舉例來說,

     

    /X/Y matches path="/X" 屬性, 但並沒有 match

    path="/XZ" 屬性。.

    domain attribute 預設值是現在deck domain.  path attribute 的預設值是"/".

    為了簡化應用程式的發展,所以可能不須要知道目前

    deck的絕對路徑。

    path attribute 可以接受相對的 URLs.

    user agent會把相對路徑轉換成絕對路徑然後對path attribute執行prefix matching

    Domain and path 尊詢 URL 的規則

    id  

    See "Common attributes" on page 23.

    class   

    See "Common attributes" on page 23.

     

    Example [20.]

    舉例來說,假設給下面的存取控計屬性domain="acmecorp.com"

    path="/pub"

    則下面參考的URLs,則可以准許存取上面的deck

    acmecorp.com/pub/stocks.cgi

    www.acmecorp.com/pub/demos/packages.cgi

    則下面參考的URLs,則不准許存取上面的deck

    www.test.net/pub

    www.acmecorp.com/internal/foo.wml

    下面的head 屬性包含一個存取控制元素,並指出只有在mycompany.com目錄下的WMLdecK,才可以存取這個deck

    <head>

    <!-- NOTE: The DOMAIN and PATH must be customized for

    your network location of the WML decks -->

    <access domain="mycompany.com" path="/WML" >

    </head>

     

    meta element

  • Description

    meta element包含有一般和WML deck有關的meta 資訊。

    Meta information property name value.來定義。值得注意的是一個meta元素只能有一個屬性來定義一個property name,否則會造成WML的文法錯誤。

     

     

  • Contained elements

    None.

     

  • Syntax

    下面的表格是說明有關Meta元素的屬性:

    Attribute Explanation

    content=cdata   這個屬性是定義 property value. 這是需要的。

    name=cdata   這個屬性是定義  property name.

       user agent忽略已命名的 meta-data. 而網路的伺服器

         不會散發WML中包含有以這個屬性為名的meta-data

    http-equiv=cdata    這個屬性可能被用來代替名字。它只出這個

          property 應該被翻譯成HTTP header. 假使它的內容

        在到達user agent之前已經標記過了

        則以這個屬性為名的meta-data會被轉換給WSP

       HTTP回應的header

    forua=boolean   This attribute specifies that the author intended

       the property to reach the user agent. If the value is

       false, an interrmediate agement must remove the

       meta element before the document is sent to the

       client. If the value is true, the meta data of the

       element must be delivered to the user-agent. The

       method of delivery may vary. For example, http-equiv

       meta data may be delivered using HTTP or

                             WSP headers.

    scheme=cdata   This attribute specifies a form or structure that

      may be used to interpret the property value. Note

       that scheme values vary depending on the type of

      meta-data.

    id  See "Common attributes" on page 23.

    class   See "Common attributes" on page 23.

    Example [21.]

     

    下面的head元素包括一個存取控制元素,及meta元素,

    描述上面的部分

    <head>

    <!-- NOTE: The domain and path must be customized for

    your network location of the WML decks -->

    <access domain="mycompany.com" path="/WML" >

    <meta content="charset" user agent="character-set=UTF-8"/>

    </head>