protected String getFullFormattedXml ( final Node node , ComparisonType type , boolean formatXml ) { StringBuilder sb = new StringBuilder ( ) ; final Node nodeToConvert ; if ( type == ComparisonType . CHILD_NODELIST_SEQUENCE ) { nodeToConvert = node . getParentNode ( ) ; } else if ( node instanceof Document ) { Document doc = ( Document ) node ; appendFullDocumentHeader ( sb , doc ) ; return sb . toString ( ) ; } else if ( node instanceof DocumentType ) { Document doc = node . getOwnerDocument ( ) ; appendFullDocumentHeader ( sb , doc ) ; return sb . toString ( ) ; } else if ( node instanceof Attr ) { nodeToConvert = ( ( Attr ) node ) . getOwnerElement ( ) ; } else if ( node instanceof org . w3c . dom . CharacterData ) { // in case of a simple text node, show the parent TAGs: "<a>xy</a>" instead "xy". nodeToConvert = node . getParentNode ( ) ; } else { nodeToConvert = node ; } sb . append ( getFormattedNodeXml ( nodeToConvert , formatXml ) ) ; return sb . toString ( ) . trim ( ) ; }
Formats the node using a format suitable for the node type and comparison .