我制定了一個XSL模板,用於重寫HTML頁面上的所有超鏈接,其中包含href屬性中的特定子字符串。它看起來像這樣:重新創建XSL超鏈接而不重新創建元素
<xsl:template match="A[contains(@href, 'asp')]">
<a>
<xsl:attribute name="href">
<xsl:value-of select="bridge:linkFrom($bridge, $base, @href, 'intranet')" />
</xsl:attribute>
<xsl:apply-templates select="node()" />
</a>
</xsl:template>
我不喜歡這樣的事實,我必須從頭開始重新創建A元素。我知道你可以做這樣的事情:
<xsl:template match="A/@href">
<xsl:attribute name="href">
<xsl:value-of select="bridge:linkFrom($bridge, $base, ., 'intranet')" />
</xsl:attribute>
</xsl:template>
但是我應該如何將這兩者合併在一起?我試過f.e.這並不起作用(元素沒有被選中):
<xsl:template match="A[contains(@href, 'asp')]/@href">
<xsl:attribute name="href">
<xsl:value-of select="bridge:linkFrom($bridge, $base, ., 'intranet')" />
</xsl:attribute>
</xsl:template>
任何幫助,非常感謝!
+1一個很好的答案。 – 2010-08-25 13:38:46
謝謝,那就是訣竅! – 2010-08-25 14:08:51
@limburgie:你好! – 2010-08-25 15:00:52