3.24. item

Element typeitem
Attributesrepeat | weight | xml:lang
Parentsitem | one-of | rule
Childrencount | item | one-of | ruleref | tag | token
DescriptionWraps a rule expansion and associates with it a weight to indicate the probability of this element's rule expansion being matched and a tag used to fill one or more fields if this item is matched in a grammar. The item element can also delimit different rule expansions in a one-of element. This is one of the VoiceXML components likely to change: The W3C is currently working on the Semantic Interpretation for Speech Recognition Specification which will subsume this element.

DTD

<!ELEMENT item (%rule-expansion; | tag)* >
<!ATTLIST item
  weight   NMTOKEN #IMPLIED
  repeat   CDATA   #IMPLIED
  xml:lang NMTOKEN #IMPLIED >

Language model



Attributes

repeat : CDATA

Specifies that the contents of this item may be heard repeatedly. The permissible patterns of repeat may be expressed as in Table 3-2.

tag : CDATA (deprecated)

In the early version of the VoiceXML 2.0 Specification the tag attribute represented an expression to be interpreted if this item element's rule-expansion is matched. This is typically an ECMAScript expression.

Table 3-2. The permissible patterns of repeat
PatternDescription
0-1This item is optional.
0-This item may occur zero or more times.
1-This item may occur one or more times.
n-This item may occur n or more times (where n is an integer).
n-mThis item may occur between n and m times inclusive (where n and m are both integers and m > n). Older implementations may still use the count element to specify repeats. An example of this is shown below.

weight : NMTOKEN

Specifies the expected probability of this item's rule-expansion being spoken. This is used to provide a hint to the speech recognition engine.

xml:lang : NMTOKEN

Specifies the spoken language used with this element. For example, en-US for US English.

Children

A rule-expansion

To be enumerated within a one-of element.

Examples

Example 3-27. A weighted grammar definition
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form id="test">
    <field name="favcolor">
      <prompt>What is your favorite color?</prompt>
      <grammar xml:lang="en-US" version="1.0" root="colors">
        <rule id="colors" scope="public">
          <one-of>
            <item><tag>red</tag>red</item>
            <item weight="0.5"><tag>red</tag>burgundy</item>
            <item><tag>blue</tag>blue</item>
            <item weight="0.5"><tag>blue</tag>indigo</item>
            <item><tag>green</tag>green</item>
          </one-of>
        </rule>
      </grammar>
      <filled>
        <prompt>
          You said <value expr="favcolor"/>.
        </prompt>
      </filled>
    </field>
  </form>
</vxml>

An example of the deprecated form of item where the tag attribute is used is shown for the grammar element in 3.20, “grammar,”.

Example 3-28. The deprecated count element
<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form id="test">
    <field name="howmuch">
      <prompt>
        Do you think this dialog is very good <break/> 
        or very very good?
      </prompt>
      <grammar xml:lang="en-US" version="1.0" root="ROOT">
        <rule id="ROOT" scope="public">
          <count number="optional">I think its</count>
          <count number="0+">very</count>
          good
        </rule>
      </grammar>
    </field>

    <filled>
      <prompt>
        I'm glad you liked it!
      </prompt>
    </filled>
  </form>
</vxml>

Though the count element is now deprecated, on many interpreters, the count element (Example 3-28) is still the only way to indicate a repeat or an optional rule expansion.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.219.78