【发布时间】:2019-12-13 03:02:51
【问题描述】:
我正在尝试从 XSD 构建有效负载,但我显然遗漏了一些东西。这是 XSD:
<xs:element name="InsuranceProducer" type="InsuranceProducer"/>
<xs:complexType name="InsuranceProducer">
<xs:sequence>
<xs:element name="distributionAgency" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>DGIS
For the exclusive agent network, the distribution agency is the same than the agency code.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="distributionNetwork" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>ExclusiveAgency</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="distributor" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Domain of value:
DGIG
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="type" type="xs:string" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>Agency, Agent, HoldingCode, Brokerage</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="code" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="primaryProducer" type="InsuranceProducer" minOccurs="0" maxOccurs="1"/>
<xs:element name="PartyInfo" type="partySum:PartyInfo" minOccurs="0" maxOccurs="1"/>
<xs:element name="salesPointDescription" type="xs:string" minOccurs="0" maxOccurs="1">
</xs:element>
<xs:element name="salesPointCode" type="xs:string" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>Identifies the point of sale responsible for the production of insurance agreements.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="SubProducer" type="SubProducer" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SubProducer" type="SubProducer"/>
<xs:complexType name="SubProducer">
<xs:sequence>
<xs:element name="code" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="PartyInfo" type="partySum:PartyInfo" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
这里是有效载荷的 InsuranceProducer 部分:
<InsuranceProducer xmlns="">
<distributionAgency>Something</distributionAgency>
<distributionNetwork>Something</distributionNetwork>
<distributor>Something</distributor>
<type>Something</type>
<code>Something</code>
<salesPointDescription>something</salesPointDescription>
<salesPointCode>Something</salesPointCode>
</InsuranceProducer>
然而,我收到的只是:org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: 发现以元素“salesPointDescription”开头的无效内容。应为“{primaryProducer, PartyInfo, SubProducer}”之一。行:3,列:391
【问题讨论】:
-
你对他的行
Something 有问题。检查这一行的最后一部分。 -
你的XML schema有很多错误,纠正错误,你也可以在线验证。
-
对不起,这是一个复制粘贴错字,刚刚修复它。
-
不过,您的 xml 架构有很多错误,请使用任何在线工具进行检查。
-
这不是完整的 XSD,因此将其粘贴到工具中肯定会导致很多错误。
标签: java xml spring validation schema