2011-03-10 5 views
3

다양한 이유 때문에 기본값보다 Google Mini의 검색 결과에 파일 이름을 결과 제목으로 표시하고 싶습니다. Google 검색 어플라이언스의 결과 제목 변경

  • 그렇게 URL을 손질

    1. 공백은 % 20 대를 교체 : 나는 거의 어떤 요구 남은 것은이다

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

      <!-- *** 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> 
      

      를 대체하여이 작업을 수행 할 수 있어요 끝 파일 이름 만 남습니다.

    2. 끝에서 파일 확장명을 자릅니다.

    어떻게하면됩니까?

  • 답변

    2

    나는 그것을 알아 냈다. 많은 코드와 함수가 이미 존재했기 때문에, 내가 찾고 있던 것을 알고 나서 결과를 약간 마사지해야했습니다.

    반환 문서의 파일 이름 :

    <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> 
    
    0

    또한, 파일 확장자가 추가로 발견 제거 할 수 있습니다/변수를 대체합니다.

    <xsl:variable name="document_title_remove_extension"> 
        <xsl:call-template name="replace_string"> 
         <xsl:with-param name="find" select="'.pdf'"/> 
         <xsl:with-param name="replace" select="''"/> 
         <xsl:with-param name="string" select="$document_title"/> 
        </xsl:call-template> 
        </xsl:variable> 
        <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_remove_extension"/> 
        </xsl:call-template> 
    </span>