I think it would be helpful to see how you are using XML::LibXSLT. Maybe the problem is there, and at the very least it would enable us to reproduce the problem. It looks like there might be an issue when you have entities with no content (i.e. <line></line> or <text></text>) but that's just a guess.