我已经编写了这个基本的voiceXML 应用程序,但是我在一个基本的流控制问题上被困了好几个小时。goto
标签 ( <goto nextitem="countryState" />
) 不起作用。我一直呆在变量名偏移的循环中。任何帮助都会很棒。
提前致谢。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml" xmlns:bevocal="http://www.bevocal.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<form>
<field name="offset">
<grammar src="map.xml#cities" type="application/grammar-xml"/>
<prompt>
What city would you like the time for?
</prompt>
<catch event="noinput nomatch" count="1">
Please say the city that your are living at. For example, chicago, los angeles or new york city
<reprompt/>
</catch>
<catch event="noinput nomatch" count="2">
Apparently the provided city is not in our system. Lets try something different.
<goto nextitem="countryState" />
<disconnect/>
</catch>
<filled>
<if cond="offset == '-8'">
<prompt>You are living in UTC offset of <value expr="offset"/></prompt>
<elseif cond="offset == '-7'"/>
<prompt>You are living in UTC offset of <value expr="offset"/></prompt>
<elseif cond="offset == '-6'"/>
<prompt>You are living in UTC offset of <value expr="offset"/></prompt>
<elseif cond="offset == '-5'"/>
<prompt>You are living in UTC offset of <value expr="offset"/></prompt>
<elseif cond="offset == '-3.5'"/>
<prompt>You are living in UTC offset of <value expr="offset"/></prompt>
</if>
</filled>
</field>
<field name="formatTime">
<prompt>
Twelve hour or twenty four hour clock?
</prompt>
<grammar type="application/x-nuance-gsl">
[[twelve (twenty four)] ?hour]
</grammar>
</field>
<script>
<![CDATA[
var d = new Date();
function calcTime() {
// create Date object for current location
var d = new Date();
// convert to msec
// subtract local time zone offset
// get UTC time in msec
var utc = d.getTime() - (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
var nd = new Date(utc + (3600000 * (countryState ? countryState : offset)));
// return time
if (formatTime == "twelve hour") {
return "" + ((nd.getHours() > 12) ? (nd.getHours() - 12) : (nd.getHours()) ) + " and " + nd.getMinutes() + " minutes.";
} else {
return "" + nd.getHours() + " and " + nd.getMinutes() + " minutes";
}
}
]]>
</script>
<block>
<prompt>Current time is <value expr="calcTime()" /> </prompt>
<prompt>Thank you. Bye.</prompt>
<disconnect/>
</block>
<field name="countryState">
<prompt>
If you are in U.S., which U.S. state your are currently living in? If you are outside of U.S., which country you are currently living in?
</prompt>
<grammar src="map.xml#countryState" type="application/grammar-xml"/>
<filled>
<if cond="countryState == '+8'">
<prompt>You are living in UTC offset of <value expr="countryState"/></prompt>
<elseif cond="countryState == '+1'"/>
<prompt>You are living in UTC offset of <value expr="countryState"/></prompt>
<elseif cond="countryState == '+0'"/>
<prompt>You are living in UTC offset of <value expr="countryState"/></prompt>
<elseif cond="countryState == '-6'"/>
<prompt>You are living in UTC offset of <value expr="countryState"/></prompt>
</if>
<goto nextitem="formatTime" />
</filled>
</field>
</form>
</vxml>