2009-02-27 54 views
2

我有一個超鏈接列的sharepoint列表。xslt超鏈接,單獨的url和descption

我把這個列表放入xml中並將xslt應用到它。

xml將在的形式產生輸出:

<link>http://www.foo.com, http://www.foo.com</link> 

如何可以使用XSLT我顯示該鏈接?

感謝

回答

6

如何:

<xsl:template match="link"> 
    <a href="{substring-before(.,',')}"> 
    <xsl:value-of select="substring-after(.,',')"/> 
    </a> 
</xsl:template> 
2

對於XSLT 2.0

<xsl:template match="link"> 
    <xsl:element name="a"> 
     <xsl:attribute name="href"> 
     <xsl:value-of select="substring-before(.,',')"/> 
     </xsl:attribute> 
     <xsl:value-of select="substring-after(.,',')"/> 
    </xsl:element> 
</xsl:template> 

雖然它使得略少可讀性,擴展的語法被認爲是很好的做法,當樣式表變得很大。文字結果元素不像xsl:element/xsl:attribute那樣容易操作XPath:

+0

xslt 2.0是否不包含縮寫語法? (根據我的文章) – 2009-02-27 14:31:16