IntelliJ IDEA 2017.2 Help

Referencing XML Schemas and DTDs

Your XML file may reference an external XML schema (XSD) or DTD file, e.g.

<root xmlns="" xmlns:xsi="" xsi:schemaLocation="">



If the referenced URL or the namespace URI is "unfamiliar", it's marked as an error.

For situations like this, IntelliJ IDEA provides the following intention actions:

  • Fetch External Resource. IntelliJ IDEA downloads the referenced file and associates it with the URL (or the namespace URI). The error highlighting disappears. The XML file is validated according to the downloaded schema or DTD. (The associations of the URLs and the namespace URIs with the schema and DTD files are shown on the Schemas and DTDs page in the Settings dialog.)
  • Manually Setup External Resource. Use this option when you already have an appropriate schema or DTD file available locally. The Map External Resource dialog will open and you'll be able to select the file for the specified URL or namespace URI. The result of the operation is the same as in the case of fetching the resource.
  • Ignore External Resource. The URL or the namespace URI is added to the Ignored Schemas and DTDs list. (This list is shown on the Schemas and DTDs page in the Settings dialog.) The error highlighting disappears. IntelliJ IDEA won't validate the XML file, however, it will check if the XML file is well-formed.

There is one more intention action that you may find useful: Add Xsi Schema Location for External Resource. This intention action lets you complete your root XML elements. If the namespace is already specified, IntelliJ IDEA can add a couple of missing attributes.

For example, if you have a fragment like this:

<root xmlns="">

and perform the intention action on the value of the xmlns attribute, the result will be:

<root xmlns="" xmlns:xsi="" xsi:schemaLocation=" >

At this step, you'll be able to add the schema URL, and then map the URL (or the namespace URI) onto an appropriate schema file, or add the URL (or the URI) to the Ignored Schemas and DTDs list.

Last modified: 29 November 2017

See Also