|
-
December 13th, 2004, 11:39 AM
#1
MSXML -> XSLT -> and bloody \r\r\n and where do they come from?
In my XSLT I want to convert an XML file in to text (csv) but a problem I'm getting is that when I want to put in a Carriage Return(\r) Line Feed(\n). No matter what I try I always get \r\r\n which is causing a problem with our import app.
I've tried all of these but with no luck
Code:
<xsl:output method="text" encoding="UTF-8" version="1.0"/>
with the '& #13;' and '& #10;' there is no space in the middle
Code:
<xsl:value-of select="IndexValue"/>,<xsl:value-of select="Action"/><xsl:text>& #13;& #10;</xsl:text>
Code:
<xsl:value-of select="IndexValue"/>,<xsl:value-of select="Action"/><xsl:text>& #13;</xsl:text>
Code:
<xsl:value-of select="IndexValue"/>,<xsl:value-of select="Action"/><xsl:text>& #10;</xsl:text>
Code:
<xsl:value-of select="IndexValue"/>,<xsl:value-of select="Action"/><xsl:text>
</xsl:text>
-
December 13th, 2004, 12:56 PM
#2
Re: MSXML -> XSLT -> and bloody \r\r\n and where do they come from?
I did a quick test (VBScript, Msxml2.DOMDocument.4.0) and & #13;& #10; in the XSL worked fine.
Any chance that:
* you are saving to a file opened in text mode (though & #10; should work then)
* there is a newline in the result of xsl:value-of?
Also, do you use DOMDocument.transformNode (that's what I tried) or DOMDocument.transformNodeToObject?
Last edited by Boris K K; December 14th, 2004 at 08:25 AM.
Boris Karadjov
Brainbench MVP for Visual C++
http://www.brainbench.com/
-
December 13th, 2004, 01:05 PM
#3
Re: MSXML -> XSLT -> and bloody \r\r\n and where do they come from?
Well thanks for actually trying it out
and that comment
>> * there is a newline in the result of xsl:value-of?
is very interesting but I'd be surprised if it was, but I'll have to check that out.
>>* you are saving to a file opened in text mode (though should work then)
I'm using
Code:
m_oOutputStream.open(csSaveName + ".csv", ios::app|ios::out);
I'm using DOMDocument.transformNode.
-
December 14th, 2004, 08:35 AM
#4
Re: MSXML -> XSLT -> and bloody \r\r\n and where do they come from?
I think the stream is opened in text mode if you do not specify ios::binary. But then only & #10; should work (and be converted by the stream to \r\n).
It would help to localize the problem if you check the value of the BSTR returned by transformNode with a debugger.
Boris Karadjov
Brainbench MVP for Visual C++
http://www.brainbench.com/
-
December 14th, 2004, 08:46 AM
#5
Re: MSXML -> XSLT -> and bloody \r\r\n and where do they come from?
We figured that out this morning but thanks any way Boris.
we figured out by see that the return from the transform had two pipes in it and then by testing different strings that had "\r\n", "\r", "\n", "\r\r\n" and had then figured it had some thing to do with the saving of the data.
One look in MSDN under CStdioFile and we found -> "Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0D, 0x0A) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte."
And as you saif we change the saving of the file to binary.
Thanks again Boris it was your "* there is a newline in the result of xsl:value-of?" that set me off thinking.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|