Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does xmlns:xsi mean?

 
Richard Butterwood
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain what this actually does?

Is it the default namespace for the schema instance? Does it always have to be xsi?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It declares that the string that follows... xmlns:xsi="something"... will be the URI of a namespace, and that all elements (and attributes) that are in the scope of this declaration and have the prefix "xsi:" will belong to the namespace.

It's the namespace URI (the "something" part up there) that identifies whether it's describing schemas or auto part requisitions. The prefix (the "xsi" part) has no meaning by itself. It is an arbitrary string that is used to relate the namespace to the elements and attributes that belong to the namespace.

That having been said, it's also traditional to use certain prefixes for certain namespaces. For example it's traditional to use the prefix "xsl:" for the XSL transformation namespace "http://www.w3.org/1999/XSL/Transform".
 
Richard Butterwood
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, does that mean it is not mandatory to have this in the XML definition? Virtually every example I have seen has xmlns:xsi at the top. A lot of XML files do not reference this xsi prefix either.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't mandatory for XML documents to use namespaces.

But somehow I doubt that is your question. If your XML document contains a namespace declaration, that really doesn't mean anything except to a program that knows what to do with that namespace. For example you can use the XSL transform namespace in an XML document if you like, but most programs won't do anything special with it unless they are using the document to do XSL transformations.
 
Sameer Raza Ali
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how does the xsi declaration actually work, is there a mapping to the url? like the way we use name space for a custom tag library and then it maps to tld file
the container knows where to search for the tld file (under WEB-INF folder)

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
Can i use any name space instead of the URL given above.

how does the schema validation actually work ??? would hihly appreciate an explanation
Thanks
Sameer


 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a link to the explanation as written in 1999 by the person who thought up the idea. It tells you everything you need to know.
 
Sameer Raza Ali
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Paul !!
 
Leon Omk
Ranch Hand
Posts: 75
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If xsi is arbitrary(we can change it to xmlns:xsjkl), how about schemaLocation? Can I change it to xsi:schemaURL="..." ?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Namespace prefixes are arbitrary. Element names are not, at least the local-name part is not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic