wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to properly insert xsi:schemaLocation in XML file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to properly insert xsi:schemaLocation in XML file?" Watch "How to properly insert xsi:schemaLocation in XML file?" New topic
Author

How to properly insert xsi:schemaLocation in XML file?

Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Hi,

I'm pretty new at XML and I'm trying to find out about the correct way to specify schema location

I look at this website: http://w3schools.com/schema/schema_howto.asp and it mentions that it should be done like this.


So I did this in my application:
(with a space before the XSD file)

But some people told me that I should have done either of these two options:
Option 1:
Option 2: and then bundle the XSD into one zip file along with the XML.

Is the option that I use currently correct ()?
Can someone please advise?

Thanks in advance for all the help.

p.s.: http://myserver.com/myapplication is not a real URL, I just use it for example purpose.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you click on the "Next" button just below where you read that, you'll find the tutorial goes on to explain (a little bit) how that works.

Note that where it says the "location" of the schema, that's a URI which is relative to the XML document which contains that schema reference. In your example you used a relative URI which says that the XSD file is in the same folder or directory as the XML document. It's also possible to use more complex relative URIs or absolute URIs in that position.
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
Paul, thanks.

So to clarify:

1.) The first option:
is for this one:
In your example you used a relative URI which says that the XSD file is in the same folder or directory as the XML document.


2.) The 2nd option:
is the same with the 1st option:
the XSD file is in the same folder or directory as the XML document.


3.) And the 3rd option, is the exact absolute URL location of the XSD.
xsi:schemaLocation="http://myserver.com/myApplication/note.xsd">



Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
So just to give you more information.

The way I send XML feed to clients is that I zip the XML and there's a URL available for them to download the zip file.
and inside the XML I have this:
Then I send the XSD via email for them to use.

But one client is confused how they can use it. So I'm thinking there might be something wrong with the way I do this.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, I don't know. I'm no Schema expert. But you said
But some people told me that I should have done...

That's where you missed your chance. You should have asked those people questions like "Why?" or "What does that do?" or "What difference does that make?"
Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 224
I see..
 
jQuery in Action, 2nd edition
 
subject: How to properly insert xsi:schemaLocation in XML file?
 
Similar Threads
Error: The matching wildcard is strict, but no declaration can be found for element 'remember-me'
Problems with Spring Security and JSF2
HTTP Status 404 problem
Question about generating XSD
Problem deploying Spring 2.5 in JBoss 5.1