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

后端 未结 18 513
礼貌的吻别
礼貌的吻别 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:13

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

    1. Go to Menu Preferences,
    2. in the navig menu, i.e. the Left frame of the dialog-box, Choose: XML > XML Files > Validation
    3. 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)
    0 讨论(0)
  • 2020-12-24 05:17

    Solution For Eclipse:

    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

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

    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.

    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.

    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.

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

    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.

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

    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)

    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)

    Then press ctrl + shift + F and save.

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

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

    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.

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