cvc-elt.1.a: Cannot find the declaration of element

2025. 1. 23. 16:13프로그래밍/java

728x90
반응형
SMALL

 

 

 

Multiple annotations found at this line:
- Downloading external resources is disabled.
cvc-elt.1.a: Cannot find the declaration of element 

 

 

Multiple annotations found at this line:
cvc-elt.1.a: Cannot find the declaration of element 'tomcat-users'.
- schema_reference.4: Failed to read schema document 'file:///C:/GH/workspace/Servers/Tomcat%20v11.0%20Server%20at%20localhost-config/tomcat-users.xsd', because 1) could not 
 find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

 

 

 

cvc-elt.1.a: Cannot find the declaration of element 에러는 XML 문서를 검증할 때 발생하는 일반적인 오류입니다. 이 메시지의 의미와 원인은 다음과 같습니다

 

의미

  • cvc-elt.1.a: "Complex Validation Constraint"의 약자로, XML Schema 기반 검증 중 특정 규칙을 위반했음을 나타냅니다.
  • "Cannot find the declaration of element": XML 문서에서 특정 요소(Element)에 대해 정의된 선언(declaration)을 찾을 수 없다는 뜻입니다.

 

원인

  1. Namespace 문제:
    • XML 문서에서 사용하는 요소가 특정 네임스페이스(namespace)에 속해 있지만, 이를 참조할 스키마 파일(.xsd)이 제대로 지정되지 않았을 때 발생합니다.
  2. 스키마 파일 누락:
    • XML 문서의 xsi:schemaLocation 또는 xsi:noNamespaceSchemaLocation 속성에 스키마 파일 경로가 올바르게 지정되지 않았거나, 해당 경로에 스키마 파일이 없을 때 발생합니다.
  3. 잘못된 요소 사용:
    • XML 문서에 사용된 요소가 스키마에서 정의되지 않았거나, 오타 등으로 인해 스키마와 일치하지 않을 경우 발생합니다.
  4. XML Schema 호환성 문제:
    • 스키마가 특정 요소를 포함하거나 해당 요소를 허용하도록 정의되지 않았을 경우 발생할 수 있습니다.

 


해결 방법

  1. 스키마 파일 확인:
    • XML 문서가 참조하는 .xsd 파일이 올바른 경로에 있고, 스키마에 필요한 요소가 정의되어 있는지 확인하세요.
  2. 네임스페이스 확인:
    • XML 문서와 .xsd 파일의 네임스페이스가 일치하는지 확인하세요. XML 문서의 루트 요소에 선언된 xmlns 속성 값을 점검하세요.
  3. 스키마 참조 경로 수정:
    • XML 문서에서 xsi:schemaLocation 또는 xsi:noNamespaceSchemaLocation 속성이 올바른 경로를 가리키고 있는지 확인하세요.
  4. XML 요소와 스키마 정의 비교:
    • XML 문서의 요소 이름, 속성 등이 스키마에서 정의된 내용과 정확히 일치하는지 검토하세요.

 


예제

문제 있는 XML

<root xmlns="http://example.com/schema"> 
    <undefinedElement>Content</undefinedElement> 
</root>
 

스키마 (.xsd)

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com/schema" 
                    xmlns="http://example.com/schema" elementFormDefault="qualified">
 
    <xs:element name="root" type="xs:string"/> 
</xs:schema>
 

해결된 XML

<root xmlns="http://example.com/schema"> 
    <root>Content</root> 
</root>
 

위와 같이 요소 이름과 네임스페이스를 정확히 일치시키면 문제가 해결됩니다.

 

 


실제 해결한 사례1

 

Multiple annotations found at this line:
- Downloading external resources is disabled.
cvc-elt.1.a: Cannot find the declaration of element 

 

Window > Preference

  >>> XML (Wild Web Developer)

         1. 체크 : Download external resources like referenced DTD, XSD

         2. Apply 버튼 클릭

 



 


실제 해결한 사례2

 

Multiple annotations found at this line:
cvc-elt.1.a: Cannot find the declaration of element 'tomcat-users'.
- schema_reference.4: Failed to read schema document 'file:///C:/GH/workspace/Servers/Tomcat%20v11.0%20Server%20at%20localhost-config/tomcat-users.xsd', because 1) could not 
 find the document; 2) the document could not be read; 3) the root element of the document is not .

 

 

 

 

하기 파일을 추가 시킴

/Servers/Tomcat v11.0 Server at localhost-config/tomcat-users.xsd

 

 

 

 

 

 

 

728x90
반응형
LIST