如何修复“没有文档检测到语法约束”的Eclipse验证错误?

时间:2022-10-16 22:22:45

Eclipse 3.5.2 is throwing an XML schema warning message:

Eclipse 3.5.2正在抛出一个XML模式警告消息:

No grammar constraints (DTD or XML schema) detected for the document.

The application.xml file:

应用程序。xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<application
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/application_5.xsd"
  version="5">

</application>

I do not want to disable the warning. How can I get Eclipse to correctly validate the XML document?

我不想禁用警告。如何让Eclipse正确地验证XML文档?

16 个解决方案

#1


40  

Not sure if you ever resolved this satisfactorily but I ran across this posting today while working with some Spring configuration files in Eclipse 3.6. I could not get the error to go away in the Problems view in Eclipse no matter what, until I right-clicked on the problem and deleted it.

不确定您是否已经满意地解决了这个问题,但是我今天在Eclipse 3.6中处理一些Spring配置文件时偶然看到了这篇文章。无论如何,在Eclipse的Problems视图中,我都无法获得错误,直到我右键单击该问题并将其删除。

I figured it would come back if I revalidated and there was actually a problem and so far it hasn't. The thing is I had an almost identical Spring config file that wasn't showing the error.

我想如果我重新验证了,它会回来的,而且实际上有一个问题,到目前为止还没有。问题是我有一个几乎相同的Spring配置文件,它没有显示错误。

It would seem that sometimes stuff just gets stuck in Eclipse. Not sure why but between this and files getting out of sync with the editors and having to force a refresh I guess I have to accept it.

看起来有时候东西会在Eclipse中卡住。不知道为什么,但是在这个和文件与编辑器不同步以及不得不强制刷新之间,我想我必须接受它。

#2


54  

Putting this at the top of any offending file works for me:

把这个放在任何违规文件的顶部对我来说都是可行的:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE project>

#3


31  

This is another way to turn off warnings for XML Documents that intentionally lack a DTP or XSD:

这是另一种关闭有意缺少DTP或XSD的XML文档警告的方法:

  1. Go to Menu Preferences,
  2. 菜单的偏好,
  3. in the navig menu, i.e. the Left frame of the dialog-box, Choose: XML > XML Files > Validation
  4. 在导航菜单中,即对话框的左侧框架,选择:XML > XML文件>验证。
  5. in the config area, i.e the right frame of the dialog-box, choose: Validating Files > No grammar specified > Ignore (This is a select box) default setting is warning)
  6. 在配置区域,i。e对话框的正确框架,选择:验证文件>没有语法指定的>忽略(这是一个选择框)默认设置为警告)

#4


6  

I am not an expert but a learner. I accidentally found an easy and stupid way to solve the problem. What you just need to do is:

我不是专家,而是学习者。我偶然发现了一个简单而愚蠢的方法来解决这个问题。你只需要做的是:

Press ctrl + shift + F (it's a shortcut to format the file in Eclipse)

按ctrl + shift + F(这是在Eclipse中格式化文件的快捷方式)

If this does not solve the problem then press the TAB key at the starting of this particular line
?xml version="1.0" encoding="UTF-8"? and not anywhere else (I don't not why, but this works. If anyone here knows why I will be very happy to know)

如果这不能解决问题,那么在这一行的开头按TAB键?xml版本=“1.0”编码=“UTF-8”?其他任何地方都没有(我不知道为什么,但这是可行的。如果这里有人知道为什么我会很高兴知道)

Then press ctrl + shift + F and save.

然后按ctrl + shift + F保存。

The warning will be gone, at least for me, you may try for yourself...

警告将会消失,至少对我来说,你可以自己尝试一下……

#5


5  

If this warning shows up it means the XML Validate function (which is different from the XML instance editor!) did not know what DTD or XSD to apply. This of course also means it did not actually check if the XML instance was compliant to any schema.

如果出现此警告,则意味着XML验证函数(与XML实例编辑器不同!)不知道应用什么DTD或XSD。当然,这也意味着它实际上没有检查XML实例是否符合任何模式。

This is therefore a helpful warning, it should not be turned off (if you use the Validate menu function and expect it to do something).

因此,这是一个有用的警告,不应该关闭它(如果您使用Validate menu函数并期望它做一些事情)。

You can use the preferences to make your schema known:

您可以使用首选项使您的模式为人所知:

  • Open Preferences / XML Catalog / User Specified Entries
  • 打开首选项/ XML目录/用户指定的条目
  • Click Add...
  • 单击Add……
  • Enter the XSD file to use in "Location"
  • 输入要在“Location”中使用的XSD文件
  • Select Key Type "Schema location" (in case you have a xsi:schemaLocation)
  • 选择密钥类型“模式位置”(如果您有xsi:schemaLocation)
  • Enter the URL (second part of the location) matching the files content as "Key"
  • 输入匹配文件内容作为“键”的URL(位置的第二部分)
  • Press OK
  • 按OK
  • Go to Problem view and delete the validation warning
  • 转到问题视图并删除验证警告
  • Right-Click the XML File and Chose "Validate" again
  • 右键单击XML文件并再次选择“Validate”

Some public idenditfiers and schema locations are already contained in the "Plugin Specified Entries" (especially if you have WSTP installed). For those namespaces you do not get the warning (As it uses the system provided copy to validate).

一些公共恒等符和模式位置已经包含在“插件指定条目”中(特别是如果安装了WSTP)。对于那些名称空间,您不会得到警告(因为它使用系统提供的副本进行验证)。

#6


3  

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

在eclipse中,为了避免为文档检测到“没有语法约束(dtd或xml模式)”,我使用xsd模式文件添加到xml目录下

"Window \ preferences \ xml \ xml catalog \ User specified entries".

“窗口\ preferences \ xml \ xml目录\用户指定的条目”。

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

从这个xml中,我生成并保存了一个xsd: /home/my_user/xsd/my_xsd

As Location: /home/my_user/xsd/my_xsd.xsd

位置:/home/my_user/xsd/my_xsd.xsd

As key type: Namespace name

作为键类型:命名空间名称

As key: http://mycompany.com/hr/schemas

关键:http://mycompany.com/hr/schemas


Close and reopen the xml file and do some changes to violate the schema, you should be notified.

关闭并重新打开xml文件并做一些更改以违反模式,您应该得到通知。

#7


2  

I had some success going back to V1.4 of application.xsd. If anyone can explain why the JavaEE version does not work, I would appreciate it.

回到application.xsd的V1.4时,我取得了一些成功。如果有人能解释为什么JavaEE版本不能工作,我将非常感激。

<?xml version="1.0" encoding="UTF-8"?>
<application
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                      http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
  version="1.4">

#8


1  

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'

步骤2:转到“libraries”并删除项目的“JRE system library”

Step 3: Click on 'Add library'-->'JRE System Library' -->select 'Workspace default JRE'

步骤3:点击“添加库”——>“JRE系统库”——>选择“工作区默认JRE”

Step 3: Go to 'Order and Export' and mark the newly added ' JRE system library'

第3步:进入“订单和导出”并标记新添加的“JRE系统库”

Step 4: Refresh and Clean the project

步骤4:刷新并清理项目

Eureka! It's working :)

尤里卡!它的工作:)

#9


1  

Add this to your xml file's very beginning:

将此添加到xml文件的开头:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RelativeLayout>

Change RelativeLayout to your defined root layout ,then find xml file in left side, in layout folder, right click and select Validate.

将相对布局更改为您定义的根布局,然后在左侧找到xml文件,在layout文件夹中,右键单击并选择Validate。

#10


0  

What I found worked for me was to remove the schemaLocation attribute completely then right click in the outline view and goto edit namespaces, then adding the schema location hint into the resulting dialog.

我发现对我有用的是完全删除schemaLocation属性,然后在outline视图中右键单击并编辑名称空间,然后在结果对话框中添加模式位置提示。

#11


0  

It can be because of your proxy settings. See this and this. You can try attaching javadoc by URL to a library without it. If it is okay in your browser, but not in your editor, then it's a connection problem. I solved the same problem by asking the admin about the proxy settings. Although all other applications did work, eclipse didn't, so I had to enter the config "manually". It would be great if developers added a button "check connection"...

这可能是因为您的代理设置。看看这个和这个。您可以尝试通过URL将javadoc附加到没有它的库中。如果在浏览器中没有问题,但是在编辑器中没有问题,那么这就是一个连接问题。我通过询问管理员关于代理设置的问题解决了同样的问题。虽然所有其他应用程序都可以工作,但是eclipse没有,所以我必须“手动”输入配置。如果开发人员增加一个按钮“检查连接”,那就太棒了。

#12


0  

Solution For Eclipse:

解决方案为Eclipse:

add <!DOCTYPE something> to the begining of each problematic XML,

添加一个< !DOCTYPE something>从每个有问题的XML开始,

after the xml tag <?xml version="1.0" encoding="utf-8"?>

在xml标记

you can write anything for doctype, but basically it's supposed to be manifest, activity, etc. from what I understand

您可以为doctype编写任何内容,但从我的理解来看,它基本上应该是manifest、activity等等

#13


0  

I was just having this problem last night (using eclipse V.kepler). I am completely new to java and eclipse and I am trying to teach myself how to make an android app. While I was working on the lessons offered at developers.android.com I had input this into my main_activity_actions.xml file:

我昨晚刚刚遇到这个问题(使用eclipse V.kepler)。我对java和eclipse完全陌生,我正在自学如何制作一个android应用程序。xml文件:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<!--  Search should appear as an action button -->
<item android:id="@+id/action_search"
      android:icon="@drawable/ic_action_search"
      android:title="@string/action_search"
      android:showAsAction="ifRoom"/>

</menu>

This gave me the same error as OP. I tried following the suggestion of adding

这给了我和opo一样的错误,我尝试按照增加的建议去做

<!DOCTYPE project> 

just below the first line and it solved the issue.

就在第一行下面,它解决了问题。

#14


0  

What worked for me is to right click the xml-file in the tree (usually on the left hand side in eclipse) and clicked the validate. Since then, the warning never came back.

对我有用的是右键单击树中的xml文件(通常在eclipse的左边)并单击validate。从那以后,警告再也没有回来。

#15


0  

Here's what worked for me. I was using schemas without version numbers (e.g. spring-beans.xsd, and not spring-beans-4.1.xsd) and they probably got updated upstream. I assume the problem was that Eclipse kept a dirty cache of the old versions.

这是对我有用的。我使用的是没有版本号的模式(例如spring-beans)。xsd,而不是spring-bean -4.1.xsd),它们可能会在上游得到更新。我认为问题在于Eclipse保留了旧版本的脏缓存。

Fix :
1. Go to Window -> Preference -> Network Connection -> Cache
2. Remove all cached schemas.
3. Delete all the no grammar constraints problems in problem view.
4. Re-validate the project.

解决办法:1。转到窗口->首选项->网络连接->缓存2。清除所有缓存模式。3所示。删除问题视图中的所有无语法约束问题。4所示。Re-validate项目。

#16


0  

for me it worked like a charm when I cut it (ctrl a + ctrl - X) and saved it back again (ctrl-s) ! the warning "No grammar constraints (DTD or XML schema) detected for the document" was gone for good!!

对我来说,当我把它剪下来(按ctrl a + ctrl- X),再把它保存回来(按ctrl-s)的时候,它就像一个咒语!为文档检测到的“没有语法约束(DTD或XML模式)”警告消失了!

#1


40  

Not sure if you ever resolved this satisfactorily but I ran across this posting today while working with some Spring configuration files in Eclipse 3.6. I could not get the error to go away in the Problems view in Eclipse no matter what, until I right-clicked on the problem and deleted it.

不确定您是否已经满意地解决了这个问题,但是我今天在Eclipse 3.6中处理一些Spring配置文件时偶然看到了这篇文章。无论如何,在Eclipse的Problems视图中,我都无法获得错误,直到我右键单击该问题并将其删除。

I figured it would come back if I revalidated and there was actually a problem and so far it hasn't. The thing is I had an almost identical Spring config file that wasn't showing the error.

我想如果我重新验证了,它会回来的,而且实际上有一个问题,到目前为止还没有。问题是我有一个几乎相同的Spring配置文件,它没有显示错误。

It would seem that sometimes stuff just gets stuck in Eclipse. Not sure why but between this and files getting out of sync with the editors and having to force a refresh I guess I have to accept it.

看起来有时候东西会在Eclipse中卡住。不知道为什么,但是在这个和文件与编辑器不同步以及不得不强制刷新之间,我想我必须接受它。

#2


54  

Putting this at the top of any offending file works for me:

把这个放在任何违规文件的顶部对我来说都是可行的:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE project>

#3


31  

This is another way to turn off warnings for XML Documents that intentionally lack a DTP or XSD:

这是另一种关闭有意缺少DTP或XSD的XML文档警告的方法:

  1. Go to Menu Preferences,
  2. 菜单的偏好,
  3. in the navig menu, i.e. the Left frame of the dialog-box, Choose: XML > XML Files > Validation
  4. 在导航菜单中,即对话框的左侧框架,选择:XML > XML文件>验证。
  5. in the config area, i.e the right frame of the dialog-box, choose: Validating Files > No grammar specified > Ignore (This is a select box) default setting is warning)
  6. 在配置区域,i。e对话框的正确框架,选择:验证文件>没有语法指定的>忽略(这是一个选择框)默认设置为警告)

#4


6  

I am not an expert but a learner. I accidentally found an easy and stupid way to solve the problem. What you just need to do is:

我不是专家,而是学习者。我偶然发现了一个简单而愚蠢的方法来解决这个问题。你只需要做的是:

Press ctrl + shift + F (it's a shortcut to format the file in Eclipse)

按ctrl + shift + F(这是在Eclipse中格式化文件的快捷方式)

If this does not solve the problem then press the TAB key at the starting of this particular line
?xml version="1.0" encoding="UTF-8"? and not anywhere else (I don't not why, but this works. If anyone here knows why I will be very happy to know)

如果这不能解决问题,那么在这一行的开头按TAB键?xml版本=“1.0”编码=“UTF-8”?其他任何地方都没有(我不知道为什么,但这是可行的。如果这里有人知道为什么我会很高兴知道)

Then press ctrl + shift + F and save.

然后按ctrl + shift + F保存。

The warning will be gone, at least for me, you may try for yourself...

警告将会消失,至少对我来说,你可以自己尝试一下……

#5


5  

If this warning shows up it means the XML Validate function (which is different from the XML instance editor!) did not know what DTD or XSD to apply. This of course also means it did not actually check if the XML instance was compliant to any schema.

如果出现此警告,则意味着XML验证函数(与XML实例编辑器不同!)不知道应用什么DTD或XSD。当然,这也意味着它实际上没有检查XML实例是否符合任何模式。

This is therefore a helpful warning, it should not be turned off (if you use the Validate menu function and expect it to do something).

因此,这是一个有用的警告,不应该关闭它(如果您使用Validate menu函数并期望它做一些事情)。

You can use the preferences to make your schema known:

您可以使用首选项使您的模式为人所知:

  • Open Preferences / XML Catalog / User Specified Entries
  • 打开首选项/ XML目录/用户指定的条目
  • Click Add...
  • 单击Add……
  • Enter the XSD file to use in "Location"
  • 输入要在“Location”中使用的XSD文件
  • Select Key Type "Schema location" (in case you have a xsi:schemaLocation)
  • 选择密钥类型“模式位置”(如果您有xsi:schemaLocation)
  • Enter the URL (second part of the location) matching the files content as "Key"
  • 输入匹配文件内容作为“键”的URL(位置的第二部分)
  • Press OK
  • 按OK
  • Go to Problem view and delete the validation warning
  • 转到问题视图并删除验证警告
  • Right-Click the XML File and Chose "Validate" again
  • 右键单击XML文件并再次选择“Validate”

Some public idenditfiers and schema locations are already contained in the "Plugin Specified Entries" (especially if you have WSTP installed). For those namespaces you do not get the warning (As it uses the system provided copy to validate).

一些公共恒等符和模式位置已经包含在“插件指定条目”中(特别是如果安装了WSTP)。对于那些名称空间,您不会得到警告(因为它使用系统提供的副本进行验证)。

#6


3  

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

在eclipse中,为了避免为文档检测到“没有语法约束(dtd或xml模式)”,我使用xsd模式文件添加到xml目录下

"Window \ preferences \ xml \ xml catalog \ User specified entries".

“窗口\ preferences \ xml \ xml目录\用户指定的条目”。

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

从这个xml中,我生成并保存了一个xsd: /home/my_user/xsd/my_xsd

As Location: /home/my_user/xsd/my_xsd.xsd

位置:/home/my_user/xsd/my_xsd.xsd

As key type: Namespace name

作为键类型:命名空间名称

As key: http://mycompany.com/hr/schemas

关键:http://mycompany.com/hr/schemas


Close and reopen the xml file and do some changes to violate the schema, you should be notified.

关闭并重新打开xml文件并做一些更改以违反模式,您应该得到通知。

#7


2  

I had some success going back to V1.4 of application.xsd. If anyone can explain why the JavaEE version does not work, I would appreciate it.

回到application.xsd的V1.4时,我取得了一些成功。如果有人能解释为什么JavaEE版本不能工作,我将非常感激。

<?xml version="1.0" encoding="UTF-8"?>
<application
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                      http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
  version="1.4">

#8


1  

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'

步骤2:转到“libraries”并删除项目的“JRE system library”

Step 3: Click on 'Add library'-->'JRE System Library' -->select 'Workspace default JRE'

步骤3:点击“添加库”——>“JRE系统库”——>选择“工作区默认JRE”

Step 3: Go to 'Order and Export' and mark the newly added ' JRE system library'

第3步:进入“订单和导出”并标记新添加的“JRE系统库”

Step 4: Refresh and Clean the project

步骤4:刷新并清理项目

Eureka! It's working :)

尤里卡!它的工作:)

#9


1  

Add this to your xml file's very beginning:

将此添加到xml文件的开头:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RelativeLayout>

Change RelativeLayout to your defined root layout ,then find xml file in left side, in layout folder, right click and select Validate.

将相对布局更改为您定义的根布局,然后在左侧找到xml文件,在layout文件夹中,右键单击并选择Validate。

#10


0  

What I found worked for me was to remove the schemaLocation attribute completely then right click in the outline view and goto edit namespaces, then adding the schema location hint into the resulting dialog.

我发现对我有用的是完全删除schemaLocation属性,然后在outline视图中右键单击并编辑名称空间,然后在结果对话框中添加模式位置提示。

#11


0  

It can be because of your proxy settings. See this and this. You can try attaching javadoc by URL to a library without it. If it is okay in your browser, but not in your editor, then it's a connection problem. I solved the same problem by asking the admin about the proxy settings. Although all other applications did work, eclipse didn't, so I had to enter the config "manually". It would be great if developers added a button "check connection"...

这可能是因为您的代理设置。看看这个和这个。您可以尝试通过URL将javadoc附加到没有它的库中。如果在浏览器中没有问题,但是在编辑器中没有问题,那么这就是一个连接问题。我通过询问管理员关于代理设置的问题解决了同样的问题。虽然所有其他应用程序都可以工作,但是eclipse没有,所以我必须“手动”输入配置。如果开发人员增加一个按钮“检查连接”,那就太棒了。

#12


0  

Solution For Eclipse:

解决方案为Eclipse:

add <!DOCTYPE something> to the begining of each problematic XML,

添加一个< !DOCTYPE something>从每个有问题的XML开始,

after the xml tag <?xml version="1.0" encoding="utf-8"?>

在xml标记

you can write anything for doctype, but basically it's supposed to be manifest, activity, etc. from what I understand

您可以为doctype编写任何内容,但从我的理解来看,它基本上应该是manifest、activity等等

#13


0  

I was just having this problem last night (using eclipse V.kepler). I am completely new to java and eclipse and I am trying to teach myself how to make an android app. While I was working on the lessons offered at developers.android.com I had input this into my main_activity_actions.xml file:

我昨晚刚刚遇到这个问题(使用eclipse V.kepler)。我对java和eclipse完全陌生,我正在自学如何制作一个android应用程序。xml文件:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<!--  Search should appear as an action button -->
<item android:id="@+id/action_search"
      android:icon="@drawable/ic_action_search"
      android:title="@string/action_search"
      android:showAsAction="ifRoom"/>

</menu>

This gave me the same error as OP. I tried following the suggestion of adding

这给了我和opo一样的错误,我尝试按照增加的建议去做

<!DOCTYPE project> 

just below the first line and it solved the issue.

就在第一行下面,它解决了问题。

#14


0  

What worked for me is to right click the xml-file in the tree (usually on the left hand side in eclipse) and clicked the validate. Since then, the warning never came back.

对我有用的是右键单击树中的xml文件(通常在eclipse的左边)并单击validate。从那以后,警告再也没有回来。

#15


0  

Here's what worked for me. I was using schemas without version numbers (e.g. spring-beans.xsd, and not spring-beans-4.1.xsd) and they probably got updated upstream. I assume the problem was that Eclipse kept a dirty cache of the old versions.

这是对我有用的。我使用的是没有版本号的模式(例如spring-beans)。xsd,而不是spring-bean -4.1.xsd),它们可能会在上游得到更新。我认为问题在于Eclipse保留了旧版本的脏缓存。

Fix :
1. Go to Window -> Preference -> Network Connection -> Cache
2. Remove all cached schemas.
3. Delete all the no grammar constraints problems in problem view.
4. Re-validate the project.

解决办法:1。转到窗口->首选项->网络连接->缓存2。清除所有缓存模式。3所示。删除问题视图中的所有无语法约束问题。4所示。Re-validate项目。

#16


0  

for me it worked like a charm when I cut it (ctrl a + ctrl - X) and saved it back again (ctrl-s) ! the warning "No grammar constraints (DTD or XML schema) detected for the document" was gone for good!!

对我来说,当我把它剪下来(按ctrl a + ctrl- X),再把它保存回来(按ctrl-s)的时候,它就像一个咒语!为文档检测到的“没有语法约束(DTD或XML模式)”警告消失了!