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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jul 31 23:54:09 MSD 2009


Author: sergei
Date: 2009-07-31 23:54:08 +0400 (Fri, 31 Jul 2009)
New Revision: 1822

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/general/rawxml.tcl
Log:
	* plugins/general/rawxml.tcl: Added XMLNS prefixes to Raw XML
	  prettyprinter.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-07-30 22:19:37 UTC (rev 1821)
+++ trunk/tkabber/ChangeLog	2009-07-31 19:54:08 UTC (rev 1822)
@@ -5,6 +5,9 @@
 	  presence.tcl, pubsub.tcl: Moved dialog windows to the center of root
 	  window.
 
+	* plugins/general/rawxml.tcl: Added XMLNS prefixes to Raw XML
+	  prettyprinter.
+
 2009-07-28  Sergei Golovan  <sgolovan at nes.ru>
 
 	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).

Modified: trunk/tkabber/plugins/general/rawxml.tcl
===================================================================
--- trunk/tkabber/plugins/general/rawxml.tcl	2009-07-30 22:19:37 UTC (rev 1821)
+++ trunk/tkabber/plugins/general/rawxml.tcl	2009-07-31 19:54:08 UTC (rev 1822)
@@ -122,15 +122,40 @@
     $dump configure -state disabled
 }
 
-proc rawxml::pretty_print {t xmldata prefix tag {pxmlns jabber:client}} {
+proc rawxml::pretty_print {t xmldata prefix tag {pxmlns jabber:client} {prefixes {xml xml}}} {
     variable options
     variable tabs
 
     ::xmpp::xml::split $xmldata stag xmlns attrs cdata subels
 
-    set attrs1 $attrs
+    array set p $prefixes
+    set attrs1 {}
+    foreach {attr value} $attrs {
+        set l [::split $attr :]
+        if {[llength $l] > 1} {
+            set axmlns [join [lrange $l 0 end-1] :]
+            set aattr [lindex $l end]
+
+            if {[string equal $axmlns $xmlns]} {
+                lappend attrs1 $aattr $value
+            } elseif {[info exists p($axmlns)]} {
+                lappend attrs1 $p($axmlns):$aattr $value
+            } else {
+                set p($axmlns) [::xmpp::xml::FindNewPrefix [array names p]]
+                lappend attrs1 xmlns:$p($axmlns) $axmlns $p($axmlns):$aattr $value
+            }
+        } else {
+            lappend attrs1 $attr $value
+        }
+    }
+
     if {$pxmlns != $xmlns && $xmlns != ""} {
-	lappend attrs1 xmlns $xmlns
+	if {![info exists p($xmlns)]} {
+	    lappend attrs1 xmlns $xmlns
+	    set pxmlns $xmlns
+	} else {
+	    set stag $p($xmlns):$stag
+	}
     }
 
     $t insert end "$prefix<" {} $stag ${tag}tag
@@ -168,7 +193,7 @@
         foreach subdata $subels {
 	    pretty_print $t $subdata \
 		$prefix[string repeat " " $options(indent)] $tag \
-		$xmlns
+		$pxmlns [array get p]
 	}
 	$t insert end "$prefix</" {} $stag ${tag}tag ">\n"
     }



More information about the Tkabber-dev mailing list