Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.35 one-of

Element type

one-of

Attributes

xml:lang

Parents

item | rule

Children

item

Description

Indicates a set of possible choices for a phrase in a rule expansion.

DTD

<!ELEMENT one-of (item)* >
<!ATTLIST one-of
  xml:lang NMTOKEN #IMPLIED >

Language model

03fig35.gif

Attributes

  • xml:lang : NMTOKEN

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

Children

  • item

    Each choice within a one-of element is represented by an item element containing a rule expansion.

Examples

In Example 3-41, the rule uses the one-of elements to accept either "like" or "hate" and either "dogs" or "cats." Hence it will match the following phrases:

  • I like dogs.

  • I hate dogs.

  • I like cats.

  • I hate cats.

Example 3-41 Using one-of to permit multiple utterances to be accepted

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
  <form id="test">
    <initial name="dogscats">
      <prompt>How do you feel about dogs and cats?</prompt>
    </initial>
    <grammar xml:lang="en-US" version="1.0" root="colors">
      <rule id="colors" scope="public">
        <one-of>
          <item tag="emotion='like';">like</item>
          <item tag="emotion='hate';">hate</item>
        </one-of>
        <one-of>
          <item tag="animal='dogs';">dogs</item>
          <item tag="animal='cats';">cats</item>
        </one-of>
      </rule>
    </grammar>

    <field name="emotion"/>
    <field name="animal"/>

    <filled>
      <prompt>
        You said you
        <value expr="emotion"/> <value expr="animal"/>.
      </prompt>
    </filled>
  </form>
</vxml>
  • + Share This
  • 🔖 Save To Your Account