Hi, I've been struggling to resolve this issue for a week now and haven't gotten any responses on StackOverflow (http://stackoverflow.com/questions/31971324/error-different-target-namespace-but-schema-validates-and-namespaces-match), so I found this list.
I managed to reduce my original complex files down to shorter examples which demonstrate the issue. I'm able to validate this XML: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <My_Data> <PartOne> testing </PartOne> <PartTwo> 123 </PartTwo> </My_Data> with this XSD: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="My_Data"> <xs:complexType> <xs:sequence> <xs:element name="PartOne" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="PartTwo" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> However, as soon as I add a targetNamespace attribute in the schema, I get the error "has a different target namespace from the one specified in the instance document ." XML: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <My_Data xmlns="http://www.mywebsite.com/schema/myschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema"> <PartOne> <ElemOne>thing</ElemOne> </PartOne> <PartTwo>123</PartTwo> </My_Data> XSD: <xs:schema xmlns="http://www.mywebsite.com/schema/myschema" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.mywebsite.com/schema/myschema"> <xs:element name="My_Data"> <xs:complexType> <xs:sequence> <xs:element name="PartOne" type="SubType" minOccurs="0" maxOccurs="1"/> <xs:element name="PartTwo" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="SubType"> <xs:sequence> <xs:element name="ElemOne" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:schema> But the XML and XSD validate! Why would this be? I've tried adding a schemaLocation attribute and searched for other examples, but can't figure out what is going on here. Any insight would be greatly appreciated! Thanks, em