File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Namespaces in XML 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 "Namespaces in XML" Watch "Namespaces in XML" New topic

Namespaces in XML

Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
Hello All,
I am very much confused bout the namescpaes. I know that(from some examples) namespace in XML is just to make the tags differee for same or diff xml files(am i right). If this is the case then why one have to write xsd as namespace for every element of XSD? I mean what is the need of that when the namespace five from namespace prefix "xsd", is alwayts the standard one(some org.xml url)?
Please explain it breifly.
Thnaks and regrds
Sandeep Jindal

SCJP 5.0
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
In fact, you don't need to add the prefix "xsd" for all XSD elements if you define the schema namespace as the default namespace (<schema xmlns="">). Of course then you would have to prefix all non-XSD elements with some namespace so that the parser won't try to find a "customer" element from the standard XSD schema and complain when it doesn't find such an element...

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Perhaps this will also help you, read for sure.

Spritle Software Blogs
Sandeep Jindal
Ranch Hand

Joined: Aug 25, 2003
Posts: 180
Thanks Balaji,
Your document really helped me. This document is very detialed though too long. I have read bout half the document and will read the rest soon.
Sir, can u please tell me the link whether i can find other general frequenly asked XML interview questions, or java questions.
Thanks and regards
Sandeep Jindal
I agree. Here's the link:
subject: Namespaces in XML
It's not a secret anymore!