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

前端 未结 19 2173
时光说笑
时光说笑 2020-11-27 10:35

I have this dtd : http://fast-code.sourceforge.net/template.dtd But when I include in an xml I get the warning : No grammar constraints (DTD or XML schema) detected for the

相关标签:
19条回答
  • 2020-11-27 11:11

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

    0 讨论(0)
  • 2020-11-27 11:11

    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)
  • 2020-11-27 11:15

    In my case I have solved this annoying warning by simply adding the <!DOCTYPE xml> after the <?xml ... > tag.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xml>
    
    0 讨论(0)
  • 2020-11-27 11:16

    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>
    
    0 讨论(0)
  • 2020-11-27 11:17
    1. copy your entire code in notepad.
    2. temporarily save the file with any name [while saving the file use "encoding" = UTF-8 (or higher but UTF)].
    3. close the file.
    4. open it again.
    5. copy paste it back on your code.

    error must be gone.

    0 讨论(0)
  • 2020-11-27 11:17

    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

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