|
| |
Gregor Android Demo
March 7th, 2008
The demo illustrates the use of Gregor's compiled XSLT transforms and small
footprint runtime system as a technology to help quickly build high performing
XML web service consuming Android applications. This demo processes Amazon WS
XML responses to searches of Amazon's huge music catalog. The technology is
equally applicable to other domains such as flight/hotel/travel, personal
finance and investing, health data, etc. The demo application has been developed
quickly and provides snappy experience on Android emulators.
What happens under the hood?
- a user enters the name of a musician, composer, group etc. and initiates
search
- the app sends the request to an intermediate server
- the intermediate server forwards the query to Amazon and receives a 237kb
XML response, a document listing CD/DVD titles, release, dates, prices,
image URLs, user rating, user and editorial reviews, etc.
- a Gregor transformer running within a servlet parses and transforms the
response
 | it uses Ambrosoft's fast integrated XML parser to parse the Amazon WS response
payload |
 | the transformation prunes data irrelevant to our demo app; the
transcoding makes the data bundle smaller; it would be possible to
perform mash-up functionality at this stage |
 | XSLT is optimized and compiled to Java bytecodes, and further
transcoded to Android Dalvik VM bytecodes |
 | transformation output is Ambrosoft's binary XDM format (XML Data
Model) to save I/O and client CPU processing |
 | transformations are performed at the rate of ~ 500-600 per second
end-to-end: from getting input document's characters to complete output
in the XDM format |
the Android application receives the response to its query in the XDM form
and immediately applies one of several translets to generate a document
View: a list of CDs formatted for the Android screen.
the user can view the data in various ways by running other transforms
dynamically without further round-trip requests to the server; the
alternative document views are activated from the application's Menu or by
following links; the transformations are performed in-place to save memory
and are very fast. As measured on a desktop these transformations can be
performed at the rate of 14,000 per second! On a small device that speed
translates to high efficiency: the high ratio of useful work per battery
life unit, as well as a great responsiveness of the application.
Notes:
- the demo application in Android's APK package, complete with a needed
subset of Gregor runtime, and compiled translets takes up only about 99kb
(like the size of 3 of the JPG images below).
- the use of the intermediate server is not strictly necessary, the
Android/Gregor app could fast-parse the Amazon XML directly on device but it
would need to deal with significantly larger documents. Both options are
open and feasible; they involve different trade-offs.
To run the demo you will need the Google
Android SDK which contains the emulator.
You can download the demo application by right-clicking here Gregor-Android-Amazon
demo (apk).

A user enters a query.

The response data is received and transformed into a table.

The user can sort the data instantly, selecting alternative views from a
menu.

The user can follow a link to drill down to detailed information about a CD.
No server round-trip is needed: all the data is already on Android, it just
needs to be transformed in a different way. Please note that we do not clean
data from Amazon, you may notice HTML tags that show up verbatim.
|