![](/img/trans.png)
[英]How to assign the attribute of an element with the content of another element in XSL?
[英]How to assign a class to a XSL element
我有以下XSL标签:
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="QuickLink" />
</xsl:attribute>
<xsl:value-of select="Html/root/NewsArticle/artTitle" />
</xsl:element>
如何为链接A
分配一个类?
首先,除非您需要计算元素名称,否则不需要xsl:element
,您只需编写一个文字结果元素:
<a href="{QuickLink}" class="some-class-name"><xsl:value-of select="Html/root/NewsArticle/artTitle"/></a>
该类是一个属性。 您可以使用添加href属性的相同方式添加它。
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="QuickLink" />
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="some-class-name" />
</xsl:attribute>
<xsl:value-of select="Html/root/NewsArticle/artTitle" />
</xsl:element>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.