The OUTPUT BINDING for a
website description consists of a WebL script that extracts information from the
information source. Here is the OUTPUT BINDING for AmazonSearch:
<OUTPUTBINDING>
<SCRIPT> <![CDATA[
var titles = Elem(P, "a") inside
Elem(P,"dt");
var dd = Elem(P,"dd");
var Author, Price, temp;
i = 0;
while i < Size(titles) do
temp = Pat(dd[i],
`[$](\d+[.]\d+)`);
if (Size(temp) == 0)
then
Price = nil;
else
Price = ToReal(temp[0][1]);
end;
temp = Pat(dd[i],
`^[^/]+`);
if (Size(temp) == 0)
then
Author = nil;
else
Author = Str_Trim(Text(temp[0]));
end;
if(Str_IndexOf("Read more", Author) != -1) then
Author = Text(Pat(dd[i], `\w.*\n`)[0]);
end;
R = R + [
[.title = Text(titles[i]),
price = Price,
author = Author
.]];
i = i+1;
end; ]]>
</SCRIPT>
</OUTPUTBINDING>
The script in the OUTPUT BINDING only contains the code that extracts the information. The portion of code that actually performs the query is dynamically generated based on user input. For more information on how to write WebL Scripts, visit the WebL Homepage: