Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I link an XSD to an XML file in Eclipse?

Tags:

xml

eclipse

How do I link an XSD to an XML file in Eclipse?

The xml file that I am editing is not in the same directory as the xsd file but both are in the workspace.

like image 365
Gambit Avatar asked Dec 14 '09 16:12

Gambit


1 Answers

  • Go to Preferences > XML > XML Catalog, and click Add.
  • Under Location, enter the path of your XSD file, relative to the workspace.
  • Under Key Type, select Schema Location.
  • Under Key, enter something like http://www.yourcompany.com/schema/yourSchema.xsd.

Then, in your XML files that use that schema, put this at the top:

<?xml version="1.0" encoding="UTF-8"?>
<yourDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.yourcompany.com/schema/yourSchema.xsd">

You may need to right-click the XML file and select Validate for it to recognize the new schema.

like image 199
JW. Avatar answered Oct 15 '22 15:10

JW.