gpt4 book ai didi

xml - 在 XSD 中表示对象列表

转载 作者:数据小太阳 更新时间:2023-10-29 01:42:06 24 4
gpt4 key购买 nike

我如何在 XSD 中表示对象列表,例如,给定这样的 XML?

 <msgBody>
<Contato>
<cdEndereco>11</cdAreaRegistro>
<cdBairro>99797781</nrLinha>
<email>foo@foo.com</email>
</Contato>
<Contato>
<cdEndereco>11</cdAreaRegistro>
<cdBairro>99797781</nrLinha>
<email>foo@foo.com</email>
</Contato>
</msgBody>

如何将它合并到对象类型 Contato 的列表中?

最佳答案

我可能会建议以下架构(即使您的 XML 在粘贴时已损坏):

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="msgBody">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="Contato"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Contato">
<xs:complexType>
<xs:sequence>
<xs:element ref="cdEndereco"/>
<xs:element ref="cdBairro"/>
<xs:element ref="email"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="cdEndereco" type="xs:integer"/>
<xs:element name="cdBairro" type="xs:integer"/>
<xs:element name="email" type="xs:string"/>
</xs:schema>

关于xml - 在 XSD 中表示对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4740221/

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