File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes help: questions about namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "help: questions about namespace" Watch "help: questions about namespace" New topic
Author

help: questions about namespace

roger wong
Ranch Hand

Joined: Oct 21, 2009
Posts: 31
Hi, I have some questions about namespace, which have made me stuck. Could you please help answer them?
Thank you in advance!
Q1.
<book xmlns:h="http://book.com">
<h:title>java</h:title>
<h:author>sun</h:author>
<desc>javajava</desc>
</book>

Is <book> in the namespace of "http://book.com"? If not, what's its namespace?(is there a default namespace?)
Is <desc> in the namespace of "http://book.com"? If not, what's its namespace?

Q2. What's the namespace?
<book>
<title>java</title>
<author>sun</author>
<desc>javajava</desc>
</book>





Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

Q1. Is <book> in the namespace of "http://book.com"?

No. The element happens to also declare that namespace, but it declares that it has the prefix "h". It doesn't use that prefix so it isn't in that namespace. And no, there isn't a default namespace because the document doesn't declare one. The element is in no namespace.

Q1. Is <desc> in the namespace of "http://book.com"?

No. Just like the book element, it is in no namespace. The http://book.com namespace is still in scope for that element, since it's inherited from its parent element, but again it isn't used by the desc element.

Q2. What's the namespace?

There isn't one.

You could read this tutorial which explains the whole thing in one page.
roger wong
Ranch Hand

Joined: Oct 21, 2009
Posts: 31
Thank you! That really helps!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help: questions about namespace