内容结束之前的预期元素。 Soap XSD 验证
我正在使用肥皂,我收到了服务人员的回复。我单击鼠标右键并选择验证,但出现错误“内容结尾之前预期元素 xxx...”
在 xsd 架构中我已经
elementFormDefault="合格"
AdditionalAtribute 正如名称所示可以为空,因此有时它具有值,但并非总是如此。当它有价值时,一切正常,但当它为空时,我的响应验证给了我这种沟通。
这就是我的 XSD 片段的样子:
<xsd:element name="listOfThings" maxOccurs="unbounded" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="thingCategory" type="xsd:string" minOccurs="0"/>
<xsd:element name="thingName" type="xsd:string" minOccurs="0"/>
<xsd:element name="thingValue" type="xsd:string" minOccurs="0"/>
<xsd:element name="additionalAttubute" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
XML 示例
<tns:listOfThings>
<tns:thing>
<tns:thingCategory>CATEGORY</tns:thingCategory>
<tns:thingName>NAME</tns:thingName>
<tns:thingValue>A</tns:thingValue>
</tns:thing>
<tns:thing>
<tns:thingCategory>CATEGORY2</tns:thingCategory>
<tns:thingName>NAME2</tns:thingName>
<tns:thingValue>B</tns:thingValue>
<tns:additionalAttribute>C</tns:additionalAttribute>
</tns:thing>
</tns:listOfThings>
I am using soap and i have response from service. I click right mouse button and choose validate and i have errors 'Expected element xxx before the end of the content..."
In the xsd schema i have already
elementFormDefault="qualified"
AdditionalAtribute as name says is nullable so sometimes it has value but not always. When it has value everything is ok but when it is null my response validation gives me this communicate.
This is what my XSD fragment looks like:
<xsd:element name="listOfThings" maxOccurs="unbounded" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="thingCategory" type="xsd:string" minOccurs="0"/>
<xsd:element name="thingName" type="xsd:string" minOccurs="0"/>
<xsd:element name="thingValue" type="xsd:string" minOccurs="0"/>
<xsd:element name="additionalAttubute" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
XML example
<tns:listOfThings>
<tns:thing>
<tns:thingCategory>CATEGORY</tns:thingCategory>
<tns:thingName>NAME</tns:thingName>
<tns:thingValue>A</tns:thingValue>
</tns:thing>
<tns:thing>
<tns:thingCategory>CATEGORY2</tns:thingCategory>
<tns:thingName>NAME2</tns:thingName>
<tns:thingValue>B</tns:thingValue>
<tns:additionalAttribute>C</tns:additionalAttribute>
</tns:thing>
</tns:listOfThings>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的架构和 XML 之间存在多个不匹配
listOfThings
下有一个节点things
,该节点的 maxoccurrs 应该是无界的,而不是listOfThings
下面是您的架构应该与该 XML 匹配的样子
You have multiple mismatches between your schema and your XML
things
underlistOfThings
that should have the maxoccurs unbounded rather thanlistOfThings
Below is what your schema should look like to match that XML
尝试使用空元素:
Try with empty element: