I am trying to validate an XML instance document that contains
elements from 2 different schema's. When I validate using .net I get
the following error
"Xml is invalid: The element http://api.onesource.com/abstract:group
has invalid child element http://api.onesource.com/schema2:assets.
Expected http://api.onesource.com/schema1:CopyrightText
http://api.onesource.com/abstract:item. An error occured at ,(1,407)
What is interesting is if I switch the order of the schema's in the
schemaLocation I get an error on the CopyrightText element. This
validates fine in XMLSpy. I have made simplified version of the
schema's we are using that are below. The full schema's come from the
XBRL committee.
Many thanks in advance to anyone who can shed some light on this
perplexing problem.
Base Schema
<?xml version="1.0"?>
<schema targetNamespace="http://api.onesource.com/abstract"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xbrli="http://api.onesource.com/abstract"
elementFormDefault="qualified" attributeFormDefault="qualified">
<element name="item" type="anyType" abstract="true"/>
<element name="group">
<complexType>
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="xbrli:item" minOccurs="0" maxOccurs="unbounded"/>
</choice>
</complexType>
</element>
</schema>
Schema1 (CopyrightText derived from xbrli:item)
<?xml version="1.0" encoding="utf-8"?>
<schema targetNamespace="http://api.onesource.com/schema1"
xmlns:xbrli="http://api.onesource.com/abstract"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:os1="http://api.onesource.com/schema1"
elementFormDefault="qualified" attributeFormDefault="qualified">
<import namespace="http://api.onesource.com/abstract"
schemaLocation="abstractschema.xsd"/>
<element name="CopyrightText" type="string"
substitutionGroup="xbrli:item"/>
</schema>
Schema2 (assets derived from xbrli:item)
<?xml version="1.0" encoding="utf-8"?>
<schema targetNamespace="http://api.onesource.com/schema2"
xmlns:os2="http://api.onesource.com/schema2"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xbrli="http://api.onesource.com/abstract"
elementFormDefault="qualified" attributeFormDefault="qualified">
<import namespace="http://api.onesource.com/abstract"
schemaLocation="abstractschema.xsd"/>
<element name="Assets" type="string"
substitutionGroup="xbrli:item"/>
</schema>
Instance document
<xbrli:group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xbrli="http://api.onesource.com/abstract"
xmlns:os1="http://api.onesource.com/schema1"
xmlns:os2="http://api.onesource.com/schema2"
xsi:schemaLocation="http://api.onesource.com/schema1 schema1.xsd
http://api.onesource.com/schema2 schema2.xsd">
<os1:CopyrightText>string</os1:CopyrightText>
<os2:Assets>string</os2:Assets>
</xbrli:group>