Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: MSXML 4.0 to 6.0 - Invalid Namespace And XMLSchemaCache >Thread Next - Re: MSXML 4.0 to 6.0 - Invalid Namespace And XMLSchemaCache Re: MSXML 4.0 to 6.0 - Invalid Namespace And XMLSchemaCacheTo: NULL Date: 11/13/2008 2:00:00 PM Leverd wrote: > <pf1:root xmlns:pf1="http://example.com/2008/ns1"> > <pf1:foo xmlns:pf2="http://example.com/2008/ns3"> > <pf2:bar>foobar</pf2:bar> > </pf1:foo> > </pf1:root> > > > If I run the above I will get no error from MSXML6.0, but will get an error > for > MSXML 4.0. If I change 'n3' to 'n2', it tries to validate in both 6.0 and > 4.0 (gives me an error because 'foobar' is not an int type). > > So this might be some internal quirk that changed from 4.0 to 6.0, but the > real problem is likely with my schemas. Is this a valid way to write a schema? MSXML 4 says "The element 'pf2:bar' is used but not declared in the DTD/Schema." That statement is correct as it is true that the element pf2:bar occurs in the XML document but is in a namespace for which there is no schema. On the other hand your XML schema simply has <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="foo"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> With that definition the foo element is allowed to have any content that is possible, see http://www.w3.org/TR/xmlschema-0/#anyType. So what MSXML 4 reports can only be considered correct if it is meant as a warning. And MSXML 6 is correct not to report an error as there is no error, your schema allows any content. Unfortunately you have run into a difference between MSXML 4 and 6 which bites you. I don't know how to solve that by changing the code using MSXML 6, instead I can only suggest to change the schema to make it more rigid, as in the example I posted where the foo contents was restricted to be a bar element from a certain namespace. If you don't want to allow a certain element from that namespace but all possible elements from a certain namespace then you can also use the xs:any element e.g. <xs:element name="foo"> <xs:complexType> <xs:sequence> <xs:any namespace="http://example.com/2008/ns"/> </xs:sequence> </xs:complexType> </xs:element> That way any element from a different namespace should raise a validation error. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
