471,582 Members | 1,361 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

differences between XslTransform and XslCompiledTransform

when switching from the old "XslTransform " to "XslCompiledTransform"
I notice a difference in the handling of whitespace. I need to transform
a XML file which contain tabs (\t), and which remain untouched when I
use XslTransform to do the transformation.
But after switching to XslCompiledTransform the tabs are transformed to
a single space in the result file, which leads to problems later on the
the program.

what I found was:
http://blogs.msdn.com/xmlteam/articl...Transform.aspx

which states:

"To load the cache, XslCompiledTransform uses XmlReader to read the
input document. At this time, XslCompiledTransform applies whitespace
stripping rules."

So What I tried:

- added a <xsl:preserve-space elements="_element_name"/> to the
stylesheet. I tried various Element names, but this didn't seem to make
any difference (or I made a mistake?)

- tried using a XmlReader with "IgnoreWhitespace":

XmlReaderSettings rs = new XmlReaderSettings();
rs.IgnoreWhitespace = false;
reader = XmlReader.Create(filePath, rs);
m_XslTransform.Transform(reader, new System.Xml.Xsl.XsltArgumentList(), ms);

Both of which resultet in the same: all tabs are gone.

Is there something I can do, or do I have to stay with XslTransform?

Thanks,

Ecki
Dec 2 '05 #1
3 3982
I found the solution for myself.

By default the XslCompiledTransform uses a XmlReader, which allways does
Normalizaion. But you can force the "old" behaviour by just giving it
a XmlTextReader instance to the transform method.
XmlTextReader does per default no normalization.

Remark: Seems like we never should have used tabs in Attribute Values to
start with.

Eckhard Schwabe wrote:
when switching from the old "XslTransform " to "XslCompiledTransform"
I notice a difference in the handling of whitespace. I need to transform
a XML file which contain tabs (\t), and which remain untouched when I
use XslTransform to do the transformation.
But after switching to XslCompiledTransform the tabs are transformed to
a single space in the result file, which leads to problems later on the
the program.

Dec 3 '05 #2
You might also want to check out this blog post:
http://blogs.msdn.com/xmlteam/articl...Transform.aspx

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

"Eckhard Schwabe" <es******@web.de> wrote in message
news:%2*****************@TK2MSFTNGP15.phx.gbl...
I found the solution for myself.

By default the XslCompiledTransform uses a XmlReader, which allways does
Normalizaion. But you can force the "old" behaviour by just giving it a
XmlTextReader instance to the transform method.
XmlTextReader does per default no normalization.

Remark: Seems like we never should have used tabs in Attribute Values to
start with.

Eckhard Schwabe wrote:
when switching from the old "XslTransform " to "XslCompiledTransform"
I notice a difference in the handling of whitespace. I need to transform
a XML file which contain tabs (\t), and which remain untouched when I use
XslTransform to do the transformation.
But after switching to XslCompiledTransform the tabs are transformed to a
single space in the result file, which leads to problems later on the the
program.

Dec 5 '05 #3
Hello Stan,

Stan Kitsis [MSFT] wrote:
You might also want to check out this blog post:
http://blogs.msdn.com/xmlteam/articl...Transform.aspx


I think I read this article before, but it should be updated to clearly
state that the normalization behaviour is changed since XslTransform.

Regards,

Eckhard

Dec 11 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by cody | last post: by
1 post views Thread by Praveen | last post: by
1 post views Thread by Mark | last post: by
1 post views Thread by =?Utf-8?B?d2VqaXY=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.