Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML File with local copy of XML Schema

Tags:

java

xml

xsd

I am trying out some XML Schema examples and have to validate them with a sample XML File. The schema is a local file (someFile.xsd). I am using eclipse and want to include a reference in the XML file to point to this local xsd file so that eclipse can suggest the elements to me.

Am finding it hard to come up with the syntax to include a local file. Any suggestions ?

like image 799
Arun R Avatar asked Nov 06 '22 12:11

Arun R


1 Answers

Are you using the xsi:schemaLocation attribute?

Ex:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://foo/target/Namespace"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:someNamespace="someFile"     
       xsi:schemaLocation="
       someFile someFile.xsd" >
...
</root>

I believe someFile.xsd has to be in your classpath

like image 133
Scott Bale Avatar answered Nov 12 '22 20:11

Scott Bale