[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

not copying duplicate node to the output (remove dupl

Subject: not copying duplicate node to the output (remove duplicate node)
From: "Wei Chin" <wei_chin@xxxxxxxxxxx>
Date: Thu, 01 Mar 2007 18:52:36 -0500
 not copying duplicate node to the output (remove  dupl
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>


<!-- Data group B -->
<release id="14" name="XY" display_on="homepage" type="MEMORANDUM">
 <doc_number>5</doc_number>
</release>
<release id="16" name="MN" display_on="sidepage" type="NOTICE">
 <doc_number>4</doc_number>
</release>
<release id="18" name="OP" display_on="otherpage" type="NOTICE">
 <doc_number>3</doc_number>
</release>
</releases>
<!-- end of file -->
Desired resulting 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="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>

<!-- Data group B -->
<release id="14" name="XY" display_on="homepage;headlines" type="MEMORANDUM">
<doc_number>5</doc_number>
</release>
<release id="16" name="MN" display_on="sidepage;headlines" type="NOTICE">
<doc_number>4</doc_number>
</release>
<release id="18" name="OP" display_on="otherpage;headlines" type="NOTICE">
<doc_number>3</doc_number>
</release>
</releases>
<!-- end of file -->
Right now I have this code written to generate the result, but it only works partially.
1. It removes the duplicated <doc_number> from each release, but it does not remove the whole release.
2. It does not insert ";headlines;" into the "display_on" attribute to the <release>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="doc_number">
<xsl:if test="not(string(.))">


 </xsl:if>
 <xsl:if test="not(. = following::fcc_doc_number)">
  <xsl:copy>
   <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:if>
</xsl:template>
<xsl:template match="@*|node()">
 <xsl:copy>
  <xsl:apply-templates select="@*|node()"/>
 </xsl:copy>
</xsl:template>
</xsl:stylesheet>
Please anyone help out? thank you!

_________________________________________________________________
Mortgage rates as low as 4.625% - Refinance $150,000 loan for $579 a month. Intro*Terms https://www2.nextag.com/goto.jsp?product=100000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h27f6&disc=y&vers=743&s=4056&p=5117


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.