0
我已阅读W3C文档,阅读教程,阅读各种帖子,但仍不明白为什么Visual Studio 2010(版本10.0.4.0219.1)中将以下架构定义标记为无效。XSD语法用于描述具有小数内容和字符串属性的XML元素?
希望可以提供任何帮助。以下是一个演示此问题的示例模式定义。在Visual Studio(上XS蓝色下划线:限制)显示
<?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>
消息是:
未定义的complexType “http://www.w3.org/2001/XMLSchema:decimal” 被用作一个复杂类型限制的基础。
其他表明必须添加simpleType或complexType来定义基本类型的限制 - 但我无法做到这一点,没有收到相同的错误消息。
感谢您的帮助。
谢谢,这意味着对XSD所需的更改仅仅是从“xs:restriction”更改为“xs:extension”,并且全部解决。 – MSheridan