.NET XSD.exe 缺少属性组引用

.NET XSD.exe misses attribute group references

这是我的一部分 XSD:

<xs:attributeGroup name="matches">
  <xs:attribute name="min-matches" type="positiveInt" default="1" use="optional" />
  <xs:attribute name="max-matches" type="positiveIntUnbounded" default="1" use="optional" />
</xs:attributeGroup>

<xs:attributeGroup name="pathAndMatches">
  <xs:attribute name="path" type="xs:string" use="required" />
  <xs:attributeGroup ref="matches" />
</xs:attributeGroup>

当我使用 .NET FX 的 xsd.exe 时,它只会在我在元素中引用 pathAndMatches 时生成 path 属性。为什么它不为 min/max 匹配项生成属性?我的 XSD 无效吗? xsd.exe 没有显示任何错误或警告。

遗憾的是 xsd.exe 不支持嵌套的属性组。请参阅文档中的以下注释:

The element cannot be nested in another element. Nested instances will be ignored by the Xsd.exe tool.

http://msdn2.microsoft.com/en-us/library/484632e7.aspx

Liquid XML Data Binder支持他们。如果您的项目不大,您可以使用免费的社区版生成它。