I dont know if this is the correct forum. Please do let me know where to post in case it isnt correct.
I have a root element 'myset' and i need to add namespace to it .. like xmlns="http://abc.com", and i have a sub element 'my'. The problem is that, when i add namespace to 'myset', its added to 'my' as well, though the value of the xmlns in 'my' is blank.
That is to be expected. You have said that the urlset/myset element is in the default namespace, so you get the default namespace declaration there in the serialized XML document. But you have said that the url/my element is NOT in a namespace. Since elements inherit namespaces from their containing elements, the serializer has to put that empty namespace declaration on the url/my element to prevent the inheritance.
If you want the url/my element to be in the same namespace as the urlset/myset element, then create the two elements in the same way with the same namespace URI.
posted 13 years ago
Thanks Paul. I managed to solve that issue. Now what i want is to generate the xml with these headers, using jdom
I could create the namespace as xsi and add the attribute schemaLocation.BUt jdom doesnt allow the namespace to start with 'xml' so i could not add the xmlns="http://www.google.com/schemas/sitemap/0.84". How can i do this?
I find that hard to understand, when you posted code earlier in the thread where you did exactly that. But at any rate, in JDOM (I looked it up in the API documentation) the Element object has an addNamespaceDeclaration() method. You need to call that. I will leave it to you to read the documentation for the Namespace class, where it does explain how to create a Namespace object for a default namespace.
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad: