473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLTextWriter and decoding special characters.

Hello Everyone,
I have written a simple app. that converts the dataset into
excelspreadshee t.
The App. uses the following architecture.
First it generates the dataset with corresponding datatables(each
datatable represents a worksheet).It uses an Xslt file to do the
transformation of the xml (generate from dataset) and write the
output xml into a xmltextwriter.

The App converts the data into excel with almost all of the formatting
as desired with exception of few.

"In order to display a STRING VALUE into MULTIPLE ROWS WITH IN A CELL
Excel uses a value "
I am aware that xmlTextWriter does not support <xsl:output> not it
support <xsl: disable-output-formatting> tags and also that
xmltextwriter converts invalid characters(&) to a valid xml
characters(&amp ;) .

I am using UTF-8 encoding specified in the xmltextwriter.

This inbuilt behaviour is causing a formatting issue. As the
resulting xml has this character escaped(&amp;#1 0;) which is differnt
from ( ), the desired functionality is not achevied.

Any work around is greatly appriciated.

Regards,
Pranay Jain.
Nov 12 '05 #1
5 9146
Hello Everyone,
I got a work around of this problem. Instead of using a XmlTextWriter
, i tried using a StreamWriter(im plementaion of a TextWriter).
The StreamWriter allows the use of <disable-output-escaping> and
thereby retaining the value  

Now my Question is since i am handling huge amount of xml,
probably 50Mb-100Mb which writer is a better option and why?.

Abstracts from MSDN about both:-
The reason going to XMLTextwriter was that its was a forward-only way
of generating streams or files containing XML data and static (Shared
in Visual Basic) members are Mutlithreadsafe .

Regarding StreamWriter :
StreamWriter is designed for character output in a particular
Encoding, whereas classes derived from Stream are designed for byte
input and output.

Any public static (Shared in Visual Basic) members of this type are
safe for multithreaded operations

BUT By default, a StreamWriter is not thread safe.
Which one do you all recommend to use and if possible please write a
couple of lines why?.

Any insight will be of a great help. Thanks

Regards,
Pranay Jain.
pr************* @hotmail.com (Jain, Pranay Kumar) wrote in message news:<26******* *************** ****@posting.go ogle.com>...
Hello Everyone,
I have written a simple app. that converts the dataset into
excelspreadshee t.
The App. uses the following architecture.
First it generates the dataset with corresponding datatables(each
datatable represents a worksheet).It uses an Xslt file to do the
transformation of the xml (generate from dataset) and write the
output xml into a xmltextwriter.

The App converts the data into excel with almost all of the formatting
as desired with exception of few.

"In order to display a STRING VALUE into MULTIPLE ROWS WITH IN A CELL
Excel uses a value "
I am aware that xmlTextWriter does not support <xsl:output> not it
support <xsl: disable-output-escaping> tags and also that
xmltextwriter converts invalid characters(&) to a valid xml
characters(&amp ;) .

I am using UTF-8 encoding specified in the xmltextwriter.

This inbuilt behaviour is causing a formatting issue. As the
resulting xml has this character escaped(&amp;#1 0;) which is differnt
from ( ), the desired functionality is not achevied.

Any work around is greatly appriciated.

Regards,
Pranay Jain.

Nov 12 '05 #2
Jain, Pranay Kumar wrote:
Now my Question is since i am handling huge amount of xml,
probably 50Mb-100Mb which writer is a better option and why?.


I don't think there is any significant difference here, but using
TextWriter or even Stream is going to be slightly faster as it
eliminates one chain (XmlWriter) in the transformation pipeline. It
would be interesting to measure some real XML document transformations
though.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #3
Thanks Oleg,
Now when you say stream i am sure you mean MemoryStream and not
streamwriter as textwriter will include streamwriter.

Correct me if i am wrong, the transformed xml will be stored as an
xmldocument in the stream and to my best understanding the xmldocument
utilizes more memory then xpathdocuments and few more..
With MemoryStream i feel that it will cause a real performance issue
as we are trying to Transform huge amount of data on fly and you know
that .net handles Memory in two different buckets sizes and it may
force the aspnet_wp to recycle if it could not handle it.

That leaves the option of going to streamwriter which basically is a
implementaion of text writer hence my <xsl:> tags will not be ignored.
Do you think a streamwriter will cauase any issue with invalid
characters as it will not convert them to valid characters. Do i need
to make any special changes or setting with streamwriter so that it
just doesnot blow away any invalid characters that can come across?..

Any suggestion...
Again, Thanks for your reply.
Regards,
Pranay Jain
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message news:<uB******* *******@TK2MSFT NGP12.phx.gbl>. ..
Jain, Pranay Kumar wrote:
Now my Question is since i am handling huge amount of xml,
probably 50Mb-100Mb which writer is a better option and why?.


I don't think there is any significant difference here, but using
TextWriter or even Stream is going to be slightly faster as it
eliminates one chain (XmlWriter) in the transformation pipeline. It
would be interesting to measure some real XML document transformations
though.

Nov 12 '05 #4
Jain, Pranay Kumar wrote:
Correct me if i am wrong, the transformed xml will be stored as an
xmldocument in the stream and to my best understanding the xmldocument
utilizes more memory then xpathdocuments and few more.. The result of the transformation is just XML text (bytes) if you
transform to TextWriter or Stream. In XmlWriter case the result is
stream of XmlWriter.Write XXX() methods.
With MemoryStream i feel that it will cause a real performance issue
as we are trying to Transform huge amount of data on fly Real issue here is not output, but input (use XPathDocument) and XSLT
stylesheet itself (optimize it).
That leaves the option of going to streamwriter which basically is a
implementaion of text writer hence my <xsl:> tags will not be ignored.
Do you think a streamwriter will cauase any issue with invalid
characters as it will not convert them to valid characters.

Never. When transforming to TextWriter, xsl:output encoding attribute is
ignored and output is done in the TextWriter's encoding.
But wait, what do you mean saying "invalid character"?
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #5
Thanks Oleg,
I agree with your reply. I was thinking wrong w.r.t the memorystream
and the output format. Also w.r.t invalid characters i was referring
to &,<,>,',".
But i realised that the streamwriter writes with character encoding so
it should not be an issue. correct me if i am wrong here.

I have modified my code and now i am using a textwriter to output the
data.
My application works good now. Although , i run to a very basic issue.
How will you calculate the width of a string for excel column. There
is a tag
<ss:column> in which i can specify a fixed width. But i dont wanna
give a static value and i want to calculate the string width value.
Any suggestions??
Regards & Thanks
Pranay Jain.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!P LEASEtkachenko. com> wrote in message news:<On******* ******@TK2MSFTN GP11.phx.gbl>.. .
Jain, Pranay Kumar wrote:
Correct me if i am wrong, the transformed xml will be stored as an
xmldocument in the stream and to my best understanding the xmldocument
utilizes more memory then xpathdocuments and few more..

The result of the transformation is just XML text (bytes) if you
transform to TextWriter or Stream. In XmlWriter case the result is
stream of XmlWriter.Write XXX() methods.
With MemoryStream i feel that it will cause a real performance issue
as we are trying to Transform huge amount of data on fly

Real issue here is not output, but input (use XPathDocument) and XSLT
stylesheet itself (optimize it).
That leaves the option of going to streamwriter which basically is a
implementaion of text writer hence my <xsl:> tags will not be ignored.
Do you think a streamwriter will cauase any issue with invalid
characters as it will not convert them to valid characters.

Never. When transforming to TextWriter, xsl:output encoding attribute is
ignored and output is done in the TextWriter's encoding.
But wait, what do you mean saying "invalid character"?

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3959
by: steve | last post by:
Hi, I am opening a stream that is UTF encoded. I use fgetc to read the stream- which is binary safe. I add every character read to a string. But when I look at the stream, I see some characters with a bunch of "?" question markets, and then utf8_decode has no effect on it either. How do you go about decoding utf. Does adding the...
1
3034
by: Matthias Stern | last post by:
Hello! I've got a Javascript-PHP encoding problem. (1) Here is the short version: ============================== I'm sending a form textfield via Javascript(!) as URL parameter (GET) from one php-page to another and want to send all possible special
18
17470
by: LarsM | last post by:
Hi all, I am new to XML, but I use it for an RSS feed. I have one problem, which I have really been struggling with. My XML document is generated from the contents of a MySQL database. It is UTF-8 encoded. However, the Danish special characters appear wrong.
40
3170
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. However when you retrieve these values into a dataset and ToString() them
5
6139
by: reddy | last post by:
I am trying to insert a node into an XMLFile. using XMLTextwriter. My Question is Is it possible to do without using XMLDocument. Because its loading all the the file into memory. I just want to insert in the front. My code is give below. Is it possible to do without using XMLDOcument? Dim masterDoc As String =...
4
11493
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm having issues using XmlTextWriter, saving it out to a file with UTF8 encoding, and seeing "dirty", or "human unreadable" characters show up *right...
1
5748
by: rmgalante | last post by:
I have a Windows Service that reads and writes an XML file to disk periodically. I use the XmlSerializer to serialize and deserialize the XML file on disk. I am writing the file using an XmlTextWriter and UTF8 encoding. I notice after long periods of time that my file has bad, non-displayable characters. I try to load the XML file with IE,...
6
3088
by: kath | last post by:
Hi all, Platform: winxp Version: Python 2.3 I have a task of reading files in a folder and creating an one excel file with sheets, one sheet per file, with sheet named as filename. I am facing problem in handling special characters. I am using XLRD and XLW package to read/write from/to file. But facing problem in...
6
10129
by: clintonG | last post by:
Can anybody make sense of this crazy and inconsistent results? // IE7 Feed Reading View disabled displays this raw XML <?xml version="1.0" encoding="utf-8" ?> <!-- AT&T HTML entities & XML <elementsare displayed --> <rss version="2.0"> <channel> <title>AT&T HTML entities & XML <elementsare displayed</title> .... <description>
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7692
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7791
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5360
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3491
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.