Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Simple XML & XSD Question >Thread Next - Re: Simple XML & XSD Question Re: Simple XML & XSD QuestionTo: NULL Date: 1/4/2005 7:18:00 PM Mark Jerde wrote: > We have developed about 80 XML documents, each probably 150 lines > long, that are all supposed to conform to a schema. My understanding > is the way to show that an XML document conforms to a schema is to > include a reference to the XSD in the XML document, and check that it > is valid. > > Some other members of the project team don't want to include a > reference to the XSD in the XML documents, citing possible > differences in parsers. > > Is my understanding of XML / XSD correct? That is, the standard way > to prove that a well formed XML document conforms to a schema is to > include the reference to the XSD in the XML document. Hi Mark, A few remarks... 1. One thing is for sure, there will be no way for a client application to validate the XML document against its schema if the document doesn't contain any reference to the schema and if the application is not made aware of this schema from an external source of information. 2. Validating XML documents against their schema is not always necessary as long as they were produced in a safe way (e.g. they can be validated just after being produced). It depends on what you need to do with them and on how you distribute them. 3.> the standard way to prove > that a well formed XML document > conforms to a schema is to > include the reference to the XSD in the XML document Adding a reference to the schema in the document will not prove anything. It depends on how the client application loads the XML document. For example, in .Net, if you don't use a validating reader, no validation occurs. The schema reference is just ignored. Again, you can provide the schema's URL to the client application, if needed, by using an external channel. In .Net, when using an XmlValidatingReader, the schema can be specified separately from the document itself (See Schemas property). 4. >possible differences in parsers. If the schema is correctly defined, any reliable and correctly written validating parser will validate the document against that schema. There's no room for interpretation, the XSD specification is accurate enough, IMHO. If the parser fails to validate a valid document, then the parser is buggy. Not referencing the schema is not a protection against a buggy parser. -- Patrick Philippot - Microsoft MVP MainSoft Consulting Services www.mainsoft.fr | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
