Compare the current and next node names using XPATH
0 1
In your XSL, if you need to test to see if the next element is named the same as the current one you can use the following piece of code to get the result using a combination of XPATH axes and the name() function.