Повторяющиеся элементы с разными метками

У меня есть повторяющийся элемент 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" />

Спасибо большое

1 ответ

Решение

У вас есть последовательность элементов property с атрибутами label, name, и так далее.

Поэтому схема может выглядеть так

<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>
Другие вопросы по тегам