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

Re: comparing following nodes and re-structuring.

Subject: Re: comparing following nodes and re-structuring.
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Tue, 06 Dec 2011 15:34:30 +0100
Re:  comparing following nodes and re-structuring.
On 2011-12-06 15:24, Andrew Welch wrote:
On 6 December 2011 14:17,<charlieo0@xxxxxxxxxxx> wrote:
I could use some help with the following problem.

I have an XML instance that is a long list of table entries. I need to compare text nodes and if they are the same, restructure an aspect of the row. I have been able to write something that will compare only the first following and first preceding rows, but I need to be able to traverse multiple rows until the matching stops. If there is no duplicate NSN, then merely copy the row as is.

Use a for-each-group selecting the nsnindxrow, grouping on the nsn, and within its body use copy-of="current-group()/callout" to get all the callouts for that nsn (the current-grouping-key())

Like that:

  <xsl:template match="nsnindx">
      <!-- group-by="nsn" assumption: the string value of nsn is unique
           for every possible combination of fsc and niin -->
      <xsl:for-each-group select="nsnindxrow" group-by="nsn">
        <!-- the context item is the first item in each group,
             so copy and copy-of work on the first group item and
             its nsn child, respectively: -->
          <xsl:copy-of select="nsn" />
          <xsl:sequence select="current-group()/callout" />

Current Thread


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.
First Name
Last Name
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.