|
In
this monthly column, an industry expert will answer
common questions about VoiceXML and related technologies.
Readers are encouraged to submit questions about VoiceXML,
including development, voice-user interface design,
and speech technology in general, or how VoiceXML is
being used commercially in the marketplace. If you have
a question about VoiceXML, e-mail it to speak.and.listen@voicexmlreview.org
and be sure to read future issues of VoiceXML Review
for the answer.
Continued
from page 2...
Creating
the VoiceXML
So far, we've focused on using XSLT to generate our
grammars and our JavaScript.
Now that we have these pieces, it should be straightforward
to author some VoiceXML that implements our call flow.
I've implemented the Voice Dialer in four VoiceXML documents:
Regardless of whether you add, update or delete an employee
or a department in the DBMS,
the VoiceXML doesn't have to change. You need only export
the data to XML and regenerate the grammars
and .js files by transforming the XML through the appropriate
.xslt documents.
Automating the creation of the XML data source documents.
The relevant data in the employee and department table
may not change often, but
manually exporting the data isn't a good use of anyone's
time.
To
automate this task you have a couple of powerful tools
at your disposal - the Windows Script Host (WSH) and
the Windows Task Scheduler.
We
introduced WSH earlier in the column. The Windows Task
Scheduler is a service that runs on the Windows Platform
and is designed to run any batch file, program, or document
at a specified time or interval.
For more information on Windows Task Scheduler, see:
"http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/taskschd/the_task_scheduler_api.asp
By combining the use of WSH and Windows Task Scheduler,
you can easily automate the export of data from MS Access.
Here's how.
First we'll author a simple script in JScript that programs
Microsoft Access to export the data from any table of
any Access database (.mdb) to an XML document (.xml).
http://www.voicexmlreview.org/Mar2003/columns/speak_files/mdb2xml.js
The script is simple. First it creates an instance of
Microsoft Access using the programmatic identifier (ProgID)
"Access.Application". A ProgID is a simple abstraction
that allows COM, Microsoft's component technology, to
invoke an application or shared library (.dll). The script
then instructs access to perform four simple tasks:
- Open a .mdb
- Export a table as XML
- Close the .mdb
- Quit
It's that simple. To automate Microsoft Access to perform
other tasks, see the Microsoft Access Object Model documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac10/html/acsumAccessObjHierarchy.asp
To use the script, create a text file using your favorite
programming editor (e.g. Notepad), and save it to a file
with a .js extension, for example, "mdb2xml.js".
Identify the following:
- The location of your .mdb (e.g. c:\data\emp.mdb)
- The name of the table (e.g. employee)
- The location where you'd like to save the exported
XML document. (e.g. c:\exports\employee.xml)
Type the following at the command line, adjusting the
paths as appropriate:
cscript c:\bin\mdb2xml.js
c:\data\emp.mdb employee c:\exports\employee.xml
If the script is successful, your table should be exported
to the XML document employee.xml in c:\exports.
Now that you've tested the script, you can program the
Windows Task Scheduler to execute the script for you.
Assuming your running Windows XP, to schedule a task using
the Windows Task Scheduler, do the following:
- From the Start Menu, choose "Control Panel".
- Double-click "Scheduled Tasks".
- Double-click "Add Scheduled Task". A wizard
guides you through the process of creating a new task.
- Click "Next".
- The wizard will present you with a list of programs.
Since WSH (cscript.exe) will not be listed, click
Browse...
- By default, cscript.exe is located in the system32
subdirectory of your Windows directory (e.g. c:\windows\system32\cscript.exe).
Select it.
- Choose how frequently you wish to execute the task
(daily, weekly, monthly, etc). You'll be given an
opportunity to choose a more frequent interval later.
Click "Next".
- Specify the date and time you wish to first execute
the task, and click "Next".
- Specify the credentials of the account you wish
to use to perform the task, and click "Next".
- To specify parameters and to increase the frequency
that the task should run, check "Open advanced
properties...", and click "Finish".
- In the "Run" text box, specify the additional
parameters using full paths to the location of the
export .js script, the .mdb, the table, and the .xml
to export.
- To run the task more frequently than once per day,
click the "Schedule" tab, and click "Advanced...".
Check "Repeat task", and specify the frequency
(e.g. Every 1 hour). Click "Ok" to dismiss
the "Advanced Schedule Options" dialog.
- Click "Ok" to dismiss the Task dialog.
Now that your familiar with the Windows Task Scheduler,
you should be able to create tasks to export the department
data and to perform all four transformations.
back
to the top
Copyright
© 2001-2003 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE
Industry Standards and Technology Organization (IEEE-ISTO).
|