我已阅读W3C文档,阅读教程,阅读此处的各种帖子,仍然不明白为什么以下架构定义在Visual Studio 2010(版本10.0.4.0219.1)中被标记为无效。
非常感谢可能提供的任何帮助。以下是演示该问题的示例模式定义。
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.tempuri.org/WhyDoesThisFail"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:why="http://www.tempuri.org/WhyDoesThisFail">
<!-- Write a valid XSD to describe the following:
<SomeField alias="SomeAlias">1234.5678</SomeField>
-->
<xs:attributeGroup name="FieldAlias">
<xs:attribute name="alias" type="xs:string" />
</xs:attributeGroup>
<xs:complexType name="DecimalWithAlias">
<xs:simpleContent>
<xs:restriction base="xs:decimal">
<xs:attributeGroup ref="why:FieldAlias" />
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:element name="SomeField" type="why:DecimalWithAlias"/>
</xs:schema>
Visual Studio中显示的消息(xs:restriction上的蓝色下划线)是:
未定义的complexType“http://www.w3.org/2001/XMLSchema:decimal”用作复杂类型限制的基础。
其他人指出,必须添加simpleType或complexType来定义基类型的限制 - 但是如果没有收到相同的错误消息,我就无法这样做。
感谢您的帮助。