gpt4 book ai didi

xml - s4s-elt-invalid-content.1 : The content is invalid. 元素 'attribute' 无效、放错位置或出现太频繁

转载 作者:数据小太阳 更新时间:2023-10-29 02:52:52 26 4
gpt4 key购买 nike

我有一个 XSD 的 XML,除了一个错误外,一切都很好:

Ln 25 Col 50 - s4s-elt-invalid-content.1: The content of '#AnonType_tracks' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.

这是我的 XML 代码:

<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">
<item>
<title>Kind of Blue</title>
<priceus>US: $11.99</priceus>
<priceuk>UK: £8.39</priceuk>
<artist>Miles Davis</artist>
<tracks>
<track length="9:22">So What</track>
<track length="5:37">Blue in Green</track>
<track length="11:33">All Blues</track>
<track length="9:26">Flamenco Sketches</track>
</tracks>
</item>
<item>
<title>Blue Train</title>
<priceus>US: $8.99</priceus>
<priceuk>UK: £6.29</priceuk>
<artist>John Coltrane</artist>
<tracks>
<track length="10:39">Blue Train</track>
<track length="9:06">Moment's Notice</track>
<track length="7:11">Locomotion</track>
</tracks>
</item>
</items>

这是我的 XSD:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="title" type="xs:string" />
<xs:element name="priceus" type="xs:string" />
<xs:element name="priceuk" type="xs:string" />
<xs:element name="artist" type="xs:string" />
<xs:attribute name="track" type="xs:string" />

<xs:element name="tracks">
<xs:complexType>
<xs:simpleContent>
<xs:attribute ref="track" use="required" />
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="item">
<xs:complexType>
<xs:sequence>
<xs:element ref="title" />
<xs:element ref="priceus" />
<xs:element ref="priceuk" />
<xs:element ref="artist" />
<xs:element ref="tracks"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element ref="item" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

最佳答案

<xs:simpleContent>声明不能包含 <attribute>声明,只有 <restriction><extension> .可以在 <restriction> 中指定属性或 <extension> block 。

参见 https://www.safaribooksonline.com/library/view/xml-schema/0596002521/re49.html

关于xml - s4s-elt-invalid-content.1 : The content is invalid. 元素 'attribute' 无效、放错位置或出现太频繁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41030899/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com