You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by sa...@ca.ibm.com on 2001/03/12 15:46:19 UTC

Re: setNodeName() ?

Laurent Foret wrote:

> It works fine, thanks ,
> But if the Element is the root of the Document What is the parent?
>

The document would be the parent. In this case, you should switch the last
two lines like this:

     parent.removeChild(el);
     parent.insertBefore(nel, null);

Sandy Gao
Software Developer, IBM Canada
(1-416) 448-3255
sandygao@ca.ibm.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: setNodeName() ?

Posted by Laurent Foret <l....@korom.net>.
> -----Message d'origine-----
> De : sandygao@ca.ibm.com [mailto:sandygao@ca.ibm.com]
> Envoye : lundi 12 mars 2001 15:46
> A : xerces-j-user@xml.apache.org
> Objet : Re: setNodeName() ?
>
>
>
> Laurent Foret wrote:
>
> > It works fine, thanks ,
> > But if the Element is the root of the Document What is the parent?
> >
>
> The document would be the parent. In this case, you should switch the last
> two lines like this:
>
>      parent.removeChild(el);
>      parent.insertBefore(nel, null);
>

that's it, thanks.

On the same model, I have a renameAttribute() method :

private Node renameAttribute(Attr att, String newName) {
    // on cree l'element avec un nouveau nom.
    Attr natt = att.getOwnerDocument().createAttribute(newName);
    natt.setNodeValue(att.getNodeValue());

    Element owner = att.getOwnerElement();
    // on remplace l'ancien attribut par le nouveau
    NamedNodeMap attrs = owner.getAttributes();
    attrs.removeNamedItem(att.getNodeName());
    attrs.setNamedItem(natt);
    return (Node) natt;
  }

But, it seems that my method doesn't respect the order attributes in
NamedNodeMap.
Does it matter ?

---------------------------------------------------------
Laurent Foret
Service developpement

l.foret@korom.net <ma...@korom.net>

www.korom.net <http://www.korom.net>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org