Sunday, 7 December 2014

Sum based on Element attribute in XSLT transformation



I am new to XSLT and facing a problem in transformation of XML. I need to transform an output in text file as with ',' seperated.


Need Help to do the total based on type Descriptor.


Output should lokk like:





Co code, ID, type, amount
DEEP1, 12345, phone, 14
DEEP1, 12345, food, 8
DEEP1, 12346, phone, 16



XML:



<Root>
<Employees>
<Employee>
<Co_Code>DEEP1</Co_Code>
<ID>12345</ID>
</Employee>
<Type Descriptor="Phone"></Type>
<amount>8</amount>
</Employees>
<Employees>
<Employee>
<Co_Code>DEEP1</Co_Code>
<ID>12345</ID>
</Employee>
<Type Descriptor="Phone"></Type>
<amount>6</amount>
</Employees>
<Employees>
<Employee>
<Co_Code>DEEP1</Co_Code>
<ID>12345</ID>
</Employee>
<Type Descriptor="Food"></Type>
<amount>8</amount>
</Employees>
<Employees>
<Employee>
<Co_Code>DEEP1</Co_Code>
<ID>12346</ID>
</Employee>
<Type Descriptor="Phone"></Type>
<amount>8</amount>
</Employees>
<Employee>
<Co_Code>DEEP1</Co_Code>
<ID>12346</ID>
</Employee>
<Type Descriptor="Phone"></Type>
<amount>8</amount>
</Employees>
</Root>


Thanks a ton in Advance.Any useful link or snipeet code will be much appreciated ,Please let me know if need more information.


No comments:

Post a Comment