복붙노트

[SPRING] SAXParseException; src-resolve : 이름 '...'을 (n) '유형 정의'구성 요소로 해석 할 수 없습니다.

SPRING

SAXParseException; src-resolve : 이름 '...'을 (n) '유형 정의'구성 요소로 해석 할 수 없습니다.

스키마 유효성 검사를하려고하는데, 현재 javax.xml.validation.SchemaFactory를 사용하고 있습니다. 불행히도 newSchema (소스 스키마) 함수를 호출하면 다음 오류가 발생합니다.

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

유틸리티 : ObjectStatusDateType 요소는 newSchema (소스 스키마) 함수에 전달할 .xsd 파일에서 사용됩니다. ObjectStatusDateType을 다른 .xsd 파일에서 가져 오는 중입니다.이 파일에 대해 파일 경로를 확인했습니다. 유틸리티 네임 스페이스도 올바르게 선언됩니다.

다음은 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>

누구든지 이런 유형의 문제가 발생 했습니까?

해결법

  1. ==============================

    1.전에이 문제를 겪었습니다. 모든 것이 Eclipse에서 유효성을 확인했지만 실행 중에 중단되었습니다. 스키마 중 하나라도 둘 이상의 스키마를 동일한 네임 스페이스로 가져올 수 있습니까?

    전에이 문제를 겪었습니다. 모든 것이 Eclipse에서 유효성을 확인했지만 실행 중에 중단되었습니다. 스키마 중 하나라도 둘 이상의 스키마를 동일한 네임 스페이스로 가져올 수 있습니까?

    이 같은 것은 작동하지 않지만 Eclipse에 의해 검증 될 것입니다 :

    <import namespace="http://www.whatever.gov" location="../wherever" />
    <import namespace="http://www.whatever.gov" location="../folder/superawesomeschema.xsd" />
    
  2. ==============================

    2.많은 사람들이 전에 이런 유형의 문제에 직면했습니다. 어떤 이유로 든 유효성 검사기가 올 때마다로드하려는 스키마 문서를로드하지 않습니다 (로드하는 것으로 생각합니다).

    많은 사람들이 전에 이런 유형의 문제에 직면했습니다. 어떤 이유로 든 유효성 검사기가 올 때마다로드하려는 스키마 문서를로드하지 않습니다 (로드하는 것으로 생각합니다).

    진단을 확인하려면 ObjectHistory_1_0.xsd에 오류 (예 : 올바른 형식의 오류)를 입력하고 시스템에서 불만이 있는지 확인합니다.

  3. ==============================

    3.Xerces를 사용하면이 기능을 설정하여 해결할 수 있습니다. http://apache.org/xml/features/honour-all-schemaLocations를 true로 설정하십시오.

    Xerces를 사용하면이 기능을 설정하여 해결할 수 있습니다. http://apache.org/xml/features/honour-all-schemaLocations를 true로 설정하십시오.

    http://apache.org/xml/features/honour-all-schema 기능은 사용할 수 없습니다. Xerces 2.7.0에서. Java 5.0 및 6.0의 현재 릴리스에는 Xerces 2.6.2가 있습니다. 붙박이. 따라서이 작업을 위해서는 최신 Xerces 라이브러리를 사용해야합니다. 즉. xml-apis.jar 및 xercesImpl.jar을 / jre / lib / endorsed에 복사하고 / jre에 jaxp.properties 파일을 작성해 그 행을 포함합니다.

    javax.xml.validation.SchemaFactory\:http\://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory
    
  4. ==============================

    4.maven plugin jaxb2-maven-plugin을 실행할 때 동일한 문제가 발생했습니다. 명시 적으로 xsd 파일을 구문 분석 한 후, 그것은 매력처럼 작동했습니다.

    maven plugin jaxb2-maven-plugin을 실행할 때 동일한 문제가 발생했습니다. 명시 적으로 xsd 파일을 구문 분석 한 후, 그것은 매력처럼 작동했습니다.

    <plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>jaxb2-maven-plugin</artifactId>
     <version>1.6</version>
        <executions>
         <execution>
          <id>xjc</id>
          <goals>
           <goal>xjc</goal>
          </goals>
         </execution>
        </executions>
        <configuration>
         <schemaFiles>MySchema.xsd</schemaFiles>
         <outputDirectory>src/main/java</outputDirectory>
        </configuration>
    </plugin> 
    
  5. from https://stackoverflow.com/questions/18853890/saxparseexception-src-resolve-cannot-resolve-the-name-to-an-type-defi by cc-by-sa and MIT license