Reputation: 25
Using JAPI-GSA i receive, in each summary, html tags from result GSA.
As
"summary": "...</b> Ce tarif n'est pas valable pour les enfants voyageant seuls (UM). Tarif le
plus bas</b>, Autres tarifs, Vol aller : Paris - Kuala Lumpur. ...</b> "
How to remove these tags from summary. Hint: I need to modify XSLT
Upvotes: 0
Views: 276
Reputation: 91
The raw search results which are thrown by GSA are in XML. In this XML output, the snippets contain tags after a certain amount of characters. You can't edit the XML output, but like you're hinting you can modify the XSLT.
In the XSLT file, add the following template:
<!-- **********************************************************************
REMOVE BR LINE-BREAKS FROM SNIPPETS
********************************************************************** -->
<xsl:template name="remove_br">
<xsl:param name="orig_string"/>
<xsl:variable name="removed_br">
<xsl:call-template name="replace_string">
<xsl:with-param name="find"><br></xsl:with-param>
<xsl:with-param name="replace"> </xsl:with-param>
<xsl:with-param name="string" select="$orig_string"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of disable-output-escaping='yes' select="$removed_br"/>
</xsl:template>
This template finds tags and replaces them with white space. After adding this template, locate the section where the snippet box is being created and replace that with the following code snippet:
<!-- *** Snippet Box *** -->
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="s">
<xsl:if test="$show_res_snippet != '0' and string-length(S) and
$only_apps != '1'">
<xsl:variable name="snippet">
<xsl:call-template name="remove_br">
<xsl:with-param name="orig_string" select="S"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="$snippet"/>
</xsl:call-template>
</xsl:if>
This code calls the template you added earlier and generate a snippet where the tags are replaced with a white space.
Upvotes: 0