2016-07-01 6 views
0

Ich muss eine XML-Datei mit Validierung bezüglich XSD analysieren. aber wenn ich die XML-Datei mit JAXB analysieren fand ich einige Fehler beim Parsen XSD-Dateicvc-complex-type.3.2.2: Das Attribut 'xsi: schemalocation' darf nicht im Element 'jtis_journey_list' erscheinen.

<xs:schema attributeFormDefault="unqualified" 
      elementFormDefault="qualified" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      targetNamespace="http://data.one.gov.hk/td" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="jtis_journey_list"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="jtis_journey_time" 
        maxOccurs="unbounded" 
        minOccurs="0"> 
      <xs:complexType> 
      <xs:choice maxOccurs="unbounded" minOccurs="0"> 
       <xs:element type="xs:string" name="location_id"/> 
       <xs:element type="xs:string" name="destination_id"/> 
       <xs:element type="xs:dateTime" name="capture_date" 
          minOccurs="0"/> 
       <xs:element type="xs:byte" name="journey_type"/> 
       <xs:element type="xs:byte" name="journey_data"/> 
       <xs:element type="xs:byte" name="colour_id"/> 
       <xs:element type="xs:string" name="journey_desc" 
          minOccurs="0"/> 
      </xs:choice> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

und XML-Datei

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<jtis_journey_list 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://data.one.gov.hk/td 
         http://data.one.gov.hk/xsd/td/journeytime.xsd" 
    xmlns="http://data.one.gov.hk/td"> 
    <jtis_journey_time> 
    <LOCATION_ID>H11</LOCATION_ID> 
    <DESTINATION_ID>CH</DESTINATION_ID> 
    <CAPTURE_DATE>2016-07-01T14:56:35</CAPTURE_DATE> 
    <JOURNEY_TYPE>1</JOURNEY_TYPE> 
    <JOURNEY_DATA>12</JOURNEY_DATA> 
    <COLOUR_ID>3</COLOUR_ID> 
    <JOURNEY_DESC></JOURNEY_DESC> 
    </jtis_journey_time> 
    <jtis_journey_time> 
    <LOCATION_ID>H11</LOCATION_ID> 
    <DESTINATION_ID>EH</DESTINATION_ID> 
    <CAPTURE_DATE>2016-07-01T14:56:35</CAPTURE_DATE> 
    <JOURNEY_TYPE>1</JOURNEY_TYPE> 
    <JOURNEY_DATA>4</JOURNEY_DATA> 
    <COLOUR_ID>3</COLOUR_ID> 
    <JOURNEY_DESC></JOURNEY_DESC> 
    </jtis_journey_time> 
</jtis_journey_list> 

Während Parsen der Datei ich einen Fehler gefunden:

cvc-complex-type.3.2.2: Attribute 'xsi:schemalocation' is not allowed to appear in element 'jtis_journey_list'.

Wie löse ich das?

Antwort

1

In Ihrem Quelldokument wird das Attribut richtig

Dinkel
xsi:schemaLocation 

Aber in der Fehlermeldung hat es die Schreibweise

xsi:schemalocation 
     ^

Ich vermute, dass Sie uns die korrigierte Version angezeigt werden, und dass die Dokument, das Sie tatsächlich validiert hatten, hatte die falsche Schreibweise.

Verwandte Themen