On Tue, 15 Jan 2002 15:00:25 +0100 Lars Martin <[EMAIL PROTECTED]> wrote:
> On Tue, 15 Jan 2002 14:13:07 +0100 > "Jeroen Breedveld" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I think I found a bug in the rename command. In RenameCommand.java from > > line 59: > > this: > > Node parent = current.getParentNode( ); > > > > should be replaced with this: > > > > Node parent; > > switch (current.getNodeType()) { > > case Node.ATTRIBUTE_NODE: > > parent = ((Attr)current).getOwnerElement( ); > > break; > > default: > > parent = current.getParentNode( ); > > } > > > > > > This will allow attributes to be renamed. (Attr nodes do not have a > > parent node, at least not in our implementation) > > Hi Jeroen, > ok, the W3C DOM2 recommendation states "All nodes, except Attr [...] > may have a parent" so I think you're probably right. :-) I would like > to slightly modify your patch: > > --- RenameCommand.java 2001/11/29 22:58:49 1.2 > +++ RenameCommand.java 2002/01/15 16:03:42 > @@ -105,6 +105,9 @@ > Node parent = current.getParentNode( ); > switch ( current.getNodeType( ) ) { > case Node.ATTRIBUTE_NODE: > + // getParentNode() returns NULL for Attributes, but > getOwnerElement() returns > + // the proper parent node of this Attribute -> special case > + parent = ((Attr)current).getOwnerElement( ); > ((Element)parent).setAttribute( name, current.getNodeValue( ) ); > ((Element)parent).removeAttribute( current.getNodeName( ) ); > break; > > I hope you'll agree on this shortening.... No objection was raised to this shorting so I'll will apply this patch in the next couple of hours. -- ______________________________________________________________________ Lars Martin mailto:[EMAIL PROTECTED] SMB GmbH http://www.smb-tec.com ---------------------------------------------------------------------- Post a message: mailto:[EMAIL PROTECTED] Unsubscribe: mailto:[EMAIL PROTECTED] Contact administrator: mailto:[EMAIL PROTECTED] Read archived messages: http://archive.xmldb.org/ ----------------------------------------------------------------------