How to fix Eclipse validation error “No grammar constraints detected for the document”?

后端 未结 18 557
礼貌的吻别
礼貌的吻别 2020-12-24 05:01

Eclipse 3.5.2 is throwing an XML schema warning message:

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

The applica

相关标签:
18条回答
  • 2020-12-24 05:31

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

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE project>
    
    0 讨论(0)
  • 2020-12-24 05:31

    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!!

    0 讨论(0)
  • 2020-12-24 05:31

    Non of the above mentioned solutions worked. It was working for Spring boot version 2.1.0.RELEASE but when i created project with spring boot version 2.3.0.RELEASE, i started getting
    no grammar constraints (dtd or xml schema) referenced in the document issue.

    I fixed it by updating Eclipse version which updates maven version as well. In my case i am using red hat developer studio so, Menu->Help->check for updates, It will scan and open the update window with Available updates. Check the update related to Eclipse version and Click Next->Next->Accept Terms->Finish.

    0 讨论(0)
  • 2020-12-24 05:33

    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:

    <?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

    <!DOCTYPE project> 
    

    just below the first line and it solved the issue.

    0 讨论(0)
  • 2020-12-24 05:35

    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.

    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).

    You can use the preferences to make your schema known:

    • Open Preferences / XML Catalog / User Specified Entries
    • Click Add...
    • Enter the XSD file to use in "Location"
    • Select Key Type "Schema location" (in case you have a xsi:schemaLocation)
    • Enter the URL (second part of the location) matching the files content as "Key"
    • Press OK
    • Go to Problem view and delete the validation warning
    • Right-Click the XML File and Chose "Validate" again

    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).

    0 讨论(0)
  • 2020-12-24 05:38

    Add this to your xml file's very beginning:

    <?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.

    0 讨论(0)
提交回复
热议问题