[英]XSL attribute without value
我會使用xsl文件在錨元素中插入“下載” html屬性。 我想要獲得的結果是
<a id="custom" href="#" download class="btn btn-default btn--download">Download</a>
我做了很多嘗試,都沒有得到任何明顯的結果。 我嘗試使用沒有值說明的xsl:attribute元素,但結果不是我要搜索的。
謝謝。
在這里您可以這樣使用:
<xsl:attribute name="download"/>
例如,您要求的屬性不是自由文本,該屬性不允許在標記內。
您可以使用XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl" version="1.0">
<xsl:template match="a">
<a id="custom" href="#" class="btn btn-default btn--download">
<xsl:attribute name="download"/>
<xsl:apply-templates/>
</a>
</xsl:template>
</xsl:stylesheet>
參見鏈接: https : //xsltfiddle.liberty-development.net/6r5Gh2K/1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.