in my source xml, I have a lines-element, containing N line-elements. Each line-element has a groupid and a lineNo-element. lineNo is a unique integer value.
I also have a groups-element, containing M group-elements. For each distinct groupid from the line-elements I have exactly one group-element, so groupid is unique within the group-elements.
Now, I want to transform the xml in a way, that I add data from the group-element to the corresponding line-element, but only to the line element with the min. lineNo for that groupid.
Can that be done with XSLT 1.0? See sample xmls below.
thank you very much & best regards
Tobias
Here's a simplified input:
<test>
<lines>
<line>
<groupid>1</groupid>
<lineNo>1</lineNo>
</line>
<line>
<groupid>1</groupid>
<lineNo>2</lineNo>
</line>
<line>
<groupid>1</groupid>
<lineNo>3</lineNo>
</line>
<line>
<groupid>2</groupid>
<lineNo>4</lineNo>
</line>
<line>
<groupid>2</groupid>
<lineNo>5</lineNo>
</line>
</lines>
<groups>
<group>
<groupid>1</groupid>
<groupTotal>100</groupTotal>
</group>
<group>
<groupid>2</groupid>
<groupTotal>200</groupTotal>
</group>
</groups>
</test>
And here the expected result.
<test2>
<lines>
<line>
<groupid>1</groupid>
<lineNo>1</lineNo>
<groupTotal>100</groupTotal>
</line>
<line>
<groupid>1</groupid>
<lineNo>2</lineNo>
<groupTotal/>
</line>
<line>
<groupid>1</groupid>
<lineNo>3</lineNo>
<groupTotal/>
</line>
<line>
<groupid>2</groupid>
<lineNo>4</lineNo>
<groupTotal>200</groupTotal>
</line>
<line>
<groupid>2</groupid>
<lineNo>5</lineNo>
<groupTotal/>
</line>
</lines>
</test2>