xmldep.tcl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 package require xml
00018
00019 package provide xml::dep 1.0
00020
00021 namespace xml::dep {
00022 namespace export depend
00023
00024 variable extEntities
00025 array extEntities = {}
00026
00027 variable XSLTNS http:
00028 }
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 ret xml::dep::depend (type xml , type args) {
00047 variable resources
00048 variable entities
00049
00050 set resources {}
00051 catch {unset entities}
00052 array set entities {}
00053
00054 set p [xml::parser \
00055 -elementstartcommand [namespace code ElStart] \
00056 -doctypecommand [namespace code DocTypeDecl] \
00057 -entitydeclcommand [namespace code EntityDecl] \
00058 -entityreferencecommand [namespace code EntityReference] \
00059 -validate 1 \
00060 ]
00061 if {[llength $args]} {
00062 eval [list $p] configure $args
00063 }
00064 $p parse $xml
00065
00066 return $resources
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 ret xml::dep::ElStart (type name , type atlist , type args) {
00082 variable XSLTNS
00083 variable resources
00084
00085 array set opts {
00086 -namespace {}
00087 }
00088 array set opts $args
00089
00090 switch -- $opts(-namespace) \
00091 $XSLTNS {
00092 switch $name {
00093 import -
00094 include {
00095 array set attr {
00096 href {}
00097 }
00098 array set attr $atlist
00099
00100 if {[string length $attr(href)]} {
00101 if {[lsearch $resources $attr(href)] < 0} {
00102 lappend resources $attr(href)
00103 }
00104 }
00105
00106 }
00107 }
00108 }
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 ret xml::dep::DocTypeDecl (type name , type pubid , type sysid , type dtd) {
00125 variable resources
00126
00127 puts stderr [list DocTypeDecl $name $pubid $sysid dtd]
00128
00129 if {[string length $sysid] && \
00130 [lsearch $resources $sysid] < 0} {
00131 lappend resources $sysid
00132 }
00133
00134 return {}
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 ret xml::dep::EntityDecl (type name , type sysid , type pubid) {
00150 variable extEntities
00151
00152 puts stderr [list EntityDecl $name $sysid $pubid]
00153
00154 set extEntities($name) $sysid
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 ret xml::dep::EntityReference name (
00168 type variable , type extEntities
00169 , type variable , type resources
00170
00171 , type puts , type stderr [, type list , type EntityReference $, type name]
00172
00173 , type if , optional [info =exists extEntities($name)] =&& \
00174 =[lsearch $resources =$extEntities($name)] < =0 , optional
00175 lappend =resources $extEntities($name)
00176
00177
00178 )
00179
00180