Index: doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java =================================================================== --- doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java (revision 630220) +++ doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookParser.java (working copy) @@ -731,15 +731,27 @@ { String text = parser.getText(); - if ( StringUtils.isNotEmpty( text.trim() ) ) + /* + * NOTE: Don't do any whitespace trimming here. Whitespace normalization has already been performed by the + * parser so any whitespace that makes it here is significant. + */ + if ( StringUtils.isNotEmpty( text ) ) { - // emit separate text events for different lines - String[] lines = StringUtils.split( text, EOL ); + // Emit separate text events for different lines, e.g. the input + // "\nLine1\n\nLine2\n\n" should deliver the event sequence "\n", "Line1\n", "\n", "Line2\n", "\n". + // In other words, the concatenation of the text events must deliver the input sequence. + // (according to section 2.11 of the XML spec, parsers must normalize line breaks to "\n") + String[] lines = text.split( "\n", -1 ); - for ( int i = 0; i < lines.length; i++ ) + for ( int i = 0; i < lines.length - 1; i++ ) { - sink.text( lines[i] ); + sink.text( lines[i] + EOL ); } + + if ( lines[lines.length - 1].length() > 0 ) + { + sink.text( lines[lines.length - 1] ); + } } }