XML 模式 maxOccurs 和 xs:all

编程入门 行业动态 更新时间:2024-10-28 14:37:20
本文介绍了XML 模式 maxOccurs 和 xs:all的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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 deltas?

推荐答案

代替 ,你可以使用 >,但这意味着所有元素都可以出现多次.

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:关键词]

本文发布于:2023-04-24 07:57:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1058928.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   XML   xs   maxOccurs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!