gpt4 book ai didi

xml - XSD:minInclusive 和属性在一起

转载 作者:数据小太阳 更新时间:2023-10-29 01:55:10 25 4
gpt4 key购买 nike

看来我不能轻易地为这个简单的 XML 声明 XSD

<root>
<weekday name="Sunday">1</weekday>
</root>

其中 weekday 是从 1 到 7 的受限 int 并且具有 string 类型的名称属性

有什么建议吗?

感谢您的支持!

最佳答案

当然可以。您需要从简单类型(将整数限制在 1 到 7 之间)派生的复杂类型(添加 name 属性):

<xs:simpleType name="NumericWeekday">
<xs:restriction base="xs:int">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="7"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Weekday">
<xs:simpleContent>
<xs:extension base="NumericWeekday">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

我会留给你将 name 属性变成一个枚举。

关于xml - XSD:minInclusive 和属性在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2584037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com