java implementation extended with xml formatting, fixed bug counting line breaks as nodes