【发布时间】:2016-08-06 16:22:06
【问题描述】:
为了这个解释,我使用了 2 个不同的 XSD:
customEntry.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="customEntry"
targetNamespace="http://tempuri.org/customEntry.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/customEntry.xsd"
xmlns:mstns="http://tempuri.org/customEntry.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:simpleType name="customEntry">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z0-9_%./]*"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
element_ArtStyleSuffix.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="element_ArtStyleSuffix"
targetNamespace="http://tempuri.org/element_ArtStyleSuffix.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/element_ArtStyleSuffix.xsd"
xmlns:mstns="http://tempuri.org/element_ArtStyleSuffix.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:import namespace="http://tempuri.org/customEntry.xsd" schemaLocation="customEntry.xsd"/>
<!-- Civilizations ArtStyleSuffix Enumeration -->
<xs:simpleType name="enum_ArtStyleSuffix">
<xs:restriction base="xs:string">
<xs:enumeration value="_EURO"/>
<xs:enumeration value="_AFRI"/>
<xs:enumeration value="_AMER"/>
<xs:enumeration value="_ASIA"/>
</xs:restriction>
</xs:simpleType>
<!-- ArtStyleSuffix GameData Schema Information -->
<xs:element name="GameData">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ArtStyleSuffix">
<xs:annotation>
<xs:documentation>
Select a default ArtStyleSuffix or you may create your own custom one and place its TypeName here.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:union memberTypes="customEntry enum_ArtStyleSuffix"/>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
我的问题在于以下行:
<xs:union memberTypes="customEntry enum_ArtStyleSuffix"/>
Visual Studio 2015 社区正在抛出错误:
键入“http://tempuri.org/element_ArtStyleSuffix.xsd:customEntry”是 未声明,或者不是简单类型。
对我来说它看起来像一个简单的类型,我认为导入行声明了它,所以也许我不完全理解“导入”,因为我没有从导入行收到任何错误,只是联合行。我这样做对吗?
【问题讨论】:
标签: xml xsd xsd-validation xml-validation