Adding to the two nice answers of @AakashM and @Tomalak, this is done naturally in XSLT 2.0:
This XSLT 2.0 transformation:
when applied on the provided XML document:
produces the wanted result:
Do note how the XPath 2.0 to operator is used in the instruction.