473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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;34</input>
<input>12&#xA;3</input>
<input>12&#xA;34</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:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="input">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength 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 XmlValidatingReader object with the XmlReader.Normalization 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.Normalization property to true would eliminate these two errors, however that is not the case. The following error still exists even with the XmlReader.Normalization 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
0 987

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

Similar topics

3
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...
5
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...
2
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...
4
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...
8
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
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...
3
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...
5
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...
0
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...
8
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.