当我尝试针对XSD验证XML时,出现以下错误。我正在使用在线XSD转换器,但出现此错误
S4s-elt-must-match.1:“全部”的内容必须匹配(注释?, 元件*)。发现一个问题始于:Sequence。
我的XML是
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dpss0="bons">
<soapenv:Header/>
<soapenv:Body>
<core:transactionResponse xmlns:bo="http://service.xxx.co.id/core/bo" xmlns:core="http://service.xxx.co.id/core">
<response>
<content xsi:type="NS_BO:ExchangeRateByTypeRes" xmlns:NS_BO="http://service.xxx.co.id/core/bo">
<currencyVersion>2019-01-21 11:22:34 AM</currencyVersion>
<currencyItemTotal>28</currencyItemTotal>
<currency>
<code>CAD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>10288.0000</midRate>
</currency>
<currency>
<code>USD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>15162.0000</buyRate>
<sellRate>15355.0000</sellRate>
</currency>
<currency>
<code>AUD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>16109.0000</buyRate>
<sellRate>16306.0000</sellRate>
</currency>
<currency>
<code>BND</code>
<code2>IDR</code2>
<units>07</units>
<midRate>9900.0000</midRate>
</currency>
<currency>
<code>CHF</code>
<code2>IDR</code2>
<units>07</units>
<midRate>13707.0000</midRate>
</currency>
<currency>
<code>EUR</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>21861.0000</buyRate>
<sellRate>22122.0000</sellRate>
</currency>
<currency>
<code>GBP</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>24814.0000</buyRate>
<sellRate>25094.0000</sellRate>
</currency>
<currency>
<code>HKD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>1952.7200</buyRate>
<sellRate>1967.3100</sellRate>
</currency>
<currency>
<code>JPY</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>188.7600</buyRate>
<sellRate>191.2900</sellRate>
</currency>
<currency>
<code>MYR</code>
<code2>IDR</code2>
<units>07</units>
<midRate>3263.0000</midRate>
</currency>
<currency>
<code>NZD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>6887.5000</midRate>
</currency>
<currency>
<code>SAR</code>
<code2>IDR</code2>
<units>07</units>
<midRate>3581.0000</midRate>
</currency>
<currency>
<code>INR</code>
<code2>IDR</code2>
<units>07</units>
<midRate>205.0000</midRate>
</currency>
<currency>
<code>AED</code>
<code2>IDR</code2>
<units>07</units>
<midRate>3646.0000</midRate>
<buyRate>4100.0000</buyRate>
<sellRate>4213.0000</sellRate>
</currency>
<currency>
<code>CNY</code>
<code2>IDR</code2>
<units>07</units>
<midRate>2038.0000</midRate>
</currency>
<currency>
<code>PHP</code>
<code2>IDR</code2>
<units>07</units>
<midRate>286.0000</midRate>
</currency>
<currency>
<code>SEK</code>
<code2>IDR</code2>
<units>07</units>
<midRate>1300.0000</midRate>
</currency>
<currency>
<code>KRW</code>
<code2>IDR</code2>
<units>07</units>
<midRate>13.4285</midRate>
</currency>
<currency>
<code>THB</code>
<code2>IDR</code2>
<units>07</units>
<midRate>378.0000</midRate>
</currency>
<currency>
<code>NOK</code>
<code2>IDR</code2>
<units>07</units>
<midRate>1.0000</midRate>
</currency>
<currency>
<code>MUL</code>
<code2>IDR</code2>
<units>07</units>
<midRate>1.0000</midRate>
</currency>
<currency>
<code>SYA</code>
<code2>IDR</code2>
<units>07</units>
<midRate>1.0000</midRate>
</currency>
<currency>
<code>CBC</code>
<code2>IDR</code2>
<units>07</units>
<midRate>12810.0000</midRate>
</currency>
<currency>
<code>CBS</code>
<code2>IDR</code2>
<units>07</units>
<midRate>1.0000</midRate>
</currency>
<currency>
<code>FKA</code>
<code2>IDR</code2>
<units>07</units>
<midRate>109.0000</midRate>
</currency>
<currency>
<code>SGD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>0</midRate>
<buyRate>12285.0000</buyRate>
<sellRate>12492.0000</sellRate>
</currency>
<currency>
<code>TWD</code>
<code2>IDR</code2>
<units>07</units>
<midRate>413.5000</midRate>
</currency>
<currency>
<code>EUR</code>
<code2>USD</code2>
<units>07</units>
<midRate>14769.5000</midRate>
<buyRate>1.4417</buyRate>
<sellRate>1.4423</sellRate>
</currency>
<currency>
<code>AUD</code>
<code2>USD</code2>
<units>07</units>
<midRate>9965.0000</midRate>
<buyRate>1.0623</buyRate>
<sellRate>1.0631</sellRate>
</currency>
</content>
</response>
</core:transactionResponse>
</soapenv:Body>
</soapenv:Envelope>
我的XSD是
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bons0="http://service.xxx.co.id/core/bo"
targetNamespace="http://service.xxx.co.id/core/bo">
<xsd:complexType name="ExchangeRateByTypeRes">
<xsd:all>
<xsd:element minOccurs="0" name="currencyVersion"
type="xsd:dateTime">
</xsd:element>
<xsd:element minOccurs="0" name="currencyItemTotal"
type="xsd:string">
</xsd:element>
<xsd:sequence>
<xsd:element name="currency" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="currency" type="bons0:ExchangeRateByTypeInfo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:all>
</xsd:complexType>
</xsd:schema>
我做错了什么,请回答我的问题,谢谢?
答案 0 :(得分:0)
该错误消息告诉您您的架构无效。 <xsd:sequence>
中不能有<xsd:all>
元素。它只能包含<xsd:element>
或<xsd:annotation>
元素。
您可以使用<xsd:sequence>
代替<xsd:any>
:
<xsd:complexType name="ExchangeRateByTypeRes">
<xsd:sequence>
<xsd:element minOccurs="0" name="currencyVersion"
type="xsd:dateTime">
</xsd:element>
<xsd:element minOccurs="0" name="currencyItemTotal"
type="xsd:string">
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="currency" type="bons0:ExchangeRateByTypeInfo" />
</xsd:sequence>
</xsd:complexType>