Google Search Appliance OneBox for Enterprise Developers Guide User Manual

Page 15

Advertising
background image

Google Search Appliance: Google OneBox for Enterprise Developer’s Guide

15

The XSLT template transforms the associated results into HTML suitable for display. The following XSLT
example creates an HTML table and transforms the <Field> name attributes:

<xsl:template name="directory">

<table border="0" cellpadding="1" cellspacing="0">

<tbody>

<tr>

<td colspan="2">

<nobr>

<a>

<xsl:attribute name="href">

<xsl:value-of select="title/urlLink"/>

</xsl:attribute>
<b>

<xsl:value-of select="title/urlText"/>

</b>

</a>

</nobr>

</td>

</tr>

<tr>

<td valign="top" width="40">

<img>

<xsl:attribute name="src">

<xsl:value-of select="IMAGE_SOURCE"/>

</xsl:attribute>

</img>

</td>
<td valign="top" width="99%">

<xsl:for-each select="MODULE_RESULT">

<font size="-1">

<b>

<a>

<xsl:attribute name="href">

<xsl:value-of select="U"/>

</xsl:attribute>
<xsl:value-of select="Field[@name=’firstname’]"/>
<xsl:value-of select="Field[@name=’lastname’]"/>

</a>

</b> -

<xsl:value-of select="Field[@name=’email’]"/> -

<xsl:value-of select="Field[@name=’phone’]"/>

</font>
<br/>

</xsl:for-each>

</td>

</tr>

</tbody>

</table>

</xsl:template>

The stylesheet template must begin with the <xsl:template> element, which is matched to generate
the HTML results. The <xsl:template> element must include a name attribute, and must not include
the match attribute, which interferes with other stylesheet operations in the search appliance’s front
end. You can include other <xsl:template> elements within the stylesheet.

If you do not specify an XSLT template, the search appliance uses the default template. The default XSLT
template only returns a maximum of three results.

Advertising