[jdom-interest] removing namespace

Martin Smith Martin.Smith at Cedar.com
Wed Mar 10 12:05:51 PST 2004


Hi there
 
Via a web service I am obtaining an xml docuent.  When I try and unarshal it
with JAXB I get an UnmarshalException as the xml is not in format required
by their own schema (this is only government web service after all!).
 
So as the change is minimal, JDom to the rescue.  I thought.
 
The problem is that the element..
    <ns1:Reference
xmlns:ns1="http://www.govtalk.gov.uk/gateway/digitalmail">PRG278</ns1:Refere
nce>
Should not have the namespace data. It should just look like this..

    <Reference>PRG278</Reference>
I get the reference element, and try and remove the namespace using the
following code...
 
    Namespace ns = Namespace.getNameSpace("ns1",
<http://www.govtalk.gov.uk/gateway/digitalmail>
http://www.govtalk.gov.uk/gateway/digitalmail);
    Element ref = parent.getChild("Reference", ns );
    ref.removeNamespaceDeclaration();
 
Doing this does not change the elements namespace at all.
So instead it tried this...
 
    ref.setNamespace(Namespace.getNameSpace(""));    // or ("","")
Which gives me...
    <Reference xmlns="">PRG278 </Reference>
Still not acceptable to JAXB though, itcomplains about the blank name space.
Please help!
 
Martin
 
 


*********************************************************************** 
This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they 
are addressed. Any unauthorised distribution or copying is strictly 
prohibited. 
 
Whilst Cedar Software Ltd takes steps to prevent the transmission of 
viruses via e-mail, we can not guarantee that any email or 
attachment is free from computer viruses and you are strongly 
advised to undertake your own anti-virus precautions. 
 
Cedar Software Ltd grants no warranties regarding performance, 
use or quality of any e-mail or attachment and undertakes no 
liability for loss or damage, howsoever caused. 

CedAr is a leading UK supplier of Financial, eProcurement, Performance Management and, following the recent acquisition of Goldenhill Computer Systems Ltd, HR and Payroll software. Cedars solutions deliver increased capabilities and offer a direct and measurable financial return on investment.  The company has a customer base of more than 500 organisations in both the public and private sector. 
Particular sector strengths include Airlines, Business Services,
Education, Emergency Services, Financial Services, Government, Health, Local Authorities, Not for Profit, Retail and Utilities.  For more
information, please visit www.cedar.com 
2003 CedAr Software Ltd. All Rights Reserved. 
Cedar Software Ltd. Incorporation number 3214465
 ***********************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20040310/409291ce/attachment.htm


More information about the jdom-interest mailing list