Modify XSLT to display metadata value as document title
Summary: The document title that GSA displays in search results is either the html <title> tag or from a complex algorithm that generates the title from the page contents.
Title generation is different for various document types. If you are feeding the content, and the main content of a page is base64 encoded, the title is from one of the meta fields.
In some cases you might want to use specific values as the title of a document.
Fix: You can alter your XSLT front end to display a specific metadata value as the title in search results.
Here is a simple example of a document body:
<!DOCTYPE html>
<html>
<head>
<meta name="Article type" content="free release" />
<meta name="Issuer" content="Daily News" />
</head>
<body>
<h1>evening Newspaper</h1>
<p>My first paragraph.</p>
</body>
</html>
This example document returns the following title in search results:
Follow the steps below to change the title in GSA results to "Daily News."
- Go to Search > Search Features > Front Ends in the GSA Admin Console.
- Next to the front end you want to modify, click Edit.
- Under XSLT Stylesheet Editor, click Edit underlying XSLT code.
- Change this section of existing XSLT
From:
<xsl:choose>
<xsl:when test="T">
<span class= "goog-trans-section l" transId="gadget_{$res_num}">
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="T"/>
</xsl:call-template>
</span>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
</xsl:choose>
To:
<xsl:choose>
<xsl:when test="MT/@N='Issuer' and MT/@V!=''">
<xsl:value-of select="MT[@N = 'Issuer']/@V"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="T">
<span class= "goog-trans-section l" transId="gadget_{$res_num}">
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="T"/>
</xsl:call-template>
</span>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose> - Apply the changes in the XSLT Stylesheet Editor
To get metadata results, you need to add the "&getfields=*" param to the search query. Search results would then look like this:
Additional Information: See this document for more information about Advanced Customization Topics.
Versions affected: 7.2, 7.4 releases