Say I have a very simple XML with an empty tag \'B\':
foo
bar
It's 7 years late, but for future readers I will buck the trend here and propose an actual solution to the original question. A solution that does not modify the original with spaces or the output directive.
The idea was to use an empty variable to trick the parser.
If you only want to do it just for one tag B, my first thought was to use something like this to attach a dummy variable.
But I found that in fact, even the dummy variable is not necessary. This preserved empty tags, at least when tested with xsltproc in linux :
For a more generic solution to handle ALL empty tags, try this:
Again, depending on how smart your parser is, you may not even need the dummy variable.