[xsl] Removal of similar but different elements from XML file

Subject: [xsl] Removal of similar but different elements from XML file
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Fri, 6 Mar 2009 09:39:16 -0700
In an XML file used to generate a cumulative index to a journal, I have a number of similar citations, one of which sometimes needs to be removed from the file.

As shown in the original example below, note that the content of the first <Subject>'s <SubDiv1> child, Kucera, Vaclav, matches the content of the second <Subject><Heading>'s child, Kucera, Vaclav. As shown in the output example, I want to remove this second <Subject>.

However, I only want to do this for certain <Headings> and need to specify in my XSLT style sheet, for instance, if within an <Item> the <Heading>Stamp Designers</Heading>'s <SubDiv1> child is identical to another another <Subject>'s <Heading> child, remove the latter. Thus, I cannot use a generalized version (I must be able to specify the first <Heading>, because not all of these constructs should be removed). I do not object to running the style sheet repeatedly to apply it to, for instance, <Heading>Stamp Engravers</Heading>. However, it would be great to be able to drive it with a list like:

<Removals>
   <Citation>Stamp Designers</Citations>
   <Citation>Stamp Engravers</Citations>
<Removals>

Any hints or help would be greatly appreciated.
Regards,
Mark

Original:
<List>
   <Item>
       <Subject>
           <Heading>Stamp Designers</Heading>
           <SubDiv1>Kucera, Vaclav</SubDiv1>
           <SubDiv2 >Czech Graphic Humor Issue</SubDiv2>
       </Subject>
       <Subject>
           <Heading>Kucera, Vaclav</Heading>
           <SubDiv1 >Czech Graphic Humor Issue</SubDiv1>
       </Subject>
       <Article>
           <Person>van Zanten, G.M.</Person>
           <Title>New issues. Czech Republic</Title>
           <IssueName>Jan/Feb</IssueName>
           <IssueNumber>1</IssueNumber>
           <Year>2000</Year>
           <Page>35</Page>
       </Article>
   </Item>
</List>

Output:
<List>
   <Item>
       <Subject>
           <Heading>Stamp Designers</Heading>
           <SubDiv1>Kucera, Vaclav</SubDiv1>
           <SubDiv2 >Czech Graphic Humor Issue</SubDiv2>
       </Subject>
       <Article>
           <Person>van Zanten, G.M.</Person>
           <Title>New issues. Czech Republic</Title>
           <IssueName>Jan/Feb</IssueName>
           <IssueNumber>1</IssueNumber>
           <Year>2000</Year>
           <Page>35</Page>
       </Article>
   </Item>
</List>

Current Thread