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

发布于 2024-10-10 15:16:27 字数 1468 浏览 0 评论 0原文

我正在创建一个 voicexml 应用程序。

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

我想知道,输入应该存储在 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>

我只改变了它。应用程序显示“测试”,但随后出现错误。


不允许使用“var”,而是我使用了其他名称:-)

I'm creating a voicexml appliacation.

I want to store an user input into a global variable.

I wondered, the input should be stored in the fieldvar. shouldn't it? After I tried it with this, i tried to store it in an global variable:

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

but somehow it didn't work. I used value expr="var" as 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>

thanks in advance

---------------EDIT:

now i used this:

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

I only changed that. The Applications says "test" but then there is an error.


It isn'T allowed to use "var" instead I used an other name :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆依然 2024-10-17 15:16:27

您是否尝试像这样将字段 var 简单分配给变量 myProdukt

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

除了根据 第 5.1 节,这没什么问题, Voice XML 规范的变量和表达式

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

因此,您需要将字段 var 重命名为 ECMAscript 中非保留字的名称,例如 productSelection

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

Did you try a simple assignment of field var to the variable myProdukt like so ?

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

Which would be fine except that according to Section 5.1, Variables and Expressions of the Voice XML specification:

VoiceXML variables, including form
item variables, must not contain
ECMAScript reserved words.

So, you'll need to rename the field var to something that is not a reserved word in ECMAscript, say productSelection:

<field name="productSelection"> 
    <!-- .. prompt, grammar as before .. -->
    <filled>
        <assign name="myProdukt" expr="productSelection"/>
    </filled>
</field>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文