[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: not copying duplicate node to the output (remove
I think you have taken the right approach to use the identity template pattern.
I have tried to understand your requirement, and come up with this solution: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*" /> </xsl:copy> </xsl:template> <xsl:template match="release[@display_on = 'headlines;'][doc_number = ../release[not(@display_on = 'headlines;')]/doc_number]" /> <xsl:template match="release[@display_on = 'headlines;'][normalize-space(doc_number) = '']"> <xsl:copy-of select="." /> </xsl:template> <xsl:template match="@display_on[not(. = 'headlines;')]"> <xsl:attribute name="display_on"> <xsl:value-of select="concat(., ';headlines')" /> </xsl:attribute> </xsl:template> </xsl:stylesheet> I hope this helps. On 3/2/07, Wei Chin <wei_chin@xxxxxxxxxxx> wrote: Hi I have this problem: I need to combine two data groups below: A. conditions: 1. Each release has a unique Id. 2. The two groups have duplicated <doc_number>s. if one <release> in data group A has a <doc_number> that is already in data group B, remove that entire <release> node in data group A. 3. Certain <release> does not even have a <doc_number>, but there is a <doc_number /> tag to represent an empty value. in this case, we keep the entire <release> node. 4. insert ";headlines;" into the "display_on" attribute to the <release>. Current file: <!-- start of file --> <releases> <!-- Data group A --> <release id="2" name="AB" display_on="headlines;" type="NEWS"> <doc_number>6</doc_number> </release> <release id="4" name="CD" display_on="headlines;" type="NOTICE"> <doc_number>5</doc_number> </release> <release id="6" name="EF" display_on="headlines;" type="ORDER"> <doc_number>4</doc_number> </release> <release id="8" name="GH" display_on="headlines;" type="ORDER"> <doc_number>3</doc_number> </release> <release id="10" name="IJ" display_on="headlines;" type="NOTICE"> <doc_number>2</doc_number> </release> <release id="12" name="KL" display_on="headlines;" type="NOTICE"> <doc_number /> </release> -- Regards, Mukul Gandhi
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|