Pergunta

I'm using a Java Transformer to convert XML into HTML. When I display the output, everywhere I had a newline string literal delimiter of "\n" in a field, there's simply a space. The only suggestion I've been able to find is:

transformer.setOutputProperty(OutputKeys.INDENT, "yes");

which didn't work. I cannot find anything in the JavaDocs for the TransformerFactory, or Transformer classes that addresses this issue. Any suggestions?

Foi útil?

Solução

I found the issue. The XSL that was specified for the Transformer included a call to the "normalize-space" function. See: http://www.xsltfunctions.com/xsl/fn_normalize-space.html

It was removing the newline and replacing it with a single space, as documented.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top