This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Iam building xml file.In that iam trying to create org.jdom.NameSpace in setAttribute() method of org.jdom.Element object. Iam getting runtime errors like illegal name. What exactly i want is i want to set "xmlns" as attribute name and "http://www.loc.gov/MARC21/slim" as attribute value. When iam directly creating that it is throwing exception that no attribute name should be xmlns in org.jdom.Element. That is why i approched to org.jdom.NameSpace. But iam not getting the way, how to set org.jdom.NameSpace in setAttribute method of org.jdom.Element object. I tried several ways but it is not comming. can any budy help me please. thanks to one and all.
Well, let's get the terminology straight for a start. When you see this in an XML document:that is called a namespace declaration. It's not an attribute, although in some DOM implementations you can cheat and use an attribute to create one.
Usually you don't explicitly put a namespace declaration into your XML. You usually do it indirectly, by using the namespace URI as part of the name of an element or an attribute.
Okay, now that we have done that, can you tell us what you are trying to do? It appears you are confused by namespaces and are trying to do something the wrong way, but it's hard to tell.