Hi, I tried " elem.setQName( QName.get( elem.getName(), ns, elem.getQualifiedName() ) );"
Still in the child elements of root element "<rule xmlns="" id="InfoMain" scope="public">" Xmlns is visible. Please let me know if any other solution is available. Thanks Kirti -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Evan Kirkconnell Sent: Thursday, August 03, 2006 12:23 AM To: dom4j-user@lists.sourceforge.net Subject: Re: [dom4j-user] help requied in Namespace problem Here's code if you want it. Lemme know if I botched something. /** *Sets the namespace of the element to the given namespace */ public static void setNamespace(Element elem, Namespace ns){ elem.setQName( QName.get( elem.getName(), ns, elem.getQualifiedName() ) ); } /** *Recursively removes the namespace of the element and all its children: sets to Namespace.NO_NAMESPACE */ public static void removeNamespaces(Element elem){ setNamespaces(elem, Namespace.NO_NAMESPACE); } /** *Recursively removes the namespace of the list and all its children: sets to Namespace.NO_NAMESPACE */ public static void removeNamespaces(List l){ setNamespaces(l, Namespace.NO_NAMESPACE); } /** *Recursively sets the namespace of the element and all its children. */ public static void setNamespaces(Element elem, Namespace ns){ setNamespace(elem, ns); setNamespaces(elem.content(), ns); } /** *Recursively sets the namespace of the List and all children if the current namespace is match */ public static void setNamespaces(List l, Namespace ns){ Node n = null; for(int i=0; i<l.size(); i++){ n = (Node)l.get(i); if(n.getNodeType() == Node.ATTRIBUTE_NODE) ( (Attribute)n ).setNamespace(ns); if(n.getNodeType() == Node.ELEMENT_NODE) setNamespaces( (Element)n, ns ); } } Naveen Murthy wrote: > > hello Edwin, > > in the older versions of dom4j, > > we could use --> > Doc.getRootElement().addAttribute("xmlns","http://www.w3.org/2001/06/gra mmar"); > > and this would make "http://www.w3.org/2001/06/grammar" as the DEFAULT > namespace for > the whole doc (whichwould apply to allthe child elemnts of the root.) > > Wondering if same can be somehow done for dom4j.1.6. > > > Herez an example which i have in my appln ( frm older dom4j). > all child elements are in the namespace > ="http://vmw.test.com/eventNotification/v1/xsd" > . (this is verified by schemavalidation, xsd says that "WorkAGR" shud > be in > "http://vmw.test.com/eventNotification/v1/xsd" namespace & it does pass > schemavalidation;) > > <eventNotificationMsg > xmlns="http://vmw.test.com/eventNotification/v1/xsd"> > <WorkAGR> > <TimeSent>0620916202344</TimeSent> > <BasePriority>10</BasePriority><Center>MODELCNTCTR</Center> > <CustomerName>MISS Jane</CustomerName> > </WorkAGR> > </eventNotificationMsg> > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ - > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE V > ------------------------------------------------------------------------ > > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ------------------------------------------------------------------------ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE V _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user