Voicexml如何将输入存储到全局变量中

时间:2011-01-05 14:53:22

标签: global-variables vxml voicexml

我正在创建一个voicexml appliacation。

我想将用户输入存储到全局变量中。

我想知道,输入应该存储在fieldvar中。不应该吗?在我尝试使用它之后,我试图将它存储在一个全局变量中:

<assign name="myvar" expr="'myinput'"/>

但不知怎的,它没有用。我使用值expr="var"作为expr。

<?xml version="1.0" encoding="UTF-8"?> 
<vxml xmlns="http://www.w3.org/2001/vxml" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.w3.org/2001/vxml 
   http://www.w3.org/TR/voicexml20/vxml.xsd"
   version="2.0">


<var name="myProdukt" />


<form id="test">

<field name="var">
<prompt bargein="true" bargeintype="hotword" >Sagen Sie ein Produkt</prompt>

<grammar root="main" version="1.0" xml:lang="de-DE">

  <rule id="main" scope="public">
    <one-of>
      <item> p1 </item>
      <item> p2 </item>
      <item> p3 </item>
      <item> p4   </item>
    </one-of>
  </rule>

</grammar>



<filled>
<assign name="myProdukt" expr="<value expr="var"/>"/>
</filled>

</field>


</form>

<<!--[...] Here i want to use the input.-->

</vxml>

提前致谢

---------------编辑:

现在我使用了这个:

<filled>
test
<assign name="myProdukt" expr="var" />
</filled>

我只是改变了。应用程序说&#34; test&#34;但后来出现了错误。


不允许使用&#34; var&#34;相反,我使用了另一个名字:-)

1 个答案:

答案 0 :(得分:3)

您是否尝试过简单地将字段var分配给变量myProdukt

<filled>
    <assign name="myProdukt" expr="var"/>
</filled>

除了根据Voice XML规范的Section 5.1, Variables and Expressions之外,哪个会没问题

  

VoiceXML变量,包括表单   项变量,不得包含   ECMAScript保留字。

因此,您需要将字段var重命名为 ECMAscript 中不是保留字的内容,例如productSelection

<field name="productSelection"> 
    <!-- .. prompt, grammar as before .. -->
    <filled>
        <assign name="myProdukt" expr="productSelection"/>
    </filled>
</field>
相关问题