Transforming xml to html – Google Search Appliance OneBox for Enterprise Developers Guide User Manual
Page 13

Google Search Appliance: Google OneBox for Enterprise Developer’s Guide
13
The following example shows the results from a directory smith query and the directory items for
William Smith and Bill Smith. The <MODULE_RESULT> tag contains the information sent from the
provider for the search results:
<?xml version="1.0" encoding="UTF-8"?>
<OneBoxResults>
<provider>ACME Employee Directory</provider>
<title>
<urlText>13 results in the ACME directory</urlText>
<urlLink>http://directory.corp.acme.com/cgi-bin/search?smith</urlLink>
</title>
<IMAGE_SOURCE>http://directory.corp.acme.com/images/directory.jpg
</IMAGE_SOURCE>
<MODULE_RESULT>
<U>http://directory.corp.acme.com/cqi-bin/lookup?empid=448473</U>
<Field name="display">Smith, William</Field>
<Field name="firstname">William</Field>
<Field name="lastname">Smith</Field>
<Field name="phone">617-555-1234</Field>
<Field name="email">[email protected]</Field>
<Field name="picture">http://directory.corp.acme.com/cqi-bin/lookup?
photo=448473</Field>
</MODULE_RESULT>
<MODULE_RESULT>
<U>http://directory.corp.acme.com/cqi-bin/lookup?empid=22638</U>
<Field name="display">Smith, Bill R.</Field>
<Field name="firstname">Bill</Field>
<Field name="lastname">Smith</Field>
<Field name="phone">617-555-9345</Field>
<Field name="email">[email protected]</Field>
<Field name="picture">http://directory.corp.acme.com/cqi-bin/lookup?
photo=22638</Field>
</MODULE_RESULT>
</OneBoxResults>
Transforming XML to HTML
You can transform the XML results into HTML by means of an XSLT stylesheet template.
The <Field> elements (see the element “MODULE_RESULT” on page 28) are available for both external
and internal OneBox provider.
The <Field> elements provide data about the results from a provider, and you can specify parameters
to improve the display of the results data. In the directory example, the provider sends the search
appliance two results and title display information:
•
The title is a clickable URL with the text “13 results in the ACME directory.”
•
An icon image makes the results stand out as directory entries.
•
The two results are directory listing results, including a display name, first name, last name, phone
number, email address, and link to an image of the employee.
The <Field> element’s name attribute provides the information for the OneBox.