EDIT: [it started with character replacement and I ended up with discovering string replacements with help of Dimitre Novatchev and Rol
The solution to the "prety-printed xml" is not really a solution.
Imagine having a document like this:
O M G
D I Y
The output from the currently accepted solution (after wrapping it in an
and adding the identity rule is:
%20
%20%20O$M$G
%20%20D$I$Y
%20
Now, why doesn't the proposed workaround save the situation? As we see from the above example, an element can have more than one child element that has text nodes...
What is the real solution?
The creators of XSLT have thought about this problem. Using the right terminology, we want all insignificant white-space-only text nodes to be ignored by the XSLT processor, as if they were not part of the document tree at all. This is achieved by the
Just add this at a global level (as a child of
and, for readability, before any templates):
and now you really have a working solution.