0

I have to write GRXML code that allows me to enter a username with any number of digits, ending with #. I have written this, but it doesn't work:

<grammar version='1.0' 
mode='dtmf' 
root='RefSaisieClient'>

    <rule id="RefSaisieClient">
        <item repeat="1-">
            <one-of>
                <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>
            </one-of>
        </item>
        <item>#</item>
    </rule> 

</grammar>
zanussi
  • 1,286
  • 2
  • 22
  • 29
  • Please explain in how far your code doesn't work. – honk Apr 06 '15 at 14:25
  • when i write a number and i hit # to finish, it gives me the error message. – Rachid Malih Apr 06 '15 at 15:28
  • _What_ error message? Please [edit](http://stackoverflow.com/posts/29472912/edit) your question and provide as much information as you can. Please help readers to help you. Also, please think about a better title. The current title is unlikely to attract many readers. If you need guidance, please take the [tour](http://stackoverflow.com/tour) and read [How to Ask](http://stackoverflow.com/questions/how-to-ask). – honk Apr 06 '15 at 16:25
  • hi thanks a lot,indeeed, I want to allow users to enter a variable length number using the keypad. I want them to terminate their input with the '#' key, the problem is that the user hit # ,the generic error message is given 'I did not understand what you said please try again'. – Rachid Malih Apr 06 '15 at 17:13
  • I edited your code to include the tags which were missing, and that might be contributing to your problems. Based on context, though, it looks like it was a simple copy-and-paste error perhaps, so I'm not sure if that will resolve your problem. – zanussi Apr 15 '15 at 16:28

1 Answers1

1

# is generally the default termination character and shouldn't be included in your grammar. Try removing it and see if that fixes your issue.

You can also try using two rules, for example:

<rule id="RefSaisieClient">
    <item repeat="1-">
        <ruleref uri="#AllowableDigits"/>
    </item>
</rule>

<rule id="AllowableDigits" scope="public">
    <item>
        <one-of>
            <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> 0 </item>
        </one-of>
    </item>
</rule>
zanussi
  • 1,286
  • 2
  • 22
  • 29