[jdom-interest] removing namespace

Martin Smith Martin.Smith at Cedar.com
Wed Mar 10 15:11:18 PST 2004


Thank you Gordon,

You're a star.

-----Original Message-----
From: Gordon Tyler [mailto:Gordon.Tyler at quest.com]
Sent: 10 March 2004 21:44
To: jdom-interest at jdom.org
Subject: RE: [jdom-interest] removing namespace


Martin Smith wrote:
> I am only removing the namespace from the <Reference> element, and
> this is the only place it appears, so I don't think that the
> namespace is applicable to any parent.  
> 
> <ns1:Reference
>
xmlns:ns1="http://www.govtalk.gov.uk/gateway/digitalmail">PRG278</ns1:Re
ference>

Try this:

    // Either:
    Namespace rootns =
Namespace.getNamespace("http://www.govtalk.gov.uk/taxation/CodingNoticeP
9");
    // or:
    Namespace rootns = myRootElement.getNamespace();
    
    Namespace ns1 = Namespace.getNameSpace("ns1",
"http://www.govtalk.gov.uk/gateway/digitalmail");
    Element ref = parent.getChild("Reference", ns1);
    ref.setNamespace(rootns);

The trick here is not that you want the Reference element to have no
namespace but rather that you want it to be in the same namespace as its
parent, which turns out to be the default namespace set on the root
element.

Ciao,
Gordon
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com


*********************************************************************** 
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
 ***********************************************************************




More information about the jdom-interest mailing list