[xsl] Another (positional?) grouping problem

Subject: [xsl] Another (positional?) grouping problem
From: Rudolf P. Weinmann <rudolf.weinmann@xxxxxxxxxxxx>
Date: Thu, 19 Oct 2006 15:53:36 +0200
Hi

Could anybody please tell me how to solve the following grouping problem with
xslt 2.0?

The input isn't structured. There is a root element and a sequence of
elements.
Input:
<DOC>
  <BALANCE_OLD>3141.70</BALANCE_OLD>
  <DATE>2006-04-26</DATE>
  <VALUE_DATE>2006-04-25</VALUE_DATE>
  <TEXT>text 1</TEXT>
  <TEXT>text 2</TEXT>
  <TEXT>text 3</TEXT>
  <TEXT>text 4</TEXT>
  <AMOUNT>315.00</AMOUNT>
  <BALANCE_NEW>3456.70</BALANCE_NEW>
  <DATE>2006-04-28</DATE>
  <VALUE_DATE>2006-04-26</VALUE_DATE>
  <TEXT>Text 1</TEXT>
  <TEXT>Text 2</TEXT>
  <AMOUNT>465.00</AMOUNT>
  <BALANCE_NEW>3921.70</BALANCE_NEW>
</DOC>

Each DATE element is the start of a group. The end of the group is either the
next DATE element or the end of the input.
I need to put the elements of each group into a <Transaction> element as
follows:

<Trx>
  <Transaction>
    <Date>2006-04-26</Date>
    <ValueDate>2006-04-25</ValueDate>
    <Text>text 1</Text>
    <Text>text 2</Text>
    <Text>text 3</Text>
    <Text>text 4</Text>
    <Amount>315.00</Amount>
    <NewBalance>3456.70</NewBalance>
  </Transaction>
  <Transaction>
    <Date>2006-04-28</Date>
    <ValueDate>2006-04-26</ValueDate>
    <Text>Text 1</Text>
    <Text>Text 2</Text>
    <Amount>465.00</Amount>
    <NewBalance>3921.70</NewBalance>
  </Transaction>
</Trx>

How can this be done with xslt 2.0?

Any help greatly appreciated,
Rudolf

Current Thread