xmlbiztalkxmlspy

XSD invalid without Prefix


I have the attached main.xsd which imports the types.xsd. Open this in XmlSpy (or similar) and the main.xsd will validate just fine. However, if the namespace prefix ns0 is removed from the declaration then it will not validate - even though the prefix is not used anywhere.

Good:<xs:schema xmlns:ns0="http://schemas.asidua.com/CCP/IntegrationServices/2011-11-18/Data"

Bad:<xs:schema xmlns="http://schemas.asidua.com/CCP/IntegrationServices/2011-11-18/Data"

The validation error message: "Cannot resolve declaration or definition 'ArrayOfString' in namespace 'http://schemas.asidua.com/CCP/IntegrationServices/2011-11-18/Data'"

Can anyone please explain why the prefix is required?

Good file:GoodMain.xsd Bad file:BadMain.xsd Imported types xsd:Types.xsd


Solution

  • By defining "xmlns=", I was saying that any unqualified elements will belong to this default namespace. Problem was, because I didn't have a "targetNamespace=" attribute for the schema, then the namespace that the default namespace targeted did not exist.

    I have now defined the XSD as follows:

    <xs:schema targetNamespace="http://schemas.asidua.com/CCP/IntegrationServices/2011-11-18/Data" xmlns="http://schemas.asidua.com/CCP/IntegrationServices/2011-11-18/Data" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:q2="http://microsoft.com/wsdl/types/" elementFormDefault="unqualified" attributeFormDefault="unqualified">
    

    Full file here:best.xsd