输入:
<Move-Afile>
<Afile>
<HEAD010->
<Receiver>7612460142409</Receiver>
<ASN>ASN</ASN>
<Sender>8712423011212</Sender>
</HEAD010->
<HEAD020->
<DeliveryNoteNumber>6125175001</DeliveryNoteNumber>
<DeliveryNoteDate>2013-05-16</DeliveryNoteDate>
</HEAD020->
<HEAD030->
<BookingTimestamp></BookingTimestamp>
<BookingReference>F234</BookingReference>
</HEAD030->
<DELH030->
<DeliveryAddressNumber></DeliveryAddressNumber>
</DELH030->
<DELH040->
<CustomerName>Office Customer</CustomerName>
<Address1>.</Address1>
</DELH040->
<DELH050->
<Address2->Silbernstrasse 20</Address2->
<City>CH-8953 Dietikon</City>
<PostalCode>8953</PostalCode>
</DELH050->
<ITEM010-> <!--....... unbounded element.... -->
<SupplierProductCode>4401896</SupplierProductCode>
<ITEM020->
<ItemDescription>FUSION LAMINATOR BUNDLE</ItemDescription>
</ITEM020->
<ITEM030->
<EANItemCode>5028252380935</EANItemCode>
</ITEM030->
<ITEM040->
<CustomerItemNumber>13627200</CustomerItemNumber>
</ITEM040->
<ITEM060->
<MovexOrderNumber>6125175</MovexOrderNumber>
<OrderDate>13/05/13</OrderDate>
</ITEM060->
<PACK010->
<PackageType>PACKAGE/CARTON</PackageType>
</PACK010->
<PACK020->
<PackageNumber>9797</PackageNumber>
</PACK020->
<PACK050->
<PackNumber>PLT9180267</PackNumber><!-- for each <PackNumber> if <PackNumber> we are performing logic -->
</PACK050->
</ITEM010->
<ITEM010-> <!--....... unbounded element.... -->
<SupplierProductCode>4401896</SupplierProductCode>
<ITEM020->
<ItemDescription>FUSION LAMINATOR BUNDLE</ItemDescription>
</ITEM020->
<ITEM030->
<EANItemCode>5028252312343</EANItemCode>
</ITEM030->
<ITEM040->
<CustomerItemNumber>13627200</CustomerItemNumber>
</ITEM040->
<ITEM060->
<MovexOrderNumber>6125175</MovexOrderNumber>
<OrderDate>13/05/13</OrderDate>
</ITEM060->
<PACK010->
<PackageType>PACKAGE/CARTON</PackageType>
</PACK010->
<PACK020->
<PackageNumber>9797</PackageNumber>
</PACK020->
<PACK050->
<PackNumber>PLT9763411</PackNumber><!-- for each <PackNumber> if <PackNumber> we are performing logic -->
</PACK050->
</ITEM010->
<ITEM010-> <!--....... unbounded element.... -->
<SupplierProductCode>4401896</SupplierProductCode>
<ITEM020->
<ItemDescription>FUSION LAMINATOR BUNDLE</ItemDescription>
</ITEM020->
<ITEM030->
<EANItemCode>5028252888777</EANItemCode>
</ITEM030->
<ITEM040->
<CustomerItemNumber>13627200</CustomerItemNumber>
</ITEM040->
<ITEM060->
<MovexOrderNumber>6125175</MovexOrderNumber>
<OrderDate>13/05/13</OrderDate>
</ITEM060->
<PACK010->
<PackageType>PACKAGE/CARTON</PackageType>
</PACK010->
<PACK020->
<PackageNumber>9797</PackageNumber>
</PACK020->
<PACK050->
<PackNumber>PLT9180267</PackNumber><!-- for each <PackNumber> if <PackNumber> we are performing logic -->
</PACK050->
</ITEM010->
<TAIL010->
<NumberOfLines>4</NumberOfLines>
</TAIL010->
</Afile>
</Move-Afile>
对于每个 <PackNumber>
我们正在执行的逻辑。如果<PackNumber>
不同,我们必须增加计数器,并且属于相同的节点<PackNumber>
位于该计数器之下。
输出:
<A>
<target>
<d1>7612460142409</d1><!-- value of <Receiver> element -->
<d2>81</d2><!-- Hard code value -->
<d3>6125175001</d3> <!-- <DeliveryNoteNumber> value -->
<d4>F234</d4><!-- <BookingReference> value -->
<d5>Office Customer</d5><!-- <CustomerName> value -->
<d6>102</d6><!--hard code value -->
<!-- for-each <PackNumber> the following will come -->
<CPS>
<element1>2</element1><!-- if previous <PackNumber> is not equal to current <PackNumber> increment the count(starting from 2)-->
<element2>1</element2><!-- hard code value-->
</CPS>
<PAC>
<element4>111</element4><!-- hard code value-->
<element5>012</element5><!-- hard code value-->
</PAC>
<LIN>
<element6>1</element6><!-- sequence number start feom 1-->
<element7>SV</element7><!-- hard code value-->
<element8>5028252380935</element8><!-- <EANItemCode> -->
<PackNumber>PLT9180267</PackNumber>
</LIN>
<!-- same <PackNumber> is present in two nodes so another LIN element also comes under same CPS elment -->
<LIN>
<element6>2</element6><!-- sequence number incremented-->
<element7>SV</element7><!-- hard code value-->
<element8>5028252888777</element8><!-- <EANItemCode> -->
<PackNumber>PLT9180267</PackNumber>
</LIN>
<CPS>
<element1>3</element1><!-- if previous <PackNumber> is not equal to current <PackNumber> increment the count-->
<element2>1</element2><!-- hard code value-->
</CPS>
<PAC>
<element4>111</element4><!-- hard code value-->
<element5>012</element5><!-- hard code value-->
</PAC>
<LIN>
<element6>3</element6><!-- sequence number incremented-->
<element7>SV</element7><!-- hard code value-->
<element8>5028252312343</element8><!-- <EANItemCode> -->
<PackNumber>PLT9763411</PackNumber>
</LIN>
</target>
</A>