问题描述
限时送ChatGPT账号..我得到以下架构:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="machine">
<xs:complexType>
<xs:sequence>
<xs:element name="states" type="tokenList"/>
<xs:element name="in_alphabet" type="tokenList"/>
<xs:element name="blank" type="xs:string"/>
<xs:element name="tape_alphabet" type="tokenList"/>
<xs:element name="first_state" type="xs:string"/>
<xs:element name="final_states" type="tokenList"/>
<xs:element name="delta" type="delta_func" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="tokenList">
<xs:list itemType="xs:normalizedString"/>
</xs:simpleType>
<xs:complexType name="delta_func">
<xs:sequence>
<xs:element name="state" type="xs:string"/>
<xs:element name="read" type="xs:string"/>
<xs:element name="target_states" type="tokenList"/>
<xs:element name="write" type="xs:string"/>
<xs:element name="move">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="R|L|r|l"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
哪个有效,但我不想限制元素的顺序.我尝试了 xs:all
但它不允许 maxOccurs=unbounded
用于 delta
,这是必须的.所有其他元素只出现一次,所以 xs:all
在这里不会有问题.有没有办法在元素上定义随机顺序,同时允许无限数量的 delta
s?
Which works, but I would like to not restrict the order of the elements. I tried xs:all
but it doesn't allow maxOccurs=unbounded
for delta
, which is a must. All other elements occur only once, so xs:all
wouldn't be problem here. Is there a way to define random order on the element while allowing an unlimited numbers of delta
s?
推荐答案
代替
,你可以使用
>,但这意味着所有元素都可以出现多次.
Instead of <sequence>
, you could use <choice maxOccurrs="unbounded">
, but it would imply that all elements can occur more than once.
这篇关于XML 模式 maxOccurs 和 xs:all的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论