0

我有一个看起来像这样的 xml 重复元素

<property label="V" name="volume" units="cm3" sourcetype="reported">...                                                        
</property>
<property label="P" name="pressure" units="atm" sourcetype="reported">...        
</property>
<property label="tau" name="residence time" units="ms" 
sourcetype="reported">...</property>

我想为它构建一个 xml 模式,以便在相同的标签名称“属性”下具有不同的标签名称和单位。这是我的尝试,显示错误

<xs:complexType>
<xs:sequence>
<xs:element label="V" name="volume" units="cm3" sourcetype="reported" />
<xs:element label="P" name="pressure" units="atm" sourcetype="reported" />

十分感谢

4

1 回答 1

0

您有一系列property具有属性labelname等的元素。

因此,架构可能看起来像这样

<xs:complexType>
  <xs:sequence>        
    <xs:element maxOccurs="unbounded" name="property">
      <xs:complexType>
        <xs:simpleContent>
          <xs:extension base="xs:string">
            <xs:attribute name="label" type="xs:string" use="required" />
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="units" type="xs:string" use="required" />
            <xs:attribute name="sourcetype" type="xs:string" use="required" />
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>
    </xs:element>        
  </xs:sequence>
</xs:complexType>
于 2018-07-18T10:57:44.900 回答