The issue got resolved by changing to xsl:output method="xml" which was initially xsl:output method="html".But I still wonder  how it worked with Saxon8.4.

As I explained, this was a change made in Saxon to implement a W3C decision. Saxon 8.4 came out long before the XSLT 2.0 specification was finalized, and there were many changes made to the product as the W3C specification evolved.

Michael Kay