java-SAXParseException; src-resolve:无法将名称“…”解析为(n)“类型定义”组件
作者:互联网
我正在尝试执行架构验证,当前使用的是javax.xml.validation.SchemaFactory.不幸的是,当我调用newSchema(Source schema)函数时,出现以下错误:
Caused by: org.xml.sax.SAXParseException; systemId: file:/C:/Users/C42056/Documents/workspace-sts-3.2.0.RELEASE/cec-sample-ws-integration-2-war/target/classes/WEB-INF/schemas/xsd/individual/PrivateComponentTypes_4_0.xsd; lineNumber: 33; columnNumber: 88; src-resolve: Cannot resolve the name 'utility:ObjectStatusDateType' to a(n) 'type definition' component.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseLocalElements(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
at com.sei.ec.xml.validation.SimpleXmlValidator.loadSchema(SimpleXmlValidator.java:70)
at com.sei.ec.xml.validation.SimpleXmlValidator.<init>(SimpleXmlValidator.java:83)
... 75 more
我将传递给newSchema(Source schema)函数的.xsd文件中使用Utility:ObjectStatusDateType元素.我正在从另一个.xsd文件导入ObjectStatusDateType,对此我已经三联检查了文件路径.实用程序名称空间也已正确声明.
这是我传递给函数(LocateCoverageIndexesByIdentifier_3_0.xsd)的架构的摘要:
<xs:import namespace="http://www.sei.com/utility/1/" schemaLocation="../../utility/InvocationOutcome_1_0.xsd"/>
<xs:import namespace="http://www.sei.com/utility/1/" schemaLocation="../../utility/ObjectHistory_1_0.xsd"/>
<xs:import namespace="http://www.sei.com/individual/component/4/" schemaLocation="../PrivateComponentTypes_4_0.xsd"/>
<xs:import namespace="http://www.sei.com/individual/shared/5/" schemaLocation="../IndividualTypes_5_0.xsd"/>
.
. <!-- Some more stuff -->
.
<xs:element name="coveragePeriod"
type="utility:ObjectStatusDateType"
minOccurs="0"/>
这是来自ObjectHistory_1_0.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.sei.com/utility/1/"
targetNamespace="http://www.sei.com/utility/1/"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
.
. <!-- Some more stuff -->
.
<xs:complexType name="ObjectStatusDateType">
<xs:sequence>
<xs:element name="effectiveDate" type="xs:date"/>
<xs:element name="cancelDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
最后,豆
<bean id="locateClaimValidator"
class="com.sei.ec.xml.validation.SimpleXmlValidator">
<constructor-arg>
<value>classpath:WEB-INF/schemas/xsd/individual/ci/LocateCoverageIndexesByIdentifier_3_0.xsd
</value>
</constructor-arg>
</bean>
有人遇到过此类问题吗?
解决方法:
我以前有过这个问题.一切都在Eclipse中进行了验证,但是在运行时就中断了.您的任何架构都可以将多个架构导入同一个名称空间吗?
诸如此类的东西将不起作用,但将通过Eclipse进行验证:
<import namespace="http://www.whatever.gov" location="../wherever" />
<import namespace="http://www.whatever.gov" location="../folder/superawesomeschema.xsd" />
标签:java,spring,xml,xsd,xerces 来源: https://codeday.me/bug/20191010/1886790.html