[Tkabber-dev] r1175 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Aug 7 12:23:47 MSD 2007


Author: sergei
Date: 2007-08-07 12:23:47 +0400 (Tue, 07 Aug 2007)
New Revision: 1175

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/general/rawxml.tcl
Log:
	* plugins/general/rawxml.tcl: Removed redundant xmlns attributes from
	  pretty-printed XML for better readability.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-08-06 10:38:03 UTC (rev 1174)
+++ trunk/tkabber/ChangeLog	2007-08-07 08:23:47 UTC (rev 1175)
@@ -1,3 +1,8 @@
+2007-08-07  Sergei Golovan  <sgolovan at nes.ru>
+
+	* plugins/general/rawxml.tcl: Removed redundant xmlns attributes from
+	  pretty-printed XML for better readability.
+
 2007-08-06  Sergei Golovan  <sgolovan at nes.ru>
 
 	* ifacetk/iroster.tcl: Fixed roster item menu commands in case

Modified: trunk/tkabber/plugins/general/rawxml.tcl
===================================================================
--- trunk/tkabber/plugins/general/rawxml.tcl	2007-08-06 10:38:03 UTC (rev 1174)
+++ trunk/tkabber/plugins/general/rawxml.tcl	2007-08-07 08:23:47 UTC (rev 1175)
@@ -101,7 +101,7 @@
     $dump configure -state disabled
 }
 
-proc rawxml::pretty_print {t xmldata prefix tag} {
+proc rawxml::pretty_print {t xmldata prefix tag {xmlns jabber:client}} {
     global font
     variable options
     variable tabs
@@ -117,12 +117,25 @@
 	    set tabs($arr_index) [font measure $font $arr_index]
 	}
 	$t tag configure $arr_index -tabs [list $tabs($arr_index)]
-	set vars1 [lassign $vars attr value]
+
+	set vars1 {}
+	foreach {attr value} $vars {
+	    if {$attr == "xmlns"} {
+		if {$value == $xmlns} {
+		    continue
+		} else {
+		    set xmlns $value
+		}
+	    }
+	    lappend vars1 $attr $value
+	}
+
+	set vars2 [lassign $vars1 attr value]
 	$t insert end \
 	    " $attr" ${tag}attr \
 	    "=" {} \
 	    "'[jlib::wrapper:xmlcrypt $value]'" ${tag}value
-	foreach {attr value} $vars1 {
+	foreach {attr value} $vars2 {
 	    $t insert end \
 		"\n\t$attr" [list ${tag}attr $arr_index]\
 		"=" {} \
@@ -143,7 +156,8 @@
 	$t insert end "\n"
         foreach subdata $subtags {
 	    pretty_print $t $subdata \
-		$prefix[string repeat " " $options(indent)] $tag
+		$prefix[string repeat " " $options(indent)] $tag \
+		$xmlns
 	}
 	$t insert end "$prefix</" {} $tagname ${tag}tag ">\n"
     }



More information about the Tkabber-dev mailing list