【问题标题】:"Type [namespace:type] is not declared" yet is imported correctly, I think我认为“类型 [namespace:type] 未声明”但已正确导入
【发布时间】:2014-06-10 01:11:56
【问题描述】:

我正在使用 Visual Studio 2013 开发一个 XSD 架构,该架构导入另一个架构以使用其“Neck”类型。出于某种原因,Visual Studio 不喜欢我使用 type="wn:Neck",导致标题中提到的错误。下面是我的父模式,之后是子模式。从视觉上看,架构看起来是正确的,但 VS2013 不同意。有谁知道为什么会这样?我见过类似的问题,但没有找到直接解决此问题的方法。

父母

<?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>

孩子

<?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>

【问题讨论】:

    标签: xsd xsd-validation


    【解决方案1】:

    在父 XSD 中,更改

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

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

    因为您希望从子 XSD 的命名空间中引用 Neck 元素,而不是类型

    【讨论】:

      猜你喜欢
      • 2020-08-16
      • 2017-11-17
      • 1970-01-01
      • 2016-11-29
      • 1970-01-01
      • 2011-08-25
      • 2012-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多