1
A
回答
1
下面演示添加屬性(在此情況target
)到a
標記中的每一個,這些標記是ID爲navigation
(因此對應於CSS中的#navigation
)的元素下的子元素。來自原始標籤的所有內容和其他屬性都得到維護(儘管訂單可能不會 - 儘管這不應該成爲問題)。
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<after css:theme="#target" css:content="#navigation" />
<xsl:template match="*[@id='navigation']//a">
<xsl:copy>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</rules>
有附加條件,如果你想匹配特定a
標記相應的調整match
條件。 xsl:template
將在所有標準重氮規則之後執行,因此如果您恰好改變了結果文檔中a
標籤的結構,請確保相應地調整match
條件。
這是在官方重氮文檔http://docs.diazo.org/en/latest/recipes/adding-an-attribute/index.html
1
不知道你的意思。 如果你想創建一個XSLT那份一切,但調整隻是「一」的DIV ID中的元素=「導航」你應該這樣做:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//div[@id='navigation']//a">
<a>
<xsl:attribute name='href'>
<xsl:value-of select='@href' />
</xsl:attribute>
<!-- Change your content here -->
</a>
</xsl:template>
</xsl:stylesheet>
相關問題
- 1. 使用jquery在<a>標籤中插入'rel'屬性標籤
- 2. 即時插入html和標籤
- 3. 修復「a」標籤「title」屬性的css
- 4. HTML <a>標籤屬性
- 5. <a>標籤的屬性屬性是什麼?
- 6. 將id屬性放在「a」標籤或「h1/h2」標籤中是否更好?
- 7. 在struts2的超鏈接標題屬性中插入標籤屬性字符串
- 8. nokogiri:如何在表格標籤後立即插入tbody標籤?
- 9. 將目標屬性的DIV標籤
- 10. Python代碼的深度基於父標籤屬性值插入XML標籤
- 11. A標記活動屬性
- 12. 將H3標籤放入A或LI標籤
- 13. 插入標籤
- 14. 插入屬性
- 15. 在XSLT中的屬性值中插入標籤
- 16. AttributeError:標籤實例沒有屬性「插入」
- 17. 如何在div標籤下插入LI元素的ID屬性
- 18. Angular2在標籤中插入自定義屬性與指令
- 19. 休眠多對一標籤屬性「插入/更新」
- 20. jQuery的插入值到另一個標籤或屬性
- 21. 在鍵入輸入時獲取屬性標籤
- 22. AngularJS標籤屬性
- 23. 標籤屬性length
- 24. 標籤屬性爲
- 25. HTML標籤屬性
- 26. JSP標籤屬性
- 27. UIbutton標籤屬性
- 28. 如何使用javascript動態地將新屬性插入到xml標籤中?
- 29. 通過模板將輸入標籤插入td標籤
- 30. 如何將輸入標籤插入到td標籤中?