我制定了一个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