我試圖從一個節點中刪除一個屬性,這個節點基於祖先的名字存在。如果祖先存在,XSLT刪除屬性
這是我的模板。我試圖刪除所有minOccurrs
屬性,除非祖先是updateCurrentObjective
。
<xsl:template match="@minOccurs">
<xsl:if test="0 = count(ancestor::node()[name() = 'updateCurrentObjective'])">
<xsl:copy/>
</xsl:if>
</xsl:template>
因此,對於以下XML,它應該刪除該屬性。
<xs:extension base="tns:planElement">
<xs:sequence>
<xs:element minOccurs="0" name="action" type="xs:string"/>
</xs:sequence>
<xs:extension>
但是對於以下它應該保持不變。
<xs:complexType name="updateCurrentObjective">
<xs:sequence>
<xs:element minOccurs="0" name="currentObjective" type="tns:objective"/>
</xs:sequence>
</xs:complexType>
想法?