W3C home > Mailing lists > Public > html-tidy@w3.org > October to December 2000

modifying attributes with JTidy

From: Austin Rosenfeld <arosenfeld@agentware.net>
Date: Wed, 29 Nov 2000 09:15:59 -0500
Message-ID: <55228D476925D411912B00E018C14D910B17B9@AWATL01>
To: "'html-tidy@w3.org'" <html-tidy@w3.org>
 I am trying to use the JTidy libraries to modify a DOM tree, and
 am not having much success.  I need to take attributes out of a node, but
the
 methods in org.w3c.tidy.DOMAttrImpl to do this are all stubbed out (and
return null).  
 I noticed there is an extensive release history for this file, but there
appears to be
 very little implementation.  I checked some older versions of the archive
(I am
 using version 1.11, 2000/08/16 Tidy Release 4 Aug 2000), and this
 functinality appears never to have existed.  Is there any
 other known way to modify (or better yet remove) attributes?

 Here's the code I have been using:
	//some desired transformations:
      //<A VLINK="xxx">  --> <A>
	//<HR NOSHADE> --> <HR>
	NamedNodeMap    attributes  = node.getAttributes();
	Node            toRemove    = null;
	toRemove = attributes.getNamedItem( mAttribute.toUpperCase() );
             if ( toRemove != null )
             {
                 toRemove.setNodeValue( "" ); //works, but I get
			 //'element=""', where I want absolutely nothing
                 attributes.removeNamedItem( mAttribute.toUpperCase() );
			 //has no effect at all, regardless of what case I
change mAttribute to
             }


 Thanks for any advice you might have.

 Austin Rosenfeld
Received on Wednesday, 29 November 2000 09:16:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:44 GMT