我必须解析一个xml文件,并对XSD进行验证。但是当我用JAXB解析xml文件时,在解析XSD文件时发现了一些错误。
<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>和XML文件
<?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>在解析文件时,我发现了一个错误:
3.2.2:属性'xsi:schemalocation‘不允许出现在元素’jtis_ to _list‘中。
我该怎么解决这个问题?
发布于 2016-07-01 11:10:29
在源文档中,该属性拼写正确。
xsi:schemaLocation但是在错误消息中,它有拼写。
xsi:schemalocation
^我怀疑您正在向我们展示更正的版本,并且您实际验证的文档拼写错误。
https://stackoverflow.com/questions/38141020
复制相似问题