This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Where are namespaces defined? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Where are namespaces defined?" Watch "Where are namespaces defined?" New topic
Author

Where are namespaces defined?

Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
I have a fairly good understanding of how namespaces work when used in an XML document, what I don't understand is where the URI comes from or how my IDE for example knows what elements are associated with that namespace. For example, in a JSF file you can refer to the core JSF namespace by using the following, and that the alias "f" could be pretty much anything I would like, but the URI must be "http://java.sun.com/jsf/core" otherwise my IDE doesn't know what those elements are and when the JSF is being processed will cause it to fail.



So obviously, the URI is important and it must be stored somewhere, but where?

I understand that the URI is not a URL, it doesn't necessarily point to a resource as it is not a Universal Resource Locator but instead a Universal Resource Identifier. My question is where is the URI actually defined and where are the elements that make up the namespace defined?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Don Blodgett wrote:

So obviously, the URI is important and it must be stored somewhere, but where?


Yes, it's important. It doesn't follow that it must be stored somewhere.

A similar case: when you're writing Java code the "public" keyword is important when you're declaring a method. But where is it stored? Well, it isn't stored anywhere. Software which needs to know its meaning (i.e. Java compilers) is written to follow a specification which describes it. I suppose you could say that the "public" keyword is "stored in" the Java Language Specification but most speakers of English wouldn't say that.

Likewise the URI in a namespace declaration is "stored in" a specification which describes how elements and atttributes in that namespace should be handled. In the example you gave, somewhere there is a JSF specification which describes that.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Paul Clapham wrote:Yes, it's important. It doesn't follow that it must be stored somewhere.


I agree with what you are saying, "stored" is not really the correct word here, but it certainly is defined in a specification which is stored somewhere. I guess my question is not really where this specification for JSF is, but generally where would an XML namespace be defined? Is it a DTD or XSD? If so how do those define the namespace they are defining? Or is it more complex than that? For example, with JSF I am assuming that it has to do with tag libs which I would imagine are all contained in the JAR files for the different JSF libraries. Am I on the right track here?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Here's an example. The namespace URI for XSLT is http://www.w3.org/1999/XSL/Transform. That's defined in this document: XSL Transformations (XSLT) Version 1.0. You'll notice that in section 2.1 of the document, the namespace URI is specified.
Don Blodgett
Ranch Hand

Joined: Jan 09, 2006
Posts: 61
Paul Clapham wrote:Here's an example. The namespace URI for XSLT is http://www.w3.org/1999/XSL/Transform. That's defined in this document: XSL Transformations (XSLT) Version 1.0. You'll notice that in section 2.1 of the document, the namespace URI is specified.


Thank you, that clears up a lot. Basically it is up to the implementation to determine how it is going to verify that the namespace is followed according to the specification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where are namespaces defined?
 
Similar Threads
Starting with JSF 2.0 - Templates
Resolving relative URIs for Canonicalization
Include JSP/JSF pages into other JSP/JSF pages
XML Namespace and XML Schema
DTD