I am new to XML and XSLT and I have an input document, where I want to extract the elements with the prefix p , T and C and count number of serial with root SKU and list. I tried lots of ways but am unable to get it to work and need some help/suggestions.
- In my XSLT I copy all the elements with the safix ppp to the output file.
- In my XSLT I copy all the elements with the safix c00 to the output file.
- In my XSLT I copy all the elements with the saefix t0 to the output file.
Any help is very much appreciated.
Thank you and looking forward for responses.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0001</serial>
</row>
<row>
<product.name>iPadMini</product.name>
<category>tablet</category>
<serial>T0001</serial>
</row>
<row>
<product.name>iPadMini</product.name>
<category>tablet</category>
<serial>T0002</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0002</serial>
</row>
<row>
<product.name>iMacPro</product.name>
<category>computer</category>
<serial>C0001</serial>
</row>
<row>
<product.name>iMacPro</product.name>
<category>computer</category>
<serial>C0002</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0003</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0004</serial>
</row>
<row>
<product.name>iPhoneX</product.name>
<category>phone</category>
<serial>P0005</serial>
</row>
The expected output is in the below format:
<?xml version="1.0" encoding="UTF-8"?>
<Inventory>
<SKU>
<category>phone</category>
<product.name>iPhoneX</product.name>
<product.count>5</product.count>
<list>P0001</list>
<list>P0002</list>
<list>P0003</list>
<list>P0004</list>
<list>P0005</list>
</SKU>
<SKU>
<category>tablet</category>
<product.name>iPadMini</product.name>
<product.count>2</product.count>
<list>T0001</list>
<list>T0002</list>
</SKU>
<SKU>
<category>computer</category>
<product.name>iMacPro</product.name>
<product.count>2</product.count>
<list>C0001</list>
<list>C0002</list>
</SKU>
</Inventory>
I tried lots of ways, but am unable to get it to work and need some help/suggestions.
Any help is very much appreciated.
Thank you and looking forward for responses.
What can I do?