> child::*[not(name()=following::name)]" following::name means all of the the following nodes which are <name> elements. (And not even limited to following sibling).
You probably meant something more like name(following-sibling::*[1]) --- which checks the name of the next element sibling. There may be other errors; this is just the first one that jumped out at me. Reminder: the XSLT FAQ website has a lot of good examples. Worth studying.