improved formatting for auto-trim function

whitespace in xpath expressions, text nodes, comment nodes and xpath
comments is
preserved even when trimming whitespace to tidy the xml indentation