VXML dtmf grammar with unknown number of digits and specific terminating character - grammar

I am new to VXML and trying to construct an inline dtmf grammar that will allow any sequence of digits between 1 and 5 terminated with digit 6 be returned.
So all three of the following sequences should result in a fill:
1123236, 236, 55555555552342346
I've tried implementing the grammar like so:
<grammar mode="dtmf">
<rule>
<item>
<item repeat"0-">1|2|3|4|5<item>6</item>
</item>
</rule>
</grammar>
and also like so:
<grammar mode="dtmf">
<rule>
<item repeat"0-">1|2|3|4|5</item>
<item>6</item>
</rule>
</grammar>
I am out of ideas and would greatly appreciate your help

Here is a grammar you may use:
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="onetofive">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</rule>
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<ruleref uri="#onetofive"/>
</item>
</one-of>
</rule>
</grammar>
To stop recognition with digit "6" set a property in your VXML form:
<property name="termchar" value="6" />
In the form while processing "filled" event you will know that the sequence was terminated with "6" so you may append it to data if it needs be.
An equivalent single rule grammar as requested in comments
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</item>
</one-of>
</rule>
</grammar>
Both variants are tested with Holly Connects Voice Platform
Here is an app you may use for quick testing.
<?xml version="1.0" encoding="utf-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
<property name="inputmodes" value="dtmf"/>
<form id="welcome">
<field name="option">
<property name="termchar" value="6"/>
<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
<rule id="oneToFiveSequence" scope="public" >
<one-of>
<item repeat="0-">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</one-of>
</item>
</one-of>
</rule>
</grammar>
<prompt>Enter digits</prompt>
<filled>
<log> You entered <value expr="option"/></log>
</filled>
</field>
</form>
</vxml>

Related

XPATH: Filtering (rather than selecting nodes), preserving hierarachy

Given the following XML (with many hierarchy levels), I need to return the nodes after filtering all nodes with Hide"True" attribute and a certain name. Note that hide could be at any hierarchy level:
<items>
<item id="1" >
<item id="2" />
<item id="3" />
<item id="4" hide="true"/>
</item>
<item id="5" hide="true">
<item id="6" >
<item id="7">
<item id="8" hide="true"/>
<item id="9"/>
</item>
</item>
</items>
I would need to get this back:
<items>
<item id="1"">
<item id="2" />
<item id="3" />
</item>
<item id="6" >
<item id="7">
<item id="9"/>
</item>
</item>
</items>
The 'filtered' XML is then assigned to a treeview, so I need to preserve the hierarchical nature of the nodes. I have tried: "items//item[#hide='false' or not(#hide)]", but this returns a flattened (as well as duplicative) data, repeating nodes at the lower level pushed up to the top level as follows. Is there a way to use Xpath to do what I want? I understand that I can Xslt the data first, then display it, but it just seems that there is got to be an easier way. I am using c#/.net4.0 MSXML
<items>
<item id="1"">
<item id="2" />
<item id="3" />
</item>
<item id="6" >
<item id="7">
<item id="9"/>
</item>
</item>
<item id="2" />
<item id="3" />
<item id="7">
<item id="9"/>
</item>
<item id="9"/>
</items>

How to return a list of objects from soap webservice with rails

I'm using Savon to access a soap webservice, but I can only ever return a single result, when what I want is an array of results.
Here is my call:
response = client.call(:get_events, message: { username: "xxxx", password: "xxxxxxxx", company_code: "12TCE" })
I want 'response' to return all records with the company_code of "12TCE" and for me to be able to output them all doing something like:
response.to_hash[:get_events_response].each do |a|
a[:return][:item][:name]
end
How can I return all records and output as desired?
UPDATE 1:
This is the link to the wsdl: http://www.brrmedia.co.uk/webservices/event/index.php?wsdl
This is the response I get:
HTTPI POST request to www.brrmedia.co.uk (httpclient)
SOAP response (status 200)
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.brrmedia.co.uk/webservices/event" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getEventsResponse xmlns:ns1="http://www.brrmedia.co.uk/webservices/event">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objEvent[1]">
<item xsi:type="tns:objEvent">
<id xsi:type="xsd:int">119466</id>
<name xsi:type="xsd:string">blur Group - 2000 projects milestone</name>
<summary xsi:type="xsd:string"/>
<location xsi:type="xsd:string"/>
<date xsi:type="xsd:string">2013-12-17 11:30</date>
<link xsi:type="xsd:string">http://www.brrmedia.co.uk/event/119466/partner/brrsoap</link>
<company xsi:type="tns:objCompany">
<name xsi:type="xsd:string">blur Group</name>
<codes xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objCompanyCode[1]">
<item xsi:type="tns:objCompanyCode">
<code xsi:type="xsd:string">BLUR</code>
<collection xsi:type="xsd:string">London Stock Exchange (AIM)</collection>
</item>
</codes>
<website xsi:type="xsd:string">http://www.blurgroup.com/</website>
<category xsi:type="xsd:string">Technology</category>
</company>
<presenter xsi:type="tns:objPresenter">
<name xsi:type="xsd:string"> Philip Letts</name>
<image xsi:type="xsd:string">http://www.brrmedia.co.uk/getimage/id/31215</image>
</presenter>
<media xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objMediaItem[3]">
<item xsi:type="tns:objMediaItem">
<src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/blur20131217.pdf</src>
<duration xsi:type="xsd:string">00:00:00</duration>
<filesize xsi:type="xsd:string">380</filesize>
<media_type xsi:type="xsd:string">pdf</media_type>
</item>
<item xsi:type="tns:objMediaItem">
<src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/BLUR20131217</src>
<duration xsi:nil="true" xsi:type="xsd:string"/>
<filesize xsi:nil="true" xsi:type="xsd:string"/>
<media_type xsi:type="xsd:string">presimages</media_type>
</item>
<item xsi:type="tns:objMediaItem">
<src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/BLUR20131217editv1.mp3</src>
<duration xsi:type="xsd:string">00:07:54</duration>
<filesize xsi:type="xsd:string">5557</filesize>
<media_type xsi:type="xsd:string">audio</media_type>
</item>
</media>
<type xsi:type="xsd:string">audio</type>
<height xsi:type="xsd:int">900</height>
<width xsi:type="xsd:int">680</width>
</item>
</return>
</ns1:getEventsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

How to disable VXML to "catch event" (nomatch) for specific DTML

The VXML menu has the options 1, 2, 3, 9, and '#'. The customers will assume that if they press 0, it would take them to the transfer to service center.
But 0 in this menu won't take them to service center, the requirement is to ignore 0 DTMF and keep playing the prompt without warning them.
This menu's bargien property has to be true. I am required to make the prompt menu where users are able to press any mentioning DTMF above to interrupt it and goto next, but I have to set the program to ignore DTMF 0.
Please try this code.
Key point is "bargeintype" property and grammar rule.
VXML's form
<form id="sample">
<field name="menu_result">
<property name="bargein" value="true" />
<property name="bargeintype" value="hotword" /><!-- Important! -->
<property name="inputmodes" value="dtmf" />
<property name="timeout" value="5s" />
<property name="interdigittimeout" value="0s" />
<property name="termchar" value="D" />
<prompt>
Please push either of 1, 2, 3, 9 or pound sign button.
Other button is ignored.
</prompt>
<grammar src="special_menu.grxml" />
<filled>
<assign name="result" expr="menu_result.slice(-1)"/><!-- Get last 1 digit -->
<goto next="#next_form"/>
</filled>
<noinput><prompt>No input error.</prompt></noinput>
<nomatch><prompt>No match error.</prompt></nomatch>
</field>
</form>
special_menu.grxml
<?xml version="1.0" encoding="UTF-8"?>
<grammar
version="1.0"
mode="dtmf"
root="main"
xmlns="http://www.w3.org/2001/06/grammar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<rule id="main">
<item repeat="0-">
<one-of><item>4</item><item>5</item><item>6</item><item>7</item><item>8</item><item>*</item></one-of>
</item>
<one-of>
<item>1</item><item>2</item><item>3</item><item>9</item><item>#</item>
</one-of>
</rule>
</grammar>

VXML Digits Grammar Excluding All Zeros

I'm looking for a way to build a VXML grammar that requires a certain number of digits to be entered, but also requires that the input is not all zeros.
The use case for this is bank numbers. For example, I would like to force an input (voice or DTMF, doesn't matter) of 9 digits for routing numbers but require that not all digits are zero. (Disregard the modulus check for the moment, I'm not concerned about that here).
Given the grammar constructs of <one-of> and <item>, I can see this being possible by enumerating all possibilities such as the rule at this end of this question. However, this seems ridiculous. Is there a better way that I haven't come across yet? Any help would be appreciated.
<rule>
<one-of>
<item>
<item repeat="1">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
<item repeat="8">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
</item>
<item>
<item repeat="1">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
<item repeat="1">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
<item repeat="7">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
</item>
<item>
<item repeat="2">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
<item repeat="1">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
<item repeat="6">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</item>
</item>
etc....
</one-of>
</rule>
How about something like this
<rule id="zero">
<oneof>
<item>0</item>
</oneof>
</rule>
<rule id="nonzero">
<oneof>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
</oneof>
</rule>
<rule id="alldigits">
<oneof>
<item>
<ruleref uri="#zero"/>
</item>
<item>
<ruleref uri="#nonzero"/>
</item>
</oneof>
</rule>
<rule id="account-num">
<oneof>
<item>
<item repeat="7">
<ruleref uri="#alldigits"/>
</item>
<item repeat="1">
<ruleref uri="#nonzero"/>
</item>
</item>
</oneof>
</rule>
The rule account-num specifies that at least one number must not be zero.

How to get SOAP response data?

This is the XML response back from webservice.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:OrientalServices1">
<SOAP-ENV:Body>
<ns1:Get_CategoryResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:responseGetCategoryByID[11]">
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">1</id>
<name xsi:type="xsd:string">國內</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">2</id>
<name xsi:type="xsd:string">財經</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">3</id>
<name xsi:type="xsd:string">社會</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">4</id>
<name xsi:type="xsd:string">國際</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">10</id>
<name xsi:type="xsd:string">龍門陣</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">11</id>
<name xsi:type="xsd:string">言論</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">6</id>
<name xsi:type="xsd:string">名家</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">8</id>
<name xsi:type="xsd:string">娛樂</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">5</id>
<name xsi:type="xsd:string">體育</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">7</id>
<name xsi:type="xsd:string">專題</name>
</item>
<item xsi:type="tns:responseGetCategoryByID">
<id xsi:type="xsd:int">9</id>
<name xsi:type="xsd:string">特輯</name>
</item>
</return>
</ns1:Get_CategoryResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In this XML, I got 11 items in an array. How can I deserialize it and get the item one by one?
You could use an XML parser.
There is support for a couple of methods in Cocoa - but since you've asked such a general question, all I can do is provide a general answer.
There is an Introduction to Event Driven XML Programming on the Apple Developer site