Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Problem with XML Validation against schema

From: "espresso" <carsten.sponsel@---.-->
To: NULL
Date: 12/7/2006 5:39:00 AM

That was exactly the right hint. Thank you very much Martin.


Martin Honnen schrieb:

> espresso wrote:
>
> > I've written a method that checks it a XML file conforms to a specific
> > XML schema. One of my XML schemas is rather complex and involves
> > namespaces etc.
> >
> > Now I'm having the problem, that if I use my method with any general
> > XML file, that does not even has the right root element, it returns
> > true, which means the xml file conforms to that xsd. Bad problem :-(
> > When i check the XML file with XMLSpy (i have to assign the schema
> > first), XMLSpy says the XML file is not valid - of course.
>
> The problem is that in terms of XSD schema validation if the validator
> looks at the root element of your XML instance document that it decides
> based on the namespace of the element whether it has a schema to
> validate against or not. If it does not find a schema with the target
> namespace being the namespace of the root element then it only emits a
> warning but does not report a validation error. So set up a
> ValidationEventHandler and make sure you receive warnings, then check
> those warnings and you should get a warning in the handler if an XML
> document is being validated where the validator can't find a schema with
> a matching namespace.
>
>
> >             XmlDocument xmlDoc = new XmlDocument ();
>
> Alternatively, if you use XmlDocument to load the XML, you can simply
> check whether xmlDoc.DocumentElement.NamespaceURI matches the schemas
> target namespace.
>
>
>
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent