Re: [xsl] Closing element required instead of self closing

Subject: Re: [xsl] Closing element required instead of self closing
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 16 Jul 2008 16:38:55 +0200
Michael Kay wrote:
This is my Client requirement.

Then please pass my question on to your client: why is this needed?

To try to put this back on track for the OP (who wasn't asking about XHTML imho). I can think of at least one use-case where this is important: when you want to diff the differences between to XML files (for instance by comparing hash keys) it's arguably easier to have them created using the same style. (though I'd agree that comparing XML should be done in a different manner).


If this is the use-case for the OP (but I am guessing), a possible, highly trivial solution is to simply parse XML A and XML B with a (full) identity transform and compare them afterwards.

Yet, since the OP is using Saxon 9, and if comparing is what he's after, he could consider using deep-equal() as well.

To really answer the original question 1:1, that is possible using XSLT 2.0 the same way you would do it with Perl / PHP etc. Use unparsed-text() to open XML A / B and output them as text again after regex'ing the minimized tags. Seems to me far simpler than any of the other options mentioned, but of course, this is quite an abuse of XSLT for something fairly trivial in any sed oneliner.

HTH,
Cheers,
-- Abel --

Current Thread