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

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

    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.

    <?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">
    
    0 讨论(0)
  • 2020-12-24 05:24

    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.

    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.

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

    Editing Spring context files, I found that setting explicitly the version of the XSD removes the warning:

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
            http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.9.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    0 讨论(0)
  • 2020-12-24 05:27

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

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

    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.

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

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

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