2015-02-09 53 views
0

如果您在google學者中搜索例如:http://scholar.google.com/scholar?q=filetype:pdf,您可以在右側看到使用pdf的下載鏈接(如下圖所示)。如何使用xslt 1.0從網址中提取域名

enter image description here

我怎樣才能提取使用XSLT URL中的域名?在上圖中,google學者剛剛顯示了url的域名(例如sciencenet.cn,unive.it)。該網址可以在http,https,ftp中。

我試圖實現的是這樣的SO post,但使用xslt。

在此先感謝。

+0

AFAICT,以上網址返回一個HTML文件,是不是** **一個良好的XML文檔 - 所以它不可能處理它使用XSLT。 – 2015-02-09 07:26:36

+0

@ michael.hor257k,我指的是搜索結果的網址。例如,在第一個搜索結果中,url是:http://bbs.sciencenet.cn/bbs/upload/15320200207j5.pdf,所以我想提取bbs.sciencenet.cn。 – euler 2015-02-09 08:23:00

+0

我指的是搜索返回的文檔。 – 2015-02-09 08:32:55

回答

0

周圍的Googling,我在這裏找到了答案:Extracting Domain from URL in XSLT

<xsl:template match="/"> 
    <xsl:variable name="url_ini" select="/root/url"/>   
    <xsl:variable name="url_minus_http" select="substring-after($url_ini,'//')"/> 

    <xsl:value-of select="substring-before($url_minus_http,'/')"/>    
    </xsl:template>