Get Java to use tabs instead of spaces for indentation

I am creating an XML document. I got indented using TransformerFactory.setAttribute("indent-number", new Integer(2)); Transformer.setOutputProperty(OutputKeys.INDENT, "yes");

Is it possible to force Java to use tabs instead of spaces for indentation? And How?

+5
source share
3 answers

No, not in general. The XSLT specification does not allow WHIT spaces to be used for indentation.

However, it can be customized for a specific element of the XSLT processor. Check the documentation for the one you are using.

If you really want this, you can use the XSLT script burner at the output, which does everything you want to do on the text () nodes.

+2
source

, . , TransformFactory , ContentHandler. ContentHandler SAXResult-pass, "" Transformer.transform(...). , . -XSLT .

+1

, .

, str.replace("\n ", "\n\t") ( , ).

- .

0

All Articles