[alicebot-archcomm] A test aiml fetch service for Jon
Jonathan Roewen
alicebot-archcomm@list.alicebot.org
Thu, 14 Aug 2003 01:25:10 +1200
> The three offered "services" have three *different* interfaces:
> Different parameters, variables, structures. That's natural, because
> they deal with different content. So what makes them more usable than
> the existing interfaces offered already by external servers? What is the
> advantage of re-inventing the wheel?
Yes, I sort of agree. The only thing that needs to be standardised is a way
to retrieve XML data .. what kind of XML data will be irrelevant. The other
aspect to be standardised is how to turn the received XML into something
usable .. which, in my opinion, is where XSLT comes in.
I have a semi-working, non-robust implementation of _a_ possible fetch tag.
Combining XML & XSLT makes it a very powerful and useful feature. I've got
it working (using a hack to workaround Gary's server problems) with the
fetchDate service, and also with Amazon.com to find books using a keyword
search.
For the quotes around "Wednesday" (and the fact that it's actually Thursday
here), that's merely due to Gary's output format, and lack of specifying GMT
offset (until hopefully tomorrow for him).
Anyways, sample session:
USER > find books about Win32 Programming
J-ALICE > Results:
Title: Win32 System Programming: A Windows(R) 2000 Application Developer's
Guid
e (2nd Edition)
Author: Johnson M. Hart
Price: $39.89
Title: Windows 95 Win 32 Programming Api Bible
Author: Michael Gouker, Richard J. Simon, Brian C. Barnes
Price: $54.95
Title: .NET Framework Solutions: In Search of the Lost Win32 API
Author: John Paul Mueller
Price: $41.99
Title: Windows 95 and Nt Win32 Api from Scratch: A Programmer's Workbook
Author: David S. Platt
Price: $36.95
Title: Making WIN32 Applications Mobile
Author: Nancy Nicolaisen
Price: $31.50
Title: Tomes of Delphi: WIn32 Shell API Windows 2000 Edition
Author: John Ayres, Charles Calvert
Price: $41.97
Title: Dan Appleman's Visual Basic Programmer's Guide to the Win32 API
Author: Dan Appleman, Galen A. Grimes
Price: $41.99
Title: Win32 Perl Programming: The Standard Extensions
Author: Dave Roth
Price: $40.00
Title: Multithreading Applications in Win32: The Complete Guide to Threads
Author: Jim Beveridge, Robert Wiener, James E. Beveridge
Price: $31.49
Title: Win32 Multithreaded Programming
Author: Aaron Cohen, Mike Woodring, Ronald Petrusha
Price: $49.95
USER > what day is it?
J-ALICE > It is "Wednesday".
I'm quite surprised at my results, as I'm still crashing through XSLT,
learning how to actually write a stylesheet .. not so easy as first thought,
but getting simpler as I write/edit them =)
The two AIML categories are:
<category>
<pattern>FIND BOOKS ABOUT *</pattern>
<template xml:space="preserve">
Results:
<fetch stylesheet="amazon_test.xsl">
<url>http://xml.amazon.com/onca/xml3?t=******&dev-t=********&Keyword
Search=<star index='1'
/>&mode=books&sort=+reviewrank&offer=All&type=lite&page=
&f=xml</url>
</fetch>
</template>
</category>
<category>
<pattern>WHAT DAY IS IT</pattern>
<template>
It is <fetch stylesheet="fetch_date.xsl">
<url>http://systemscheck.com/aimlFetchServices/fetchDate.cfm?mask="dddd"</ur
l>
</fetch>.
</template>
</category>
The reasons for specifying url as a child element, rather than an attribute
is apparent in the first example, as I wouldn't be able to put <star/> into
the url otherwise. At this point, I just added stylesheet as an attribute,
but this might want to be an element as well. One reason for that could be
that it could contain the stylesheet in its contents, rather than requiring
a separate .xsl file -- however, this is just an experimental implementation
.. nothing too serious at this point.
The following XML is from my stylesheet for outputting the Amazon.com
results:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="ProductInfo">
<xsl:apply-templates select="Details" />
</xsl:template>
<xsl:template match="Details" xml:space="preserve">
Title: <xsl:value-of select="ProductName" />
Author: <xsl:apply-templates select="Authors/Author" />
Price: <xsl:value-of select="OurPrice" />
</xsl:template>
<xsl:template match="Author">
<xsl:if test="position() != 1">, </xsl:if>
<xsl:value-of select="current()" />
</xsl:template>
</xsl:stylesheet>
Anyways, I hope this will spur some more ideas about what something like
fetch could be like.
Jon =)
PS: Sorry about the long email ;-)