Need some help with this problem in implementing with XSLT, I had already implemented a Java code of this one using SAX parser, but it is a troublesome due to customer request to change something.
So we are doing it now using an XSLT with doesn't need to be compiled and deployed to a web server. I have XML like below.
Example 1:
<ShotRows>
<ShotRow row="3" col="3" bit="1" position="1"/>
<ShotRow row="3" col="4" bit="1" position="2"/>
<ShotRow row="3" col="5" bit="1" position="3"/>
<ShotRow row="3" col="6" bit="1" position="4"/>
<ShotRow row="3" col="7" bit="1" position="5"/>
<ShotRow row="3" col="8" bit="1" position="6"/>
<ShotRow row="3" col="9" bit="1" position="7"/>
<ShotRow row="3" col="10" bit="1" position="8"/>
<ShotRow row="3" col="11" bit="1" position="9"/>
</ShotRows>
Output 1:
<ShotRows>
<ShotRow row="3" colStart="3" colEnd="11" />
</ShotRows>
<!-- because the col is continuous from 3 to 11 -->
Example 2:
<ShotRows>
<ShotRow row="3" col="3" bit="1" position="1"/>
<ShotRow row="3" col="4" bit="1" position="2"/>
<ShotRow row="3" col="6" bit="1" position="3"/>
<ShotRow row="3" col="7" bit="1" position="4"/>
<ShotRow row="3" col="8" bit="1" position="5"/>
<ShotRow row="3" col="10" bit="1" position="6"/>
<ShotRow row="3" col="11" bit="1" position="7"/>
<ShotRow row="3" col="15" bit="1" position="8"/>
<ShotRow row="3" col="19" bit="1" position="9"/>
</ShotRows>
Output 2:
<ShotRows>
<ShotRow row="3" colStart="3" colEnd="4" />
<ShotRow row="3" colStart="6" colEnd="8" />
<ShotRow row="3" colStart="10" colEnd="11" />
<ShotRow row="3" colStart="15" colEnd="15" />
<ShotRow row="3" colStart="19" colEnd="19" />
</ShotRows>
The basic idea is to group any continuous col into one element, like the col 3 to 4, col 6 to 8, col 10 to 11, col 15 is only one, and col 19 is only one. Thanks in advance.