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.... Anyway many thanks for your
good job.
Regards, Lars.
> uses case:
>
> input:
>
> <?xml version="1.0"?>
> <addresses>
> <address name="Andreas">
> <town>New York</town>
> </address>
> <address name="Lars">
> <town>Los Angeles</town>
> </address>
> </addresses>
>
> update:
>
> <lexus:modifications version="1.0"
> xmlns:lexus="http://www.xmldb.org/xupdate">
> <lexus:rename select="/addresses/address/@name">naam</lexus:rename>
> </lexus:modifications>
>
> result:
>
> <?xml version="1.0"?>
> <addresses>
> <address naam="Andreas">
> <town>New York</town>
> </address>
> <address naam="Lars">
> <town>Los Angeles</town>
> </address>
> </addresses>
>
> greetings,
>
> jeroen
>
>
> --
>
> X-Hive Corporation
> e-mail: [EMAIL PROTECTED]
> phone: +31 10 7108622
> http://www.x-hive.com
> ----------------------------------------------------------------------
> Post a message: mailto:[EMAIL PROTECTED]
> Unsubscribe: mailto:[EMAIL PROTECTED]
> Contact administrator: mailto:[EMAIL PROTECTED]
> Read archived messages: http://archive.xmldb.org/
> ----------------------------------------------------------------------
--
______________________________________________________________________
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/
----------------------------------------------------------------------