[英]Removing an attribute from xml using XSL transformation
我正在使用 xsl 轉換
[文件名]文件正文
我想從元素區域中刪除屬性“regionTitleFriendly”
這就是我一直在嘗試的
<xsl:template match = "sc:region[@xt:regionTitleFriendly='Region Title']"> <xsl:attribute name="id"> <xsl:value-of select="./@id"/>
</xsl:attribute> <xsl:attribute name="type"> <xsl:value-of select="./@type"/>
</xsl:attribute> <xsl:apply-templates select="node()"/> </xsl:template>但它不工作有人可以幫忙嗎? 提前致謝
如果您想從 output 中“刪除”一個屬性,通常的方法是將該屬性與“空”模板“匹配”:
使用您的匹配規則,可以將其簡單地轉換為“空”模板。 此模板僅匹配sc:region
元素中具有值'Region Title'
那些xt:region
屬性:
<xsl:template match="sc:region/@xt:regionTitleFriendly[. eq 'Region Title']"/>
如果您寧願從sc:region
元素中刪除所有@xt:regionTitleFriendly
屬性,則可以使用:
<xsl:template match="sc:region/@xt:regionTitleFriendly"/>
這對你有用嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.