Factorize out the XSLT code and improve the comments.
Add Javadoc comment.
Refactored to have reusable classes.