Before i go to the actual question i must say certain things. i understand this topic is already discussed much in this forum. but still my situation is bit unique.
i have to perform this transform inside a tool called BMC atrium orchestrator version 7.9 , which uses not just xslt 1.0 but the XSLT processor it uses is also bit older or not that much friendly .why am saying this at the very begging is
this very simple nested transform listed above in the link itself , am not able to perform in that tool . just copying and pasting the source xml and xslt it showing error.
below is the source xml
<root>
<order>
<item>
<item_type>A</item_type>
<item_type>A</item_type>
<item_type>B</item_type>
<item_type>C</item_type>
</item>
</order>
<order>
<item>
<item_type>A</item_type>
<item_type>B</item_type>
<item_type>C</item_type>
<item_type>C</item_type>
</item>
</order>
<order>
<item>
<item_type>C</item_type>
<item_type>C</item_type>
<item_type>B</item_type>
</item>
</order>
</root>
below is the source xslt
xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="groups" match="item_type" use="concat(., '|', generate-id(ancestor::order))"/>
<xsl:template match="/root">
<root>
<xsl:for-each select="order">
<order>
<xsl:for-each select="item/item_type[generate-id() = generate-id(key('groups', concat(., '|', generate-id(ancestor::order)))[1])]">
<item>
<xsl:value-of select="."/>
</item>
</xsl:for-each>
</order>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
above xml & XSLT is solely given to say that such a simple transformation is not working for some reason with my tool. screen shots in comment section. but that is not my actual problem. as i gave the background , now am moving to actual question
my source xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element>
<credat>20180518</credat>
<cretim>06:25:10</cretim>
<docnum>1177016</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-039723</field1>
<field14>ENTRY_QNT-150.000</field14>
<field15>ENTRY_UOM-PK</field15>
<field2>PLANT-GB20</field2>
<field3>STGE_LOC-GB30</field3>
<field4>BATCH-A012A02</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& & : Original Batch & differs from Confirmed Batch &</statusMessage>
</element>
<element>
<credat>20180518</credat>
<cretim>06:26:30</cretim>
<docnum>1177017</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-039723</field1>
<field14>ENTRY_QNT-150.000</field14>
<field15>ENTRY_UOM-PK</field15>
<field2>PLANT-GB20</field2>
<field3>STGE_LOC-GB30</field3>
<field4>BATCH-A012A02</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& & : Original Batch & differs from Confirmed Batch &</statusMessage>
</element>
<element>
<credat>20180518</credat>
<cretim>06:26:51</cretim>
<docnum>1177018</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-039723</field1>
<field14>ENTRY_QNT-150.000</field14>
<field15>ENTRY_UOM-PK</field15>
<field2>PLANT-GB20</field2>
<field3>STGE_LOC-GB30</field3>
<field4>BATCH-A012A02</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& & : Original Batch & differs from Confirmed Batch &</statusMessage>
</element>
<element>
<credat>20180604</credat>
<cretim>12:21:35</cretim>
<docnum>1177592</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-039723</field1>
<field14>ENTRY_QNT-150.000</field14>
<field15>ENTRY_UOM-PK</field15>
<field2>PLANT-GB20</field2>
<field3>STGE_LOC-GB30</field3>
<field4>BATCH-A012A02</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& & : Original Batch & differs from Confirmed Batch &</statusMessage>
</element>
<element>
<credat>20180604</credat>
<cretim>12:21:45</cretim>
<docnum>1177593</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-039723</field1>
<field14>ENTRY_QNT-150.000</field14>
<field15>ENTRY_UOM-PK</field15>
<field2>PLANT-GB20</field2>
<field3>STGE_LOC-GB30</field3>
<field4>BATCH-A012A02</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& & : Original Batch & differs from Confirmed Batch &</statusMessage>
</element>
<element>
<credat>20180614</credat>
<cretim>16:04:13</cretim>
<docnum>1178094</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180618</credat>
<cretim>12:07:05</cretim>
<docnum>1178407</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180619</credat>
<cretim>09:08:31</cretim>
<docnum>1178456</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180619</credat>
<cretim>09:12:07</cretim>
<docnum>1178644</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180619</credat>
<cretim>10:13:17</cretim>
<docnum>1178649</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:25:03</cretim>
<docnum>1178722</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:27:48</cretim>
<docnum>1178723</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:31:47</cretim>
<docnum>1178724</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:35:49</cretim>
<docnum>1178725</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:38:50</cretim>
<docnum>1178726</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:42:36</cretim>
<docnum>1178727</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>15:44:40</cretim>
<docnum>1178728</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180620</credat>
<cretim>16:01:54</cretim>
<docnum>1178732</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT121</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180621</credat>
<cretim>08:21:13</cretim>
<docnum>1178745</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT121</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180628</credat>
<cretim>10:17:25</cretim>
<docnum>1180138</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCR</mestyp>
<rcvprn>SR1CLNT121</rcvprn>
<statusCode>51</statusCode>
<statusMessage>& exceeded by & & &</statusMessage>
</element>
<element>
<credat>20180628</credat>
<cretim>10:19:32</cretim>
<docnum>1180139</docnum>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected]</emailidTo>
<field1>MATERIAL-111116</field1>
<field14>ENTRY_QNT-20.000</field14>
<field15>ENTRY_UOM-EA</field15>
<field2>PLANT-RU20</field2>
<field3>STGE_LOC-RU20</field3>
<field4>BATCH-E979A01</field4>
<field5>MOVE_TYPE-101</field5>
<idocStatus>Business Input Needed</idocStatus>
<mestyp>MBGMCL</mestyp>
<rcvprn>SR1CLNT120</rcvprn>
<statusCode>51</statusCode>
<statusMessage>Posting only possible in periods &1 and &2 in company code &3</statusMessage>
</element>
</root>
my desired result :
<root>
<element>
<rcvprn>SR1CLNT120</rcvprn>
<mestype>MBGMCR</mestype>
<emailidCc>[email protected]</emailidCc> <emailidTo>[email protected];[email protected]</emailidTo>
<docnum>
1177016
1177017
1177018
1177592
1177593
1178094
1178407
1178456
1178644
1178649
1178722
1178723
1178724
1178725
1178726
1178727
1178728
</docnum>
</element>
<element>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<rcvprn>SR1CLNT121</rcvprn>
<mestype>MBGMCR</mestype>
<docnum>
1178732
1178745
1180138
</docnum>
</element>
<element>
<emailidCc>[email protected]</emailidCc>
<emailidTo>[email protected];[email protected]</emailidTo>
<rcvprn>SR1CLNT120</rcvprn>
<mestype>MBGMCL</mestype>
<docnum>
1180139
</docnum>
</element>
</root>
Now i will say the grouping rules :
- docnum is the element to be grouped
- all docnum elements having same rcvprn and msgtyp values must be grouped in to one and their email id "to" and "cc" must be Unioned respectively with each other .
future requirement in future there may be couple of other feilds might get added to club the docnum feilds.
for-each-group
with an XSLT 1 processor so no idea why you link to an XSLT 1.0 article about nested grouping and claim it doesn't work, I don't see anyfor-each-group
in the older post you linked to. – Martin Honnen