I have a large poorly formed XML file where information related to a single line item is broken into multiple lines of information that I'm trying to group with the parent line item (ITEM_ID). The information is sequential so the key is the ITEM_ID node, but I can't seem to create the proper XSL needed to group the information related to an item (ITEM_ID), given the following XML source (Updated to include newly discovered grandchild element in XML source):
<LINE_INFO>
<ITEM_ID>some_part_num</ITEM_ID>
<DESC>some_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
</LINE_INFO>
<LINE_INFO>
<EXT_DESC>more_description_for_some_part_num</EXT_DESC>
</LINE_INFO>
<LINE_INFO>
<ITEM_ID>some_other_part_num</ITEM_ID>
<DESC>some_other_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
</LINE_INFO>
<LINE_INFO>
<EXT_DESC>more_description_for_some_other_part_num</EXT_DESC>
</LINE_INFO>
<LINE_INFO>
<LINE_NOTE>This is a note related to some_other_part_num</LINE_NOTE>
</LINE_INFO>
<LINE_INFO>
<ADDTL_NOTE_DETAIL>
<NOTE>This is the grandchild note that sometimes appears in my data</NOTE>
</ADDTL_NOTE_DETAIL>
</LINE_INFO>
<LINE_INFO>
<ITEM_ID>yet_another_part_num</ITEM_ID>
<DESC>yet_another_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
</LINE_INFO>
...
Desired output:
<LINE_INFO>
<ITEM_ID>some_part_num</ITEM_ID>
<DESC>some_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
<EXT_DESC>more_description_for_some_part_num</EXT_DESC>
</LINE_INFO>
<LINE_INFO>
<ITEM_ID>some_other_part_num</ITEM_ID>
<DESC>some_other_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
<EXT_DESC>more_description_for_some_other_part_num</EXT_DESC>
<LINE_NOTE>This is a note related to some_other_part_num</LINE_NOTE>
<NOTE>This is the grandchild note that sometimes appears in my data</NOTE>
</LINE_INFO>
<LINE_INFO>
<ITEM_ID>yet_another_part_num</ITEM_ID>
<DESC>yet_another_part_num_description</DESC>
<QTY>nn</QTY>
<UNIT>uom</UNIT>
</LINE_INFO>