XSLT XML Question.
Looking into a simple transformation. I have simple index xml input. I have to output the the first and last element with a for each chapter. AS shown
Updated to take advantage of a cleaner predicate - thanks to @SeanB.Durkin.
I. XSLT 1.0 Solution
When this XSLT:
...is applied to the original XML:
Chapter01
Chapter01
Chapter01
Chapter01
Chapter01
Chapter01
Chapter02
Chapter02
Chapter02
Chapter02
Chapter02
Chapter02
Chapter03
Chapter03
Chapter03
Chapter03
Chapter03
Chapter03
...the desired result is produced:
Chapter01
Chapter01
Chapter02
Chapter02
Chapter03
Chapter03
Explanation:
elements by their value.
element, two
elements are copied: the first and last from the group that contains the unique value.II. XSLT 2.0 Solution
Note that in XSLT 2.0, the solution becomes even simpler.
When this XSLT:
...is applied to the original XML, the same desired result is produced:
Chapter01
Chapter01
Chapter02
Chapter02
Chapter03
Chapter03
Explanation:
current-group()
instruction are used.