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

dotnet xml : Document Validation


Kent Ogletree
1/7/2005 10:17:56 AM
I am porting a Java XML Validation class over to C# and I am having a
problem finding exactly what I need to acomplish the task.

First I need to test for well formedness. I know this is usually something
that does not need to be done, however in this case it is required. Is the
best way to do this to validate to the schema and if no exception is thrown
it must be well formed? What exception would be thrown if the document is
found to not be well formed?

Second, these documents sometimes come with additional vendor specified
metadata included. When they do there is additional XSDs included. How would
I load these into the cache and know the proper name space for them since I
can not know in advance if they are included or even their name? Depending
on the source of them, these XSDs could have an unknown variaty of different
namespaces. We do not use this data but my understanding of Validation is if
we do not want an error during validation we need to include the XSDs in the
process.

This is really my first dive into heavy low level use of XML, everything
else I have done is basic web services where I did not have to worry about
many of the lower level details.

TIA,
Kent

Kent Ogletree
1/7/2005 1:21:42 PM
[quoted text, click to view]

Where might I find a reference to limiting the validation to the data in a
specific namespace?

Kent



[quoted text, click to view]

Bjoern Hoehrmann
1/7/2005 7:33:41 PM
* Kent Ogletree wrote in microsoft.public.dotnet.xml:
[quoted text, click to view]

Yes, that's in fact the only way for most processors. The exception
depends on the interface you use (XmlDocument, XmlTextReader, etc.)

[quoted text, click to view]

It should be possible to limit Validation to specific namespaces, so
this is not necessarily a problem. At least XML Schema does not require
positive validation of all elements to determine schema-validity.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
Zafar Abbas [MSFT]
1/10/2005 11:03:42 AM
There is no direct way to ignore validation of certain components. You could
construct your schema in such a way that only the components from a certain
namespace are processed for validation and others are ignored due to a
wildcard element <xs:any> and wildcard attribute <xs:anyAttribute> with
processContents = skip.

[quoted text, click to view]

AddThis Social Bookmark Button