tags:

views:

116

answers:

2

Hi,

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 ?

+1  A: 

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

Scott Bale
A: 

Does something like this work?

<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Copied from http://www.w3schools.com/Schema/schema_howto.asp

Andre