Engineering Full Stack Apps with Java and JavaScript
1. What is an application root document? How do you specify the application root documrnt for a vxml application?
A VoiceXML application consists of one or more documents. Any multi document application has a single application root document. Each document in an application identifies the application root document with the application attribute of the <vxml> tag:
<vxml
version="2.0"
xmlns=http://www.w3.org/2001/vxml
application="myAppRoot.vxml" >
Whenever the interpreter executes a document, it loads that document. If the document specifies an application root document, that document is also loaded. You can use an application root document for global items or interactions that you want to be active throughout the application. For example, suppose the application root document myAppRoot.vxml declares a variable. This variable has application scope. That is, any document in the application can use the variable.
2. What are built in grammars? Give examples.
Built in grammars are grammars that are already built into VoiceXML interpreters. The following basic grammars are built into all standard VoiceXML interpreters: boolean, currency, date, digits, number, phone, time.
You can reference a built-in grammar in either of two ways:
First, you can use a standard built-in grammar as the type attribute of a <field> element. The example is:
<field name="num" type="number">
This means that the speech-recognition engine tries to interpret what the user says as a number.
Second, you can use any built-in grammar (standard or vendor VoiceXML extension) in a <grammar> element by specifying the src attribute with a URI of the form:
builtin:grammar/typeName
For example:
<grammar src="builtin:grammar/boolean"/>
3. List down the different formats in which we can specify application defined grammar?
4. Differentiate between inline grammar and external grammar?
An inline grammar is defined within the <grammar> element itself.
An external grammar is defined in a file separate from the VoiceXML document file and is referenced by the src attribute of the <grammar> element. For example, the following field uses a grammar rule named Colors in an external XML grammar defined in the file partGrammar.grxml.
<field name="part">
<grammar
src="http://www.mySite/partGrammar.grxml#Colors"/>
5. What are active grammars?
The speech-recognition engine uses active grammars to interpret user input. A field grammar is active whenever the interpreter is executing that field. A menu-choice grammar is active whenever the interpreter is executing the containing menu. A form grammar is active whenever the interpreter is executing the containing form.
A form grammar or the collection of choice grammars in a menu can optionally be made active at higher scopes. A grammar with document scope is active whenever the interpreter is executing any dialog in the document. A grammar with application scope is active whenever the interpreter is executing any document in the application.
If the interpreter is executing one dialog and the user’s input matches an active grammar for a different dialog, control transfers to the latter dialog. If the grammar is in application scope, control might transfer to a dialog in a different document.
Within a field, you can temporarily turn off grammars from higher scopes by setting the field’s modal attribute to true.
6. What do you mean by an active grammar set?
The set of grammars active during a VoiceXML interpreter context's input collection operation.
7. Within a field how can you temporarily turn off grammars from higher scopes?
Within a field, you can temporarily turn off grammars from higher scopes by setting the field’s modal attribute to true. modal attribute can have one of the following values:
8. How can you activate or deactivate universal grammar?
All universal grammars are deactivated by default. The application can activate some or all universal grammars by setting the universals property. This property specifies which of the universal grammars should be active; all other universal grammars are deactivated.
Examples:
Set the universals property to all to activate all universal grammars (both predefined and application-defined):
<!-- Activate help, exit, cancel, and goback -->
<property name="universals" value="all" />
Set the universals property to a space-separated list of grammars to activate those universal and deactivate others:
<!-- Activate only help, goback, and joke -->
<property name="universals" value="help goback joke" />
Set the universals property to none to deactivate all previously activated universal grammars in the current scope.
<!-- Deactivate all universal grammars -->
<property name="universals" value="none" />
9. If a <var> element specifies a variable that is already in scope, what will happen?
If a <var> element specifies a variable that is already in scope, it does not declare a new variable with the same name, but simply assigns a value to the existing variable. If the <var> element has an expr attribute, the variable is assigned the specified value; otherwise, the variable is assigned the value undefined.
10. Describe the scopes of a vxml variable?
A variable has the scope of the element that contains its declaration: