Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 元素的随机顺序和最大发生次数>;1._Python_Xml_Xsd - Fatal编程技术网

Python 元素的随机顺序和最大发生次数>;1.

Python 元素的随机顺序和最大发生次数>;1.,python,xml,xsd,Python,Xml,Xsd,我需要创建一个验证XML文件的XSD1.0 验证将使用python中的lxml.etree,此工具仅支持XMLSchema 1.0() 我需要使用的结构类型为: item | owners* | config+ | | config_id | | tests* | | picked? | | capability* | | | name | | | value 使用的符号有: *元素可以出现零次或多次 +元素可以出现一次

我需要创建一个验证XML文件的XSD1.0

验证将使用python中的lxml.etree,此工具仅支持XMLSchema 1.0()

我需要使用的结构类型为:

    item
    | owners*
    | config+
    | | config_id
    | | tests*
    | | picked?
    | | capability*
    | | | name
    | | | value
使用的符号有:

  • *
    元素可以出现零次或多次
  • +
    元素可以出现一次或多次
  • 该元素是可选的
config标记中的元素可以是任意顺序,这意味着我不能使用
指示器<代码>}元素“:的值无效 maxOccurs(必须为0或1)


我的问题有其他解决办法吗?

是的,有其他办法:

  • 完全放弃随机顺序要求。这往往比它的价值更麻烦
  • 通过将
    config_id
    picked
    迁移到
    xs:all
    之外,并将
    maxOccurs=“unbounded”
    xs:all
    的子级迁移到
    xs:all
    本身,部分放弃随机顺序要求
  • 保留随机顺序要求,将
    maxOccurs=“unbounded”
    迁移到
    xs:all
    ,并使用XSD 1.1断言强制执行其他发生约束

  • 您知道linux中有任何XSD1.1验证程序也是免费的吗?请参阅
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    
    <!--Schema version: 1.0, date: 29-02-2016-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <!-- definition of complex types -->    
      <xs:complexType name="capability_type">
        <xs:sequence>
          <xs:element name="name" type="xs:string" />
          <xs:element name="value" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    
      <xs:complexType name="config_type">
        <xs:all>
          <xs:element name="config_id" type="xs:string" />
          <xs:element name="tests" type="xs:string" minOccurs="0" 
                              maxOccurs="unbounded" />
          <xs:element name="picked" type="xs:string" minOccurs="0" />
          <xs:element name="capability" type="capability_type" 
                              minOccurs="0" maxOccurs="unbounded" />
        </xs:all>
      </xs:complexType>
    
      <xs:complexType name="item_type">
        <xs:sequence>
          <xs:element name="owners" type="xs:string" minOccurs="0" 
                              maxOccurs="unbounded" />
          <xs:element name="config" type="config_type" minOccurs="1" 
                              maxOccurs="unbounded" />
        </xs:sequence>
      </xs:complexType>
    
      <!-- definition of schema -->
      <xs:element name="item" type="item_type" />
    
    </xs:schema>