471,108 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 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 1411
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by scorpion | last post: by
1 post views Thread by Christian | last post: by
2 posts views Thread by Chris Dunaway | last post: by
reply views Thread by Gary Shell | last post: by

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.