我知道有很多关于这个问题的问题,我看了很多。但是从我读到的所有内容来看,我的架构看起但是当我尝试验证架构时,我仍然遇到此错误:
org.xml.sax.SAXParseException:src-resolve.4.2:解析组件' addr:coordinatesElement'时出错。检测到' addr:coordinatesElement'在名称空间' urn:ajga.address:1.0',但来自此命名空间的组件无法从架构文档&file:/// C:/ Users / tmcginnis / Workspaces / MyEclipse%引用202015%20CI /南大-架构0.0.1-SNAPSHOT / SRC /主/资源/模式/ AddressSchema_1_0.xsd&#39 ;.如果这是不正确的命名空间,可能是' addr:coordinatesElement'的前缀。需要改变。如果这是正确的命名空间,那么适当的导入'标签应添加到' file:/// C:/Users/tmcginnis/Workspaces/MyEclipse%202015%20CI/nanda-schema-0.0.1-SNAPSHOT/src/main/resources/schema/AddressSchema_1_0.xsd& #39;
这是架构:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:ajga:address:1.0"
xmlns:tns="urn:ajga.address:1.0"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
<xsd:element name="address">
<xsd:complexType>
<xsd:all>
<xsd:element name="addressType" type="xsd:string" minOccurs="0"/>
<xsd:element name="addressLine1" type="xsd:string"/>
<xsd:element name="addressLine2" type="xsd:string" minOccurs="0"/>
<xsd:element name="pobox" type="xsd:string" minOccurs="0"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:string"/>
<xsd:element name="countyCode" type="xsd:string" minOccurs="0"/>
<xsd:element name="country" type="xsd:string"/>
<xsd:element name="fips" type="xsd:string" minOccurs="0"/>
<xsd:element name="coordinates" type="tns:coordinatesElement" minOccurs="0"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="coordinatesElement">
<xsd:all>
<xsd:element name="longitude" type="xsd:string"/>
<xsd:element name="lattitude" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
这有什么问题?
答案 0 :(得分:0)
名称空间前缀tns
应设置为与targetNameSpace
属性相同的URI。
注意以下URI之间的区别:
targetNamespace="urn:ajga:address:1.0"
^
xmlns:tns="urn:ajga.address:1.0"
^