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 Laurent Forêt <l....@korom.net> on 2001/03/06 15:17:39 UTC

setNodeName() ?

Using xerces 1.2.1.

I would like to programmatically change a node Name, (only if the node is an
element).

But there's no setNodeName() method to my element. How could I do ?

Thanks.

-------------------------

Laurent Forêt
Service développement

l.foret@korom.net
www.korom.net


RE: setNodeName() ?

Posted by Laurent Foret <l....@korom.net>.

Thanks evrybody for your answers.

I am implementing a light xml editor using dom and swing.tree,
So I have a class SwingTreeNode wich extends DefaultMutableTreeNode,
specified like this :
When I change the structure of SwingTreeNode, I change the structure of the
user objetcs which are Dom nodes (to preserve the Dom structure of the
document).

So,when I want to change the value of a Dom textNode, I have to access to
the good MyTreeNode and change the value of the userObject.
That is simple.

But, now if I want to change the name of a dom elementNode, I have to
clone/import in order to preserve the structure of the dom tree.
Due to the clonage the swingtreenodes childs won't contain the good handles
to the clone dom Node childs !
And It means that I have to rebuild the SwingTreeNode.

Am I right ?



> -----Message d'origine-----
> De : Arnaud Le Hors [mailto:lehors@us.ibm.com]
> Envoye : mardi 6 mars 2001 18:41
> A : xerces-j-user@xml.apache.org
> Objet : Re: setNodeName() ?
>
>
> There is no way to change the name of an element, along with its
> namespace URI if it has one, it's an inherent part of its type and
> cannot be changed once the element is created (because in some
> implementations it may directly be related to a specific concrete
> class). So the only way to achieve this is to actually create an element
> with a new name and insert it in place of the other.
> --
> Arnaud  Le Hors - IBM Cupertino, XML Strategy Group
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>


Laurent Foret
Service developpement

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

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


Re: setNodeName() ?

Posted by Arnaud Le Hors <le...@us.ibm.com>.
There is no way to change the name of an element, along with its
namespace URI if it has one, it's an inherent part of its type and
cannot be changed once the element is created (because in some
implementations it may directly be related to a specific concrete
class). So the only way to achieve this is to actually create an element
with a new name and insert it in place of the other.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

Re: setNodeName() ?

Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Laurent,


> I would like to programmatically change a node Name, (only if the node is an
> element).
> 
> But there's no setNodeName() method to my element. How could I do ?

You will have to create a new node with another name and clone
information from *oldNode* to *newNode*.

Elena