471,075 Members | 980 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Simple XML & XSD Question

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
Nov 12 '05 #1
6 4076
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
Nov 12 '05 #2
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.
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.


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 :-)

Nov 12 '05 #3
Thanks, Patrick & Cindy.

-- Mark
Nov 12 '05 #4
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
Nov 12 '05 #5
Ruslan Popov wrote:
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.


Hi,

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

http://msdn.microsoft.com/library/de...ineSchemas.asp
http://groups-beta.google.com/group/...ple.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/de...exsdschema.asp

--
Patrick Philippot - Microsoft MVP
MainSoft Consulting Services
www.mainsoft.fr
Nov 12 '05 #6
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 **
----------------------------------------------------------
http://www.usenet.com
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ryan Waye | last post: by
13 posts views Thread by LRW | last post: by
11 posts views Thread by Jeremy | last post: by
6 posts views Thread by cj | last post: by
14 posts views Thread by Arne | 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.