To eliminate everything that looks like indentation, you may need to (this means that there are times when you need to) use both <xsl:strip-space> and `` indent = "no" .
The simplest example : you have an identity transformation. Without either of these two methods, the conversion will only reproduce text nodes with a space from the source XML document. That is, if the source XML document is indented, the conversion will also indent the result.
Now add this conversion <xsl:output indent="no" /> . . This instructs the XSLT processor not to do "pretty-printed." However, whitespace-only nodes from the source XML document are still copied to the output file, and the resulting document appears to be indented (since the source document is indented).
Now, as a last step, add <xsl:strip-space elements="*"/> . . You have indicated both methods of preventing the appearance of only white spaces in the output. What's happening? On the XSLT processor, only nodes with "white space" are not processed at all, and it does not deviate from the output - you get the desired single-line dense output.
Finally, do a regression, change the value of <xsl:output indent="no" /> to <xsl:output indent="yes" /> . <xsl:strip-space elements="*"/> still exists, so only nodes with spaces are not output. But the XSLT processor obeys the <xsl:output indent="yes" /> directive and adds its own read-only text nodes.
Thus, of the four possible combinations, only specifying both <xsl:strip-space elements="*"/> and <xsl:output indent="no" /> ensures that the indentation is not called from the node nodes or from the source XML document, nor from the XSLT processors.
Even this last case, of course, does not fully guarantee that the output will not be indented - if the XSLT programmer intentionally puts the indentation code there, for example
<xsl:text>
</xsl:text>
output will contain this indent.
Dimitre novatchev
source share