473,797 Members | 3,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

End-of-line Handling in the XmlReader (.NET Framework Version 1.1)

According to the XML 1.0 (Third Edition) W3C Recommendation (http://www.w3.org/TR/2004/REC-xml-20...#sec-line-ends) all #xD, #xA, and #xD#xA character combinations should be converted to a single #xA character.

According to the "Reading XML with the XmlReader" section of the ".NET Framework Developer's Guide" on-line help, the XmlReader will not perform this normalization by default. You can cause the XmlReader to perform this normalization by setting the Normalization property to true. This does not appear to be the case in every situation. The test below was performed using the .NET Framework Version 1.1.

Sample XML File:
<?xml version="1.0"?>
<test>
<input>12345</input>
<input>12
3</input>
<input>12
34</input>
<input>12&#xD;& #xA;3</input>
<input>12&#xD;& #xA;34</input>
<input>12&#xD;3 </input>
<input>12&#xD;3 4</input>
<input>12&#xA;3 </input>
<input>12&#xA;3 4</input>
</test>

Sample XSD Schema File:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<xsd:element name="test">
<xsd:complexTyp e>
<xsd:choice minOccurs="0" maxOccurs="unbo unded">
<xsd:element name="input">
<xsd:simpleType >
<xsd:restrictio n base="xsd:strin g">
<xsd:maxLengt h value="5"/>
</xsd:restriction >
</xsd:simpleType>
</xsd:element>
</xsd:choice>
</xsd:complexType >
</xsd:element>
</xsd:schema>

If the XML File above is loaded using a XmlReader and a XmlValidatingRe ader object with the XmlReader.Norma lization property to false, the following two errors are generated:

Error 1:
The 'input' element has an invalid value according to its data type. An error occurred at file: Test Case.xml, (7, 5).
<input>12
34</input>
^

Error 2:
The 'input' element has an invalid value according to its data type. An error occurred at file: Test Case.xml, (9, 25).
<input>12&#xD;& #xA;34</input>
^

These errors are expected since the input file was not normalized and the <input> element can only be 5 characters long. One would assume that setting the XmlReader.Norma lization property to true would eliminate these two errors, however that is not the case. The following error still exists even with the XmlReader.Norma lization property set to true:

Error 1:
The 'input' element has an invalid value according to its data type. An error occurred at file: Test Case.xml, (9, 25).
<input>12&#xD;& #xA;34</input>
^

It appears as if the XmlReader does not perform normalization if the CR-LF appears as a &#xD;&#xA;. Am I misinterpreting the XML specification or is the XmlReader not handling this case properly?

----------------------------------------------------------------------------
Excerpt from the XML 1.0 (Third Edition) W3C Recommendation (http://www.w3.org/TR/2004/REC-xml-20...ec-line-ends):

2.11 End-of-Line Handling
XML parsed entities are often stored in computer files which, for editing convenience, are organized into lines. These lines are typically separated by some combination of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).

To simplify the tasks of applications, the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character.

Nov 12 '05 #1
1 5363
you are wrong.
the spec. says the translation occurs "before parsing".
so, before parsing, &#xD;&#xA; are not line-break sequence.
Nov 12 '05 #2

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

Similar topics

3
5284
by: Matt | last post by:
I always heard people saying IIS ASP front end, and MS-SQL back end. ASP is for server side programming and dynamic content generation, how could it is called front end? Because I thought it is executed in the server, which is back end? I think I am confused with the term front end and back end here. Please advise. Thanks!!
5
10792
by: mitchchristensen | last post by:
I have a transaction log that tracks issues from a call center. Each time an issue is assigned to someone else, closed, etc. I get a time stamp. I have these time stamps for the beginning of an issue to the end of an issue and I'd like to determine how many business hours these issues were open. Issue BeginDt Enddt Total hours 1 3/29/05 5:00 PM 4/1/05 2:00 PM 69 ...
2
4506
by: Jeff Pritchard | last post by:
Some time ago I am sure I came across something that said this was possible, though it doesn't seem to work. A client wants to replace an Access back-end with SQL Server tables. We have tried linking the SQL tables to an Access back-end and then linking the linked tables in the Access back-end to the Access front-end. Doesn't work at all. Obviously, this can't be done. What is the best way to replace an Access back-end with SQL tables?
4
2810
by: John Baker | last post by:
Hi: I have an application that has a back end and a front end. I need to add a table which is identical to one in the back end, and then use it for a temporary holing place form some records. I have done the following: .. Copied the table in the back end and given the copy a new name .. Created a table with the identical name to the back end copy in the front end .. Used the linkage process to link the table reference in the front end...
8
1482
by: Murt | last post by:
on my inbox below i want the loop to quit if the user enters End, It does not function as written, any ideas? thanks ---------------------- Dim inputString As String
5
1265
by: Ashish | last post by:
Hi, please take a look at the following code. (I've ommitted the Windows generated code) -------------------------------- Imports System.Drawing.Drawing2D Public Class Form1 Inherits System.Windows.Forms.Form Dim points() As Point = {} Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255)) Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
3
2037
by: oktave | last post by:
Hi, Anybody would like to tell me ther defference between Application.Exit() and End? I can use End to end my application no matter how many forms and codes after the End statement. But since I change the End statement to Application.Exit(), the codes after the statement still been executed. So,
5
1223
by: Bob | last post by:
My app shows a modal MDI parent form, and creates a timer that ticks every ten minutes to boot unresposive users at 3 in the morning. Below is a simplified working example with no time check. My question is, is it OK to use End or it is there a cleaner way to close the app? Keep in mind that I want everything taken down, including any warning dialogue box shown from the timer, and any others that happen to be still open in the MDI parent...
0
1242
by: shapala | last post by:
Hi all! Can anybody help me with this problem: I have a database splited with to front-end back end application. At front end I have a form who contains combo box. This combo has row source to a table in back-end database (it give me all records). All is OK - back end database is not locked, but when I click in this combo, back end databse is locking by Me???. My question is there way to select data from this combo without to lock back-end...
8
1807
by: JohnC | last post by:
RE: Access 2003 My application has been split and the front end runs on client PCs with the back end on a LAN file server. Also I have an updater routine that copies an updated client from the LAN file server to the client PCs when needed. I keep the client front end on the LAN server for distribution purposes. The problem is that occasionally, user's get confused and go to the LAN file server and run the application from the front end...
0
9685
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10245
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5458
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.