【发布时间】:2020-08-02 08:17:00
【问题描述】:
我需要在这个 XML 文件中添加更多具有相同标题、媒体、描述、创建和显示子元素的“艺术品”元素,我尝试使用 max0ccurs=unbounded 但看到我只能在元素是与全局元素没有直接关系。 这是 XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Artworks">
<xs:complexType>
<xs:sequence>
<xs:element ref="Artwork"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Artwork">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Media" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Created" type="xs:string"/>
<xs:element name="Display" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是 XML
<Artworks xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="artwork1.xsd">
<Artwork>
<Title>Xtreme Air</Title>
<Media>Glass Sculpture</Media>
<Description>An amazing work that uses glass balloon shaps to illustrate a rainbow of balloons circuling a glass earth.</Description>
<Created>April 2010</Created>
<Display>Orlando Museum of Arts</Display>
<Artwork></Artwork>
</Artwork>
</Artworks>
【问题讨论】: