This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Identity question


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
XSLT'.

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

<Child>
</Child>

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="." />
</xsl:template>

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

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]