gpt4 book ai didi

xml - 此命名空间中的组件不可从架构文档中引用

转载 作者:行者123 更新时间:2023-12-04 16:54:41 26 4
gpt4 key购买 nike

我知道有很多关于这个主题的问题,我已经看过了很多。但是从我阅读的所有内容来看,我的架构看起来是正确的。但是当我尝试验证架构时,我仍然收到此错误:

org.xml.sax.SAXParseException: src-resolve.4.2: Error resolving component 'addr:coordinatesElement'. It was detected that 'addr:coordinatesElement' is in namespace 'urn:ajga.address:1.0', but components from this namespace are not referenceable from schema document 'file:///C:/Users/tmcginnis/Workspaces/MyEclipse%202015%20CI/nanda-schema-0.0.1-SNAPSHOT/src/main/resources/schema/AddressSchema_1_0.xsd'. If this is the incorrect namespace, perhaps the prefix of 'addr:coordinatesElement' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///C:/Users/tmcginnis/Workspaces/MyEclipse%202015%20CI/nanda-schema-0.0.1-SNAPSHOT/src/main/resources/schema/AddressSchema_1_0.xsd'.



这是架构:
<?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>

这有什么问题?

最佳答案

命名空间前缀 tns应该设置为与 targetNameSpace 相同的 URI属性。
请注意以下 URI 之间的区别:

targetNamespace="urn:ajga:address:1.0" 
^
xmlns:tns="urn:ajga.address:1.0"
^

关于xml - 此命名空间中的组件不可从架构文档中引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33901876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com