Re: [xsl] Identity question

Subject: Re: [xsl] Identity question
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 17 Jan 2001 18:52:36 +0000
Hi Chris,

The usual question would be:

  Why am I getting <Child></Child> instead of <Child />

And the usual answer would be 'it doesn't make any difference which of
these is used - they're logically equivalent - and this level of
detail about the way the output is serialised cannot be affected by

*However*, what you're getting (and what I get when I try it too) is:


This is different from <Child /> because The Child element here has a
text node in there with a carriage return in it. If you read this in
again (with another processor - MSXML ignores whitespace-only text
nodes by default) then you wouldn't have an empty element. There's
nothing in the identity template to create this whitespace. So, this
is actually a bug in MSXML - they're fairly rare on the ground these
days, so well spotted! :)

Turns out you can get around it by adding the template:

<xsl:template match="*[not(node())]">
   <xsl:copy-of select="." />

In other words, make a direct copy of any element that doesn't have
any children.

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread