gpt4 book ai didi

xslt - 在 Google Search Appliance 中更改结果标题

转载 作者:行者123 更新时间:2023-12-04 18:34:55 25 4
gpt4 key购买 nike

出于各种原因,我非常希望能够在 Google Mini 的搜索结果中将文件名显示为结果标题,而不是默认的。我几乎可以通过替换来做到这一点

<!-- *** Result Title (including PDF tag and hyperlink) *** -->
...
<span class="l">
<xsl:choose>
<xsl:when test="T">
<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="T"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$stripped_url"/></xsl:otherwise>
</xsl:choose>
</span>

<span class="l">
<xsl:value-of select="$stripped_url"/>
</span>

剩下的就是:

  1. 用空格替换 %20
  2. 修剪 url,只留下最后的文件名
  3. 从末尾修剪文件扩展名

我怎样才能做到这一点?

最佳答案

我想通了。许多代码和函数已经存在,我只需要知道我在寻找什么,然后稍微修改一下结果。

返回文档的文件名:

<span class="l">
<xsl:variable name="document_title">
<xsl:call-template name="last_substring_after">
<xsl:with-param name="string" select="substring-after(
$temp_url,
'/')"/>
<xsl:with-param name="separator" select="'/'"/>
<xsl:with-param name="fallback" select="'UNKNOWN'"/>
</xsl:call-template>
</xsl:variable>

将 %20 替换为空格:

    <xsl:call-template name="replace_string">
<xsl:with-param name="find" select="'%20'"/>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="string" select="$document_title"/>
</xsl:call-template>
</span>

关于xslt - 在 Google Search Appliance 中更改结果标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5254133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com