문서에 대한 문법 제한 조건 (DTD 또는 XML 스키마)이 발견되지 않았습니다.
나는이 dtd를 가지고있다 : http://fast-code.sourceforge.net/template.dtd 그러나 xml에 포함시킬 때 경고를 얻는다 : 문서에 대한 문법 제약 (DTD 또는 XML 스키마)이 감지되지 않았다. xml은 다음과 같습니다
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE templates PUBLIC "//UNKNOWN/" "http://fast-code.sourceforge.net/template.dtd">
<templates>
<template type="INSTANCE_OF_CLASS">
<description>Used to Create instance of class</description>
<variation>asasa</variation>
<variation-field>asasa</variation-field>
<class-pattern>asasa</class-pattern>
<getter-setter>setter</getter-setter>
<allowed-file-extensions>java</allowed-file-extensions>
<number-required-classes>1</number-required-classes>
<allow-multiple-variation>false</allow-multiple-variation>
<template-body>
<![CDATA[
// Creating new instance of ${class_name}
final ${class_name} ${instance} = new ${class_name}();
#foreach ($field in ${fields})
${instance}.${field.setter}(${field.value});
#end
]]>
</template-body>
</template>
</templates>
편집 : xml을 변경했는데 지금이 오류가 발생합니다.
요소 유형 "템플릿"의 내용은 "(설명, 변형?, 변형 필드?, 허용 다변량?, 클래스 패턴?, 게터 설정?, 허용 된 파일 확장명?, 숫자 필요)와 일치해야합니다. 클래스?, 서식 파일)).
내 경우에는 단순히 태그 <!DOCTYPE xml>
뒤에 after 를 추가 하여이 성가신 경고를 해결했습니다 <?xml ... >
.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
이것은 Eclipse 3.7.1에서 나를 위해 일했습니다 : 환경 설정 창으로 이동 한 다음 XML-> XML 파일-> 유효성 검사로 이동하십시오. 그런 다음 오른쪽에있는 환경 설정 패널의 파일 유효성 검증 섹션에서 "문법 지정되지 않음"환경 설정의 드롭 다운 상자에서 무시를 선택하십시오. 경고가 사라지도록 파일을 닫았다가 다시 열어야 할 수도 있습니다.
(이 질문은 오래되었다는 것을 알고 있지만 경고를 검색 할 때 처음 발견 한 것이므로 다른 검색자를 위해 여기에 답변을 게시하고 있습니다.)
대답:
아래 DTD의 각 부분에 대한 의견. 자세한 내용은 공식 사양 을 참조하십시오 .
<!
DOCTYPE ----------------------------------------- correct
templates --------------------------------------- correct Name matches root element.
PUBLIC ------------------------------------------ correct Accessing external subset via URL.
"//UNKNOWN/" ------------------------------------ invalid? Seems useless, wrong, out-of-place.
Safely replaceable by DTD URL in next line.
"http://fast-code.sourceforge.net/template.dtd" - invalid URL is currently broken.
>
간단한 설명 :
매우 기본적인 DTD는 다음 두 번째 줄과 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nameOfYourRootElement>
<nameOfYourRootElement>
</nameOfYourRootElement>
상해:
DTD는 합의 된 데이터 형식을 설정하고 그러한 데이터의 수신을 확인하는 역할을합니다. 이들은 다음을 포함하여 XML 문서의 구조를 정의합니다.
- 법적 요소 목록
- 특수 문자
- 문자열
- 그리고 훨씬 더
예 :
<!DOCTYPE nameOfYourRootElement
[
<!ELEMENT nameOfYourRootElement (nameOfChildElement1,nameOfChildElement2)>
<!ELEMENT nameOfChildElement1 (#PCDATA)>
<!ELEMENT nameOfChildElement2 (#PCDATA)>
<!ENTITY nbsp " ">
<!ENTITY author "Your Author Name">
]>
Meaning of above lines...
Line 1) Root element defined as "nameOfYourRootElement"
Line 2) Start of element definitions
Line 3) Root element children defined as "nameOfYourRootElement1" and "nameOfYourRootElement2"
Line 4) Child element, which is defined as data type #PCDATA
Line 5) Child element, which is defined as data type #PCDATA
Line 6) Expand instances of
to  
when document is parsed by XML parser
Line 7) Expand instances of &author;
to Your Author Name
when document is parsed by XML parser
Line 8) End of definitions
The Real Solution:
add <!DOCTYPE something>
to the begining of each problematic XML,
after the xml tag <?xml version="1.0" encoding="utf-8"?>
you can write anything for doctype, but basically it's supposed to be manifest, activity, etc. from what I understand
Have you tried to add a schema to xml catalog?
in eclipse to avoid the "no grammar constraints (dtd or xml schema) detected for the document." i use to add an xsd schema file to the xml catalog under
"Window \ preferences \ xml \ xml catalog \ User specified entries".
Click "Add" button on the right.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<HolidayRequest xmlns="http://mycompany.com/hr/schemas">
<Holiday>
<StartDate>2006-07-03</StartDate>
<EndDate>2006-07-07</EndDate>
</Holiday>
<Employee>
<Number>42</Number>
<FirstName>Arjen</FirstName>
<LastName>Poutsma</LastName>
</Employee>
</HolidayRequest>
From this xml i have generated and saved an xsd under: /home/my_user/xsd/my_xsd.xsd
As Location: /home/my_user/xsd/my_xsd.xsd
As key type: Namespace name
As key: http://mycompany.com/hr/schemas
Close and reopen the xml file and do some changes to violate the schema, you should be notified
Add DOCTYPE tag ...
In this case:
<!DOCTYPE xml>
Add after:
<?xml version="1.0" encoding="UTF-8"?>
So:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
For me it was a Problem with character encoding and unix filemode running eclipse on Windows:
Just marked the complete code, cutted and pasted it back (in short: CtrlA-CtrlX-CtrlV) and everything was fine - no more "No grammar constraints..." warnings
A new clean way might be to write your xml like so:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE rootElement>
<rootElement>
....
</rootElement>
The above works in Eclipse Juno+
I can't really say why you get the "No grammar constraints..." warning, but I can provoke it in Eclipse by completely removing the DOCTYPE declaration. When I put the declaration back and validate again, I get this error message:
The content of element type "template" must match "(description+,variation?,variation-field?,allow-multiple-variation?,class-pattern?,getter-setter?,allowed-file-extensions?,template-body+).
And that is correct, I believe (the "number-required-classes" element is not allowed).
i know this is old but I'm passing trought the same problem and found the solution in the spring documentation, the following xml configuration has been solved the problem for me.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
<!-- THIS IS THE LINE THAT SOLVE MY PROBLEM -->
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
before I put the line above as sugested in this forum topic , I have the same warning message, and placing this...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
and it give me the following warning message...
The content of element type "template" must match "
(description,variation?,variation-field?,allow- multiple-variation?,class-
pattern?,getter-setter?,allowed-file-extensions?,number-required-
classes?,template-body)".
so just try to use the sugested lines of my xml configuration.
This may be due to turning off validation in eclipse.
Solved this issue in Eclipse 3.5.2. Two completely identical layouts of which one had the warning. Closed down all tabs and when reopening the warning had disappeared.
- copy your entire code in notepad.
- temporarily save the file with any name [while saving the file use "encoding" = UTF-8 (or higher but UTF)].
- close the file.
- open it again.
- copy paste it back on your code.
error must be gone.
I used a relative path in the xsi:noNamespaceSchemaLocation to provide the local xsd file (because I could not use a namespace in the instance xml).
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../project/schema.xsd">
</root>
Validation works and the warning is fixed (not ignored).
https://www.w3schools.com/xml/schema_example.asp
I too had the same problem in eclipse using web.xml file
it showed me this " no grammar constraints referenced in the document "
but it can be resolved by adding tag
after the xml tag i.e. <?xml version = "1.0" encoding = "UTF-8"?>
Here's the working solution for this problem:
Step 1: Right click on project and go to properties
Step 2: Go to 'libraries' and remove the project's ' JRE system library'
Step 3: Click on 'Add library'-->'JRE System Library' -->select 'Workspace default JRE'
Step 3: Go to 'Order and Export' and mark the newly added ' JRE system library'
Step 4: Refresh and Clean the project
Eureka! It's working :)
What I found to be the solution was something very very simple that I think you should try before tinkering with the preferences. In my case I had this problem in a strings file that had as a base tag "resources" ...all I did was delete the tag from the top and the bottom, clean the project, save the file and reinsert the tag. The problem has since disappeared and never gave me any warnings. It may sound to simple to be true but hey, sometimes it's the simplest things that solve the problems. Cheers
I deleted the warning in the problems view. It didn't come back till now.
'IT' 카테고리의 다른 글
Maven“Module”과“Project”(Eclipse, m2eclipse 플러그인) (0) | 2020.05.15 |
---|---|
지시어 정의의 transclude 옵션을 이해하고 있습니까? (0) | 2020.05.14 |
RecyclerView 스크롤을 비활성화하는 방법은 무엇입니까? (0) | 2020.05.14 |
일치하는 값이 포함 된 해시 키를 찾는 방법 (0) | 2020.05.14 |
오류가 발생하면 자동으로 파이썬 디버거 시작 (0) | 2020.05.14 |