tclxml-3.2/examples/tclxslt/common.tcl File Reference

Go to the source code of this file.

Functions/Subroutines

package require http ret SetProperties (type win, type log)
ret Browse (type win, type field, type args)
ret ReadAndParseXML (type win, type label, type fname, type baseuri, optional timearr=time, type args)

Function Documentation

ret Browse ( type  win,
type  field,
type  args 
)

$fname

Definition at line 55 of file tclxml-3.2/examples/tclxslt/common.tcl.

00055                                                 {
00056     upvar \#0 State$win state
00057 
00058     set w [expr {$win == "." ? {} : $win}]
00059 
00060     array set opts {
00061     -title {Select Document}
00062     -type open
00063     -command {}
00064     }
00065     array set opts $args
00066 
00067     set cwd [pwd]
00068     if {$state(cwd) != {}} {
00069     set cwd $state(cwd)
00070     }
00071 
00072     switch -- $opts(-type) {
00073     save {
00074         set fname [tk_getSaveFile -parent $win -title [mc $opts(-title)] -initialdir $cwd]
00075     }
00076     open -
00077     default {
00078         set fname [tk_getOpenFile -parent $win -title [mc $opts(-title)] -initialdir $cwd]
00079     }
00080     }
00081 
00082     if {![string length $fname]} {
00083     return {}
00084     }
00085 
00086     set state($field) file:///$fname
00087     set state(cwd) [file dirname $fname]
00088 
00089     if {[string length $fname] && [string length $opts(-command)]} {
00090     uplevel #0 $opts(-command)
00091     }
00092 
00093     return {}
00094 }

ret ReadAndParseXML ( type  win,
type  label,
type  fname,
type  baseuri,
optional  timearr = time,
type  args 
)

Definition at line 114 of file tclxml-3.2/examples/tclxslt/common.tcl.

00114                                                                                                               {
00115     upvar 1 $timearr time
00116     upvar \#0 State$win state
00117 
00118     array set opts {
00119     -noent 0
00120     -nonet 0
00121     }
00122     array set opts $args
00123 
00124     set state(externalentities) 0
00125 
00126     Feedback $win [mc "Opening $label document \"$fname\""]
00127     if {[string match http://* $fname]} {
00128     FeedbackProgress $win 0
00129     set state(start_download) [clock clicks -milliseconds]
00130     if {[catch {::http::geturl $fname \
00131             -command [list HTTPComplete $win] \
00132             -progress [list HTTPProgress $win] \
00133             -timeout 30000} token]} {
00134         tk_messageBox -message "unable to retrieve $label document \"$fname\" due to \"$token\"" -parent $win -type ok -icon error
00135         return -code error {}
00136     }
00137     ::http::wait $token
00138     if {[::http::status $token] != "ok"} {
00139         return -code error {}
00140     }
00141     set xml [::http::data $token]
00142     ::http::cleanup $token
00143     set time(read) [clock clicks -milliseconds]
00144     } else {
00145     if {[catch {open $fname} ch]} {
00146         tk_messageBox -message "unable to open $label document \"$fname\" due to \"$ch\"" -parent $win -type ok -icon error
00147         return -code error {}
00148     }
00149     set time(open) [clock clicks -milliseconds]
00150     Log timing $win "Opening $label document took [expr $time(open) - $time(start)]ms\n"
00151 
00152     Feedback $win [mc "Reading $label document"]
00153     # Take note of encoding information
00154     set encoding {}
00155     gets $ch xmldecl
00156     set re ^[::sgml::cl $::xml::Wsp]*<\\?xml[::sgml::cl $::xml::Wsp]+(version[::sgml::cl $::xml::Wsp]*=[::sgml::cl $::xml::Wsp]*("|')[::sgml::cl ^"']+\\2)?[::sgml::cl $::xml::Wsp]*(encoding[::sgml::cl $::xml::Wsp]*=[::sgml::cl $::xml::Wsp]*("|')([::sgml::cl ^"']+)\\4)?[::sgml::cl $::xml::Wsp]*(standalone[::sgml::cl $::xml::Wsp]*=[::sgml::cl $::xml::Wsp]*("|')(yes|no)\\7)?[::sgml::cl $::xml::Wsp]*\\?>
00157     if {[regexp $re $xmldecl discard allversion delimiter allencoding delimiter encoding allstandalone delimiter]} {
00158         if {[catch {fconfigure $ch -encoding $encoding} msg]} {
00159         if {[catch {fconfigure $ch -encoding [string tolower $encoding]} msg]} {
00160             tk_messageBox -message "unable to read $label document \"$fname\" due to \"$msg\"" -parent $win -type ok -icon error
00161             return -code error {}
00162         }
00163         }

package require http ret SetProperties ( type  win,
type  log 
)

Definition at line 30 of file tclxml-3.2/examples/tclxslt/common.tcl.

00030                                          {
00031 
00032     $log tag configure timing -background #bafdff
00033     $log tag configure error -background #ff9d8d
00034     $log tag configure errorhighlight -background #cd3030
00035     $log tag configure related -background #ffe59f
00036     $log tag configure relatedhighlight -background #e8b417
00037     $log tag configure message -background #ffe59f
00038     $log tag configure log -background #b9ffd4
00039 
00040     return {}
00041 }


Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1