Removal of same tiered nodes, based on text
Given:
<Event>
<EventType>Name1</EventType>
<Stuff>stuff</Stuff>
<ImageName>imageName1</ImageName>
</Event>
<Event>
<EventType>Name2</EventType>
<Destination>place</Destination>
<ImageName>imageName1</ImageName>
<ImageName>imageName2</ImageName>
<imageName>imageName3</ImageName>
</Event>
End Result:
<Event>
<EventType>Name1</EventType>
<Stuff>stuff</Stuff>
<ImageName>imageName1</ImageName>
</Event>
<Event>
<EventType>Name2</EventType>
<Destination>place</Destination>
</Event>
Essentially, I want to remove all of the <ImageName> nodes in the second <Event> set. I am thinking that this can be done based on the text that is in the second sets <EventType> field (Name2 in this example). However, I am not sure how to check another node's text and remove (or not copy) the nodes that are in the same tier.
Attempt:
<xsl:template match="/Event/ImageName">
<xsl:if test="parent::node()/EventType[./text() = Name2]">
</xsl:if>
</xsl:template>
I've also put the <xsl:apply-templates /> in between the if statements. I have also done a number of other attempts, almost all I cannot remember. In the end, none of my attempts remove the <ImageName> tags from the second <Event> set. OR, one of my attempts seemed to remove everything from teh XML during transform.
Any ideas? Thank you.
|