문제

Im using Visual Studio 2013 to develop an XSD Schema that imports another schema for use of its "Neck" type. For some reason Visual Studio doesnt like my use of type="wn:Neck", resulting in the error mentioned in the title. Below is my parent schema and after that is the child schema. Visually the schema looks correct but VS2013 disagrees. Does anyone know why this is happening? Ive seen similar questions but haven't found a direct solution to this issue.

Parent

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:wn="http://fxb.co/xsd/warmoth/neck.xsd"           
           targetNamespace="http://fxb.co/xsd/warmoth/customitem.xsd">
  <xs:import namespace="http://fxb.co/xsd/warmoth/neck.xsd" schemaLocation="./Neck.xsd"/>
  <xs:element name="CustomItems">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustomItemOption">
          <xs:complexType>
            <xs:sequence>                  
              <xs:element minOccurs="0" maxOccurs="unbounded" name="Neck" type="wn:Neck" />            
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Child

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"            
           xmlns:xs="http://www.w3.org/2001/XMLSchema"                
           targetNamespace="http://fxb.co/xsd/warmoth/neck.xsd" >
  <xs:element id="Neck" name="Neck">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Headstock">
          <xs:complexType>
            <xs:attribute name="active" type="xs:boolean" default="true" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
도움이 되었습니까?

해결책

In the parent XSD, change

<xs:element minOccurs="0" maxOccurs="unbounded" name="Neck" type="wn:Neck" />            

to

<xs:element minOccurs="0" maxOccurs="unbounded" ref="wn:Neck" />            

because you wish to reference the Neck element, not type, from the namespace of the child XSD.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top