Erro:org.xml.sax.SAXParseException:cvc-complex-type.2.3

时间:2015-06-12 19:29:49

标签: java xml web-services xsd

我正在使用" umarshall" - XSD验证:

      <xs:complexType>
        <xs:sequence maxOccurs="50">
          <xs:element name="docZip">
            <xs:annotation>
              <xs:documentation>Informação resumida ou documento fiscal eletrônico de interesse da pessoa ou empresa. O conteúdo desta tag estará compactado no padrão gZip. O tipo do campo é base64Binary.</xs:documentation>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:any processContents="skip">
                  <xs:annotation>
                    <xs:documentation>Estrutura genérica do documento fiscal eletrônico</xs:documentation>
                  </xs:annotation>
                </xs:any>
              </xs:sequence>
              <xs:attribute name="NSU" type="TNSU" use="required">
                <xs:annotation>
                  <xs:documentation>NSU do documento fiscal</xs:documentation>
                </xs:annotation>
              </xs:attribute>
              <xs:attribute name="schema" type="xs:string" use="required">
                <xs:annotation>
                  <xs:documentation>Identificação do Schema XML que será utilizado para validar o XML existente no campo seguinte. Vai identificar o tipo do documento e sua versão. Exemplos: resNFe_v1.00.xsd, procNFe_v3.10.xsd, resEvento_1.00.xsd, procEventoNFe_v1.00.xsd</xs:documentation>
                </xs:annotation>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>

我有这个例外:

[org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'docZip' cannot have character [children], because the type's content type is element-only.]

有谁知道错误是什么?

1 个答案:

答案 0 :(得分:1)

看起来当您尝试解组使用上述service response or request xml的{​​{1}}时,xml的xsd元素中包含一些文本,其中包含其子元素。如下图所示。

'docZip'

这就是xsd验证失败的原因。因此捕获实际的xml并查看docZip元素中是否没有直接文本

有关此错误的详细信息,请参阅this链接