title: Include repetitive namespaces in xml elements using java
body: <p>I have an unusual request.  I need to generate an xml file that looks for eg., something like below</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;pk:DeviceInfo xmlns:pk="urn:ietf:params:xml:ns:kyp:pk" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
        &lt;pk:Manufacturer xmlns:pk="urn:ietf:params:xml:ns:kyp:pk" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
        ABC
        &lt;/pk:Manufacturer&gt;
        &lt;pk:SerialNo&gt;123456&lt;/pk:SerialNo&gt;
        &lt;pk:Model&gt;Model1&lt;/pk:Model&gt;
        &lt;pk:IssueNo&gt;1&lt;/pk:IssueNo&gt;
  &lt;/pk:DeviceInfo&gt;
  </code></pre>
  
  <p>I am generating the xml using jdom api.  The problem is, even if i declare namespace for pk:Manufacturer element, jdom doesn't add it there because it is already declared in the root element.  But i need to repeat the namespace declaration in the child element as well, because i need to send this file to another server that requires the xml to be in this format.<br>
  I believe jdom doen't allow this, so i tried to create the xml first with jdom and update the xml with dom parser to include the namespace to the child element using elmt.setAttributeNS(), but unfortunately this doesn't seem to work. 
  Has anybody faced this problem before?</p>