Xsd.exe 架构错误:未定义的复杂类型 'http://www.w3.org/2001/XMLSchema:string'用作复杂类型限制的基础
如何解决这个问题呢?
警告 2 未定义的复杂类型“http://www.w3.org/2001/XMLSchema:string”用作复杂类型限制的基础。
发生这种情况是因为
<xs:element name='TO'>
<xs:complexType>
<xs:simpleContent>
<xs:restriction base='xs:string'>
<xs:maxLength value='15'/>
<xs:attribute name='PROVID'>
<xs:simpleType>
<xs:restriction base='xs:int'>
<xs:enumeration value='1'/>
<xs:enumeration value='2'/>
<xs:enumeration value='3'/>
<xs:enumeration value='5'/>
<xs:enumeration value='6'/>
<xs:enumeration value='7'/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name='TYPE'>
<xs:simpleType>
<xs:restriction base='xs:string'>
<xs:enumeration value='NPM'/>
<xs:enumeration value='EMS'/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
查看 W3schools 参考 这看起来不错,但不是根据 VS2010 和 Xsd.exe
我真正想做的是有一个定义可以具有上述两个属性的元素 TO 及其元素文本应限制为 15 个字符。
How to solve this problem?
Warning 2 Undefined complexType 'http://www.w3.org/2001/XMLSchema:string' is used as a base for complex type restriction.
This is happening because of <xs:simpleContent><xs:restriction base='xs:string'>
<xs:element name='TO'>
<xs:complexType>
<xs:simpleContent>
<xs:restriction base='xs:string'>
<xs:maxLength value='15'/>
<xs:attribute name='PROVID'>
<xs:simpleType>
<xs:restriction base='xs:int'>
<xs:enumeration value='1'/>
<xs:enumeration value='2'/>
<xs:enumeration value='3'/>
<xs:enumeration value='5'/>
<xs:enumeration value='6'/>
<xs:enumeration value='7'/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name='TYPE'>
<xs:simpleType>
<xs:restriction base='xs:string'>
<xs:enumeration value='NPM'/>
<xs:enumeration value='EMS'/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
looking at the W3schools reference this looks ok, but not according to VS2010 and Xsd.exe
All I really want to do is have a definition for an element TO that can have the two above attributes and its element text should be restricted to 15 characters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将字符串限制为 15 个字符并同时将其扩展为具有属性的复杂类型。如果您首先定义一个受限制的字符串类型,然后扩展它,则不会有问题:
You can't restrict a string to 15 characters and extend it to be a complex type with attributes at the same time. If you first define a restricted string type and then extend it, you won't have a problem: