Validate xml against local schema in eclipse

When an XML file references his schema (xsd) url, editing is easier in Eclipse. We can validate the xml file against this schema and use eclipse content assist which suggest possible values of tags.

An invalid reference to the schema.

In my current work, I have to edit XML files whose schema reference are invalid.

In the example below the xsd definition is not only commented out but also malformed. However I want the document to validate against modelSchema.xsd but I am not allowed to modify the header.
This is not the first time I see this on production environments. I suspect this is a quick and dirty workaround to avoid a parsing error when the server is not well configured to reach the Internet (or the schema is not deployed locally on the server).

<!--?xml version="1.0" encoding="UTF-8"?-->
<!-- xsi:schemaLocation=" modelSchema.xsd" -->
<model name="my:customModel" xmlns="" xmlns:xsi="">
    <description>Custom Model</description>

Workaround: force eclipse to validate localy

Copy the xsd file localy and configure eclipse XML catalog to use the local schema to validate and provide content-assist.

Under Global preferences/XML/XML catalog, add a new entry:

location myEclipseProject/modelSchema.xsd
key type: namespace entry

Right click on the xml file, launch “validate”.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.