We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

xml data

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
oberwetter
Posts: 8
Joined: Fri May 12, 2006 8:01 am

xml data

Post by oberwetter »

Below is a tiny program that gets an xml file using the <data> tag and calls a script passing it the tag name and the data value is supposed to be returned.
This runs as written correctly on Voxeo and Bevocal. The text "This is the text from the xml file." is spoken.
But on Plum I get the error "A serious error of type error.semantic has occurred. Exiting." Why is that?
The first two log entries show the value xxxxxx vvvvvvv. The second two log entries show the value { } { }

I am trying to migrate my code to plum to use it for hosting and this is a show stopper.

Thanks,

Robert

<?xml version="1.0" ?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

<var name="g_voice_recognition_on" expr="'n'"/>

<script>
<![CDATA[
// retrieve the value contained in the node t from the DOM exposed by d
function GetData(d, t, nodata) {
try {
return d.getElementsByTagName(t).item(0).firstChild.data;
}
catch(e) {
// the value could not be retrieved, so return this instead
return nodata;
}
}
]]>
</script>

<form id="playpretext">
<var name="xmlsectionurl" expr="'http://www.host.com/test/textxmlfile.xml'"/>
<var name="xmlpretexttext" expr="'xxxxxx'"/>
<var name="xmlpretextaudio" expr="'vvvvvvv'"/>
<var name="xmlresult" expr="''"/>

<block>
<log label="mylog">After assign xmlpretextaudio equal <value expr="xmlpretextaudio"/></log>
<log label="mylog">After assign xmlpretexttext equal <value expr="xmlpretexttext"/></log>
<data name="texttextxml" srcexpr="xmlsectionurl"/>
<assign name="xmlresult" expr="texttextxml.documentElement"/>

<assign name="xmlpretexttext" expr="GetData(xmlresult, 'pretexttext', 'unknown')"/>
<assign name="xmlpretextaudio" expr="GetData(xmlresult, 'pretextaudio', 'unknown')"/>

<log label="mylog">After assign xmlpretextaudio equal <value expr="xmlpretextaudio"/></log>
<log label="mylog">After assign xmlpretexttext equal <value expr="xmlpretexttext"/></log>

<audio src="http://nonexistent.domain.com/test.wav">
<value expr="xmlpretexttext"/>
</audio>
</block>

</form>
</vxml>

XML FILE - textxmlfile.xml
<?xml version="1.0"?>
<section>
<pretexttext>This is the text from the xml file.</pretexttext>
<pretextaudio>audio1.wav</pretextaudio>
</section>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Code tells IVR sys to convert data at that node to a string

Post by support »

Hello,

When accessing data from an XML DOM structure it is necessary for you to convert the data to a String before handing it off to our TTS engine:

Code: Select all

<script>
<![CDATA[
// retrieve the value contained in the node t from the DOM exposed by d
function GetData(d, t, nodata) {
	try {
		return d.getElementsByTagName(t).item(0).firstChild.data.toString();
	} catch(e) {
		// the value could not be retrieved, so return this instead
		return nodata;
	}
}
]]>
</script>
This tells the IVR system to convert the data at that node to a string. The IVR issue was also covered recently on this forum: http://support.plumvoice.com/viewtopic.php?t=414. Hope this helps.

Regards,
Plum Support
Last edited by support on Thu Feb 25, 2010 1:32 pm, edited 3 times in total.

oberwetter
Posts: 8
Joined: Fri May 12, 2006 8:01 am

Success

Post by oberwetter »

It worked. The solution was so simple after being so difficult to isolate.

Thanks.

Post Reply