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
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"?>
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 :)
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>
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>
error must be gone.
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