This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Concatenate element values based on another key element


I am trying to write a template to concatenate values from an element based
on another key element.  The source document looks like this:


<test>
  <rec>
     <some_id>1</some_id>
     <some_text>text for id 1</some_id>
  </rec>

  <rec>
     <some_id>2</some_id>
     <some_text>first line of text for id 2</some_text>
  </rec>

  <rec>
     <some_id>2</some_id>
     <some_text>second line of text for id 2</some_text>
  </rec>

  <rec>
     <some_id>2</some_id>
     <some_text>nth line of text for id 2</some_text>
  </rec>

  <rec>
     <some_id>3</some_id>
     <some_text>text for id 3</some_text>
  </rec>
</test>

The number of <rec>s can vary and each ID can have as many lines (thus recs)
of text.  In terms of the id element, they are duplicates, but I need to
concatenate the related the element (some_text) and produce one single rec
in the output like this:

<test>
  <rec>
     <some_id>1</some_id>
     <some_text>text for id 1</some_text>
  </rec>

  <rec>
     <some_id>2</some_id>
     <some_text>first line of text for id 2 second line of text for id 2 nth
line of text for id 2</some_text>
  </rec>

  <rec>
     <some_id>3</some_id>
     <some_text>text for id 3</some_text>
  </rec>
</test>

Could anyone help me on this.  Thank you very much in advance.

Ben



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]