WebStorm 9.0.2 Help

Referencing DTD or Schema

For an XML file to validate, you have to reference a DTD or a schema file. You can identify the DTD source in your xml file, for instance, like this:

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd" >

To reference a schema file, WebStorm supports standard ways, in particular, the xsi attribute.

If WebStorm cannot find the specified DTD or schema, they are marked as errors. In this case special intention actions are suggested to:

  • Resolve the reference, if it is represented as a URL.
  • Map a URI to a local file.
  • Permanently ignore it. An ignored URI will not be highlighted as an error any more, until removed from the ignore list.
  • Add Xsi schema location for external resources. A special attribute is added to point namespace location.
  • Configure schema for your XML file. The schema for your XML file can be configured based on detecting schemas located locally in project sources or libraries.

Fetching a DTD or schema file

  1. In an xml file, specify a URI of the DTD or schema. If the corresponding file is not found, the reference is marked as an error.
  2. Place the cursor within the reference and press Alt+Enter.
  3. In the suggestion list, select Fetch external resource.

Mapping a DTD or schema URI to a local file

  1. In an xml file, specify a URI of the DTD or schema. If the corresponding file is not found, the reference is marked as an error.
  2. Place the cursor within the problematic URI and press Alt+Enter.
  3. In the suggestion list, select Manually Setup External Resource.
  4. In the dialog that opens, select a file for the specified URI and click OK.

Ignoring a DTD or schema

  1. In an xml file, specify a URI of the DTD or schema. If the corresponding file is not found, the reference is marked as an error.
  2. Place the cursor within the reference and press the Alt+Enter.
  3. In the suggestion list, select Ignore External Resource. The URI is added to the Ignored Schemas and DTDs list.

Adding an Xsi schema location for an external resource

  1. In an xml file, specify a URI of the DTD or schema.
  2. Press Alt+Enter if the specified DTD or schema is not found and marked as an error.
  3. In the suggestion list, select Add Xsi Schema Location for External Resources.

Configuring a schema for an XML file

  1. In an xml file, specify the schema. If the desired file is not found, the reference is marked as an error.
  2. Place the cursor within the reference and press Alt+Enter.
  3. In the suggestion list, select Manually Setup External Resource. The Map External Resource dialog box opens showing the list of all schemas found in your project.
  4. In the Map External Resource dialog box, select the path to the desired schema file and click OK.

See Also

Last modified: 29 January 2015
comments powered by Disqus