Groups | Blog | Home
all groups > dotnet xml > january 2005 >

dotnet xml : Simple XML & XSD Question



Mark Jerde
1/4/2005 12:21:24 PM
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.

Thanks.

-- Mark

Patrick Philippot
1/4/2005 7:17:32 PM
[quoted text, click to view]

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
[quoted text, click to view]

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

Cindy M -WordMVP-
1/11/2005 8:44:59 PM
Hi Mark,

If you'd be using these in Microsoft Word, by using the same TargetNamespace
in both the xml and xsd files you can get Word to associate the schema.
Assuming it's been added to the user's schema library, that is.

[quoted text, click to view]

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Mark Jerde
1/12/2005 9:46:09 AM
Thanks, Patrick & Cindy.

-- Mark

Ruslan Popov
1/30/2005 8:13:38 PM
I wonder is there a way to embed a schema into the document, rather then
just referencing it. So that when the schema is needed it could be obtained
directly from the document.

--
Yours, respectfully
Ruslan Popov

Patrick Philippot
1/31/2005 9:07:08 AM
[quoted text, click to view]

Hi,

For sure, you can do that. See an example of inline schemas here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmconValidationInlineSchemas.asp
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.aspnet/attach/07869c7f5eda2495/sample.xml?part=2

However, using inline schemas generates new validation problems. For
example, since the <schema> element is a child of the root element, the
root element itself cannot be validated (when using an
XmlValidatingReader for example).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconvalidationwithinlinexsdschema.asp

--
Patrick Philippot - Microsoft MVP
MainSoft Consulting Services
www.mainsoft.fr

vasacheh NO[at]SPAM lycos-dot-com.no-spam.invalid
2/13/2005 1:52:05 PM
Use FREEWARE XMLFox XML/XSD editor:
http://www.xmlfox.com/xml_schema_editor.htm

XMLFox is an XML editing and validation tool for creating valid,
well-formed XML documents and/or XSD Schema. It includes an XML View,
XML Tree, XML Grid, and XML Script modes for editing, as well as
extensive find capabilities for text and XML data. Additional
features include XML and Schema Validation, standard editing
features, XSD Schema building and more.


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
AddThis Social Bookmark Button