Subject: Re: [xsl] Removal of similar but different elements from XML file From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Fri, 06 Mar 2009 18:00:21 +0100 |
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.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:data="http://example.com/2009/data" exclude-result-prefixes="data" version="1.0">
<data:data> <Removals> <Citation>Stamp Designers</Citation> <Citation>Stamp Engravers</Citation> </Removals> </data:data>
<xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template>
Martin Honnen http://JavaScript.FAQTs.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Removal of similar but differ, Mark Wilson | Thread | Re: [xsl] Removal of similar but di, Mark Wilson |
RE: [xsl] Effects of white space be, Michael Kay | Date | Re: [xsl] Removal of similar but di, Mark Wilson |
Month |