Q:
Whatabout links? How do they really come into play in
VoiceXML programming?
A: Once
you understand how forms, fields, and grammars interact,
the notion of "links" in VoiceXML is a very
straightforward thing to add. As you might imagine,
a very common thing developers want to do in VoiceXML
applications is add some measure of "universal
commands" that are always available, and always
behave in the same way.
It
would certainly be possible- though by no means practical-
to write the grammar for these commands, save it to
a separate file, reference it in every form in every
document in your application, and then write the proper
logic in every field of every form of every document
to react in the right way if the caller actually says
one of these things. With this in mind, VoiceXML has
support for the notion of "links".
VoiceXML
links (defined by the <link> element) are very
simple- they define a grammar and either an event to
throw or a URL to transition to; if the caller ever
says something to match the link's grammar, control
is whisked away from the current field and the specified
transition or event is executed. Links can be specified
at any scope (from an application root document down
through within an individual field), and their grammars
are only active within the scope where the link is specified.
Links
that fire events are a particularly good way to handle
universal commands, because the flexible and hierarchical
event model (see later in this chapter for detail, but
you're probably already getting the picture) make it
easy to specify global event handlers at the application
level, and override them locally when and if needed.
In
our simple example
of using links within a single document application;
the general concept extends easily to more complex applications.
That's really all there is to it. Using links (and associated
event handlers) throughout applications is a flexible
technique commonly used by professional VoiceXML developers.