I have noticed a difference in the processing of XSL transforms between
dotnet and MSXML. Dotnet formats the resulting output differently, and since
we use the <pre> tag in the HTML output it makes a big difference.
What is in fact correct here? I don't see that the XSL transform engine
should reformat the output in this way, and would like to know if this
difference is going to remain in future.
The transform in question can be split down into the following:
XML:
<?xml version="1.0" encoding="Windows-1252"?>
<?xml-stylesheet type="text/xsl" href="./test1.xsl"?>
<outer xml:space="preserve">
<inner> Text 1 </inner>
<inner> Text 2 </inner>
</outer>
XSL:
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html"/>
<xsl:template match="outer">
<html>
<pre>
<xsl:apply-templates select="inner"/>
</pre>
</html>
</xsl:template>
<xsl:template match="inner">
<font color="#ff0000"><xsl:value-of select='.'/></font><nobr/>
</xsl:template>
</xsl:stylesheet>
The HTML resulting from this from MSXML is:
<html>
<pre>
<font color="#ff0000"> Text 1 </font><nobr></nobr><font color="#ff0000">
Text 2 </font><nobr></nobr></pre>
</html>
and from dotnet:
<html>
<pre>
<font color="#ff0000"> Text 1 </font>
<nobr>
</nobr>
<font color="#ff0000"> Text 2 </font>
<nobr>
</nobr>
</pre>
</html>
and obviously these look quite different in a browser.
Thanks for any suggestions,
Peter 7 2068
Hi Peter,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that the result of XSLT from MSXML and .NET
XML makes much difference. If there is any misunderstanding, please feel
free to let me know.
Based on the result you have provided, these two HTML are actually the
same. .NET XML adds a return behind each element. If you open the result
HTML in Internet Explorer or other browsers, it will display the same thing.
HTH.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Hallo Kevin, First of all, I would like to confirm my understanding of your issue. From your description, I understand that the result of XSLT from MSXML and .NET XML makes much difference. If there is any misunderstanding, please feel free to let me know.
Yes, that is exactly the problem.
Based on the result you have provided, these two HTML are actually the same. .NET XML adds a return behind each element. If you open the result HTML in Internet Explorer or other browsers, it will display the same thing.
No, they are very different. I assume you have not looked at the result of
transform in a browser. As you say, the dotnet result is formatting the
result, the MSXML result is not.
As we are using the <pre> in HTML statement this changes the look of the
output by adding a carriage return at the end of each line.
In the HTML samples I provided, the line beginning with the <font> tag is
produced on a single line, it only looks split due to the limited space here.
If you try copying these results into two HTML file and loading them you will
see what I mean.
. .NET XML adds a return behind each element
And to reiterate, this is then displayed by the <pre> tag, and that is
exactly my problem.
Peter
Hi Peter,
Thanks for pointing me out!
XSL Transformations (XSLT) uses the XML Document Object Model (DOM), not
the source document, to guide its transformation. Because the white space
has already been stripped to process the XML into the DOM, white space
characters are lost even before the transformation takes place. Most of the
XSLT-related methods for specifying white space in the source data document
or style sheets are applied too late to make a difference in formatting.
So could you please try to set preserveWhiteSpace property to true before
loading and saving to file? I think this might resolve the problem you're
facing.
HTH.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Hallo Kevin,
Thanks for the suggestion. However, if you check the original XML, this is
already set:
<outer xml:space="preserve">
Just to be certainI also tried setting the "preserveWhiteSpace" flag in the
code and as expected it makes no difference.
I would rather need an option "disableOutputFormatting" on the transform
object since that is causing the trouble. Is anything like that available or
planned?
Thanks,
Peter
"Kevin Yu [MSFT]" wrote: Hi Peter,
Thanks for pointing me out!
XSL Transformations (XSLT) uses the XML Document Object Model (DOM), not the source document, to guide its transformation. Because the white space has already been stripped to process the XML into the DOM, white space characters are lost even before the transformation takes place. Most of the XSLT-related methods for specifying white space in the source data document or style sheets are applied too late to make a difference in formatting.
So could you please try to set preserveWhiteSpace property to true before loading and saving to file? I think this might resolve the problem you're facing.
HTH.
Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
Hi Peter,
I think this is the default behavior of MSXML. I'm not quite sure if there
will be any changes to this. But I will try to forward your feedback to the
product team. Thank you!
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Hello Kevin,
Just to clear up any confusion. I think this is the default behavior of MSXML.
1) Yes, I know that is the default behaviour of MSXML.
2) That is GOOD. I have no problems with MSXML
3) It is NOT the default behaviour of dotnet.
4) I have a problem with dotnet.
If you are able to forward the request to anyone, please ask the dotnet team
to make the transform work the same way as MSXML, or at least offer an option
to enable this compatibility.
In the meantime we will unfortunately remove have to remove our dotnet
support and recommend our customers do the same.
Thanks and best regards,
Peter
"Kevin Yu [MSFT]" wrote:
Hi Peter,
I think this is the default behavior of MSXML. I'm not quite sure if there will be any changes to this. But I will try to forward your feedback to the product team. Thank you!
Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
Thanks, Peter. I will do that. Thanks again for your feedback.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights." This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KathyB |
last post by:
If someone could just explain this to me...I just don't get it!
I have an aspx page where I retrieve several session variables and use
xmlDocument to transform xml file with xsl file into an...
|
by: b0yce |
last post by:
Hi Group,
I think I have found a problem with the <xsl:element> when being
transformed by the .NET xmlTransform class. When using XmlSpy for
development and debugging, the <xsl:number>...
|
by: Jason S |
last post by:
Hello Group,
I am just about tearing my hair out with this one and thought someone may
have some insight. I have a transform that wasn't working so I grabbed the
nearest debugger (xselerator)...
|
by: Daniel |
last post by:
Are the differences between MSXML and .Net XSL transformation documented
online anywhere? Many of my XSL's work in MSXML but transform differently in
..Net XSL transformation.
|
by: tcdevelopment |
last post by:
I have a XSLT file that gives expected results when I transform using MSXML
V4.0 in a simple vbs file. However when using XslTransform in dotnet, I do
not get the same results.
The part of the...
| |
by: Danny Lesnik |
last post by:
Hi i have my XML file c:\prd.xm
<?xml-stylesheet type="text/xsl" href="prd.xsl"?><products><product><a>2</a><b>3</b></product><product><a>4</a><b>2</b></product></products
This is my XSL file...
|
by: KathyB |
last post by:
Hi, I've been reading conflicting posts, etc., could someone please
explain to me if msxml is used by asp.net to transform xml using an
xsl stylesheet?
If msxml is NOT used, CAN it be...i.e.,...
|
by: Peter |
last post by:
I have noticed a difference in the processing of XSL transforms between
dotnet and MSXML. Dotnet formats the resulting output differently, and since
we use the <pre> tag in the HTML output it makes...
|
by: Michael Nemtsev |
last post by:
Any kind of differences?
Were they buid on the common base or different?
--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |