473,405 Members | 2,338 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,405 software developers and data experts.

Validating XML file

I receive a XML file from a customer and want to use a schema for validating
the XML file. What I don't know how to do is, that I want to continue
processing this XML - file no matter if there is an error or not.

e.g. I have an element <Code> which can contain values 1 to 9.

If something else is delivered within the XML file, I want to replace this
wrong value with the default 1.

Is this possible within the schema definition, or do I have to treat this
in my program.

Thanks
Uwe


Nov 12 '05 #1
3 1471
Uwe Kuhne wrote:
I receive a XML file from a customer and want to use a schema for validating
the XML file. What I don't know how to do is, that I want to continue
processing this XML - file no matter if there is an error or not.

e.g. I have an element <Code> which can contain values 1 to 9.

If something else is delivered within the XML file, I want to replace this
wrong value with the default 1.

Is this possible within the schema definition, or do I have to treat this
in my program.


Validation against schema can tell you whether XML is valid or not.
Basing on that you can "fix" your XML in your code.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
Nov 12 '05 #2
My hope was that this is possible. I would have prefered to have everything
inside the schema file, to see exactly which values are possible and what
happens if a value is outside a defined range.
For a user of this schema it's not possible to guess what happens inside my
program, if some wrong value is delivered.
But nevertheless thanks for your reply, it prevents me from a time consuming
search on the web.

Cheers Uwe

"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> schrieb im Newsbeitrag
news:et**************@TK2MSFTNGP12.phx.gbl...
Uwe Kuhne wrote:
I receive a XML file from a customer and want to use a schema for validating the XML file. What I don't know how to do is, that I want to continue
processing this XML - file no matter if there is an error or not.

e.g. I have an element <Code> which can contain values 1 to 9.

If something else is delivered within the XML file, I want to replace this wrong value with the default 1.

Is this possible within the schema definition, or do I have to treat this in my program.


Validation against schema can tell you whether XML is valid or not.
Basing on that you can "fix" your XML in your code.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #3
Hi Uwe,

Please try to take a look at the DataType Facets. The maxInclusive and
minInclusive property may meet your needs.

http://msdn.microsoft.com/library/de...us/xmlsdk/htm/
xsd_ref_9rar.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4

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

Similar topics

1
by: scorpion | last post by:
I have this problem that an xml instance is validated correctly by xml tools, but not with my simple code, by setting the validating flag to true. --------------- Schema...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
1
by: Christian | last post by:
Hi, I load an Xml-file "customers.xml" into a DataSet (works fine) but then how do I validate it against a schema (e.g. customers.xsd) ? my customers.xml: <?xml version="1.0"...
1
by: Andy | last post by:
I am having some trouble validating XML using the XmlValidatingReader. I have created some xml and used the visual studio to generate the schema. So I am confident that the xml and schema match. ...
6
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed...
0
by: Joe | last post by:
Hi For a while now I have been finding postings of problems with the validating event not firing on controls properly. I too had this problem. The event would fire when clicking on another...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
1
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this...
2
by: lrheeza | last post by:
Hello everyone, I am a newbie at MS Access and I need help!!! I am importing an excel file using Import functionality in MS Access, all the fields are required but there are instances in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.