It looks like what's happening here is that IE is performing the XML end of line handling on not just the input XML but also on the XSLT. Just try executing this in IE (with any input XML):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:fn="fn"
exclude-result-prefixes="fn msxsl">
<xsl:output method="xml" indent="yes"/>
<msxsl:script implements-prefix="fn">
function charCodes(str) {
var result = '';
for(var i = 0; i < str.length; i += 1) {
result += str.charCodeAt(i) + " ";
}
return result;
}
</msxsl:script>
<xsl:template match="/">
<html>
<body>
<xsl:if test="function-available('fn:charCodes')">
<div>
<xsl:text>Char code for xA: </xsl:text>
<xsl:value-of select="fn:charCodes('
')"/>
</div>
<div>
<xsl:text>Char code for xD: </xsl:text>
<xsl:value-of select="fn:charCodes('
')"/>
</div>
<div>
<xsl:text>Char code for xDxA: </xsl:text>
<xsl:value-of select="fn:charCodes('
')"/>
</div>
</xsl:if>
<div>
<xsl:text>String length of xDxA: </xsl:text>
<xsl:value-of select="string-length('
')"/>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The result this produces in IE 10 when I try it is:
Char code for xA: 10
Char code for xD: 10
Char codes for xDxA: 10
String length of xDxA: 1
So all xDxA
s and xD
s are being replaced with xA
, and I think that explains perfectly the behavior you have been witnessing.
Incidentally, executing the same script in Firefox produces:
String length of xDxA: 2
And that explains what you saw in Firefox.
One final thing to note is that I can reproduce the above behavior in IE, but not in Visual Studio's XSLT functionality, so it seems that this behavior is present in some implementations of MSXSL, but not all of them.