471,348 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

xml schema

Hello!

First of all does every Xml document have a schema ?

I'm trying to get the right feeling for what a xml schema is ?
As far as I understand it's used for defining a structure how you are permitted to right your Xml document.

Is it possible to make a simile to C# in some sensible way.

//Tony
Aug 14 '08 #1
9 1424
Tony Johansson <jo*****************@telia.comwrote:
First of all does every Xml document have a schema ?
No.
I'm trying to get the right feeling for what a xml schema is ?
As far as I understand it's used for defining a structure how you are
permitted to right your Xml document.
Yes, pretty much.
Is it possible to make a simile to C# in some sensible way.
I have no idea what you mean by this, I'm afraid.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 14 '08 #2
Hello!

When should a Xml schema be used and when can you skip it ?

//Tony

"Jon Skeet [C# MVP]" <sk***@pobox.comskrev i meddelandet
news:MP*********************@msnews.microsoft.com. ..
Tony Johansson <jo*****************@telia.comwrote:
First of all does every Xml document have a schema ?

No.
I'm trying to get the right feeling for what a xml schema is ?
As far as I understand it's used for defining a structure how you are
permitted to right your Xml document.

Yes, pretty much.
Is it possible to make a simile to C# in some sensible way.

I have no idea what you mean by this, I'm afraid.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com

Aug 14 '08 #3
Tony Johansson <jo*****************@telia.comwrote:
When should a Xml schema be used and when can you skip it ?
It's a bit like static typing vs dynamic typing - XML schema allows you
to validate the XML document to some extent. It also enables editors to
provide the equivalent of Intellisense.

Personally I'm not a massive fan, but it depends on the situation. It's
a good way of conveying a specification in a machine-readable format.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 14 '08 #4
On Thu, 14 Aug 2008 11:46:33 +0200, Tony Johansson wrote:
Hello!

When should a Xml schema be used and when can you skip it ?
My take on this is that schema validation should be used sparingly in
production. Strict adherence to an XML standard (schema) must be done
during testing between exchanging parties but you should be free to
handle schema validation errors in production.

Ken
Aug 14 '08 #5

"Tony Johansson" <jo*****************@telia.comwrote in message
news:uA**************@TK2MSFTNGP02.phx.gbl...
Hello!
First of all does every Xml document have a schema ?
I'm trying to get the right feeling for what a xml schema is ?
As far as I understand it's used for defining a structure how you
are permitted to right your Xml document.
Is it possible to make a simile to C# in some sensible way.
An XML document without a schema is roughly like a C# object whose
only property is a list of name-value pairs. You can iterate through
the list, but until you do, there's no way to tell what names will be
present or what type each value will have.

An XML document with a schema is like a normal C# object. The type of
the object (just like the schema) shows you the properties and their
types.
Aug 14 '08 #6
On Aug 14, 1:54*pm, Ken Foskey <rmove.fos...@optushome.com.auwrote:
My take on this is that schema validation should be used sparingly in
production. *Strict adherence to an XML standard (schema) must be done
during testing between exchanging parties but you should be free to
handle schema validation errors in production.
A better rule is to be lax on your input but strict on your output. So
you wouldn't validate XML when reading it, trying to detect and
recover from errors as you go, but you'd validate your outputs, so as
to be sure that it adhers to the spec, and your own program and any
third-party product can read it back correctly.

Also, .NET XML schema validation classes allow one to do incremental
validation, and perform recoverable error handling.
Aug 14 '08 #7
Pavel Minaev <in****@gmail.comwrote:
On Aug 14, 1:54*pm, Ken Foskey <rmove.fos...@optushome.com.auwrote:
My take on this is that schema validation should be used sparingly in
production. *Strict adherence to an XML standard (schema) must be done
during testing between exchanging parties but you should be free to
handle schema validation errors in production.
A better rule is to be lax on your input but strict on your output.
I find it's better to be strict on both input and output. Everyone
being lax on input means that errors on output don't get noticed. Being
lax on input is what got browsers into such a horrible mess as they
tried to work out what invalid HTML was meant to read.

Invalid XML is particularly inexcusable, as it's meant to be machine
generated - if something is generating XML which doesn't conform to the
spec, it is *broken* and you shouldn't work with it IMO.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 14 '08 #8
Tony Johansson wrote:
When should a Xml schema be used and when can you skip it ?
You should use it whenever you have time to do one.

Arne
Aug 15 '08 #9
Pavel Minaev wrote:
On Aug 14, 1:54 pm, Ken Foskey <rmove.fos...@optushome.com.auwrote:
>My take on this is that schema validation should be used sparingly in
production. Strict adherence to an XML standard (schema) must be done
during testing between exchanging parties but you should be free to
handle schema validation errors in production.

A better rule is to be lax on your input but strict on your output. So
you wouldn't validate XML when reading it, trying to detect and
recover from errors as you go, but you'd validate your outputs, so as
to be sure that it adhers to the spec, and your own program and any
third-party product can read it back correctly.

Also, .NET XML schema validation classes allow one to do incremental
validation, and perform recoverable error handling.
I would not recommend continue processing XML that is not
valid according to the expected XSD.

Something is wrong and until the reason is invesigated
it could do more harm than good to continue.

Arne
Aug 15 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by wooks | last post: by
1 post views Thread by Hari Om | last post: by
4 posts views Thread by Gordon Dickens | last post: by
4 posts views Thread by Iain A. Mcleod | last post: by
reply views Thread by Derek | 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.