Tutorial 3: Multi-Document Applications and Scope

A multi-document application consists of a “root” document and one or more “supporting” documents. The use of supporting documents allows the application developer to:

  • assign global behaviors
  • cleanly group various dialog tasks into distinct documents
  • break up large applications into smaller loadable pieces, reducing

delays associated with loading large document files

An example of a multi-document application is shown in Fig. 1 below.

multidocapp

 

The above pizza purchasing application consists of a root document (“pizza.vxml”), and two supporting documents (“order_pizza.vxml” and “deliver_pizza.vxml”). In this example, the “pizza.vxml” document plays a welcome prompt and gives the caller a list of options, the “order_pizza.vxml” document contains all of the functionality for ordering a pizza, and the “deliver_pizza.vxml” document acquires the information required for deliveries.

Specifying the root and supporting documents

Supporting documents are created by setting the application attribute equal to the root document name in the <vxml> tag. A root document would not include the application attribute in its tag. Looking at the sample above, you can see that the two supporting documents have the following in their <vxml> tag:

<vxml version="2.0" application="pizza.vxml" >

while the root document has only:

<vxml version="2.0" >

Transitioning between documents

To transition between document, utilize the <goto> element and specify the document name in URI set by the next attribute. This will begin execution at the top of the chosen document. For example, if we wanted to move from the “mainMenu” form of the “pizza.vxml” root document to the top of the “deliver_pizza.vxml” document we would need the following statement somewhere in the originating form:

<goto next="deliver_pizza.vxml" />

To transition to a specific form in a document, specify the document name and the form name separated by the “#” symbol. This will begin execution at the top of the chosen form:

<goto next="deliver_pizza.vxml#address" />

When specifying the document name in a URI for the <goto>, the interpreter will upon executing this element unload the current document and load the new document. This will result in the loss of all variables of document and lesser scope. To avoid this when transitioning between forms in the same document, simply specify the form name only as follows:

<goto next="#address" />

Leave a Reply

Your email address will not be published. Required fields are marked *