Reputation: 8836
I transform some different structures of XML files at once using XSLT.
Some of them have a <link></link>
element tag in their structure, and the others have either one of <feedburner:origLink></feedburner:origLink>
and <link></link>
, or both.
My question is how do I delete the <feedburner:origLink></feedburner:origLink>
when is found with the <link></link>
tag ?
This is what I use for now and some of the XMLs have two times a <url></url>
element tag.
<xsl:template match="feedburner:origLink | link">
<url>
<xsl:apply-templates select="node() | @*" />
</url>
</xsl:template>
Upvotes: 2
Views: 161
Reputation: 163262
In XSLT 2.0 you might be able to use a solution along the lines of
<xsl:apply-templates select="(link, feedburner:origLink)[1]"/>
Upvotes: 1
Reputation: 10582
One approach is to match the element with a predicate specifying that the other one isn't there:
<xsl:template match="feedburner:origLink[not(../link)] | link">
<url>
<xsl:apply-templates select="node() | @*" />
</url>
</xsl:template>
Upvotes: 0