+proc constant_var {oid} {
+ set lname [string tolower [lindex $oid 2]]
+ set lname [string map {- _ . _ { } _ ( {} ) {}} $lname]
+ set prefix [string tolower [lindex $oid 0]]
+
+ return yaz_oid_${prefix}_${lname}
+}
+
+proc oid_to_xml {srcdir input xname} {
+ set oids [readoids "${input}"]
+ set xfile [open "${xname}" w]
+
+ puts $xfile "<!-- Generated by oidtoc.tcl from $input -->"
+ puts $xfile {<informaltable id="standard-oids">}
+ puts $xfile {<tgroup cols="3">}
+ puts $xfile {<colspec colwidth="3*" colname="name"></colspec>}
+ puts $xfile {<colspec colwidth="2*" colname="class"></colspec>}
+ puts $xfile {<colspec colwidth="4*" colname="oid"></colspec>}
+ puts $xfile {<thead>}
+ puts $xfile {<row>}
+ puts $xfile {<entry>Name</entry>}
+ puts $xfile {<entry>Class</entry>}
+ puts $xfile {<entry>Constant / OID</entry>}
+ puts $xfile {</row>}
+ puts $xfile {</thead>}
+ puts $xfile {<tbody>}
+
+ foreach oid $oids {
+ puts $xfile {<row>}
+
+ puts $xfile {<entry morerows="1">}
+ puts $xfile [lindex $oid 2]
+ puts $xfile {</entry>}
+
+
+ puts $xfile {<entry morerows="1">}
+ puts $xfile [lindex $oid 0]
+ puts $xfile {</entry>}
+
+ puts $xfile {<entry><literal>}
+ set v [constant_var $oid]
+ puts $xfile $v
+ puts $xfile {</literal></entry>}
+
+
+ puts $xfile {</row>}
+ puts $xfile {<row>}
+
+ puts $xfile {<entry namest="oid">}
+ puts $xfile [lindex $oid 1]
+ puts $xfile {</entry>}
+
+ puts $xfile {</row>}
+ }
+
+ puts $xfile {</tbody>}
+ puts $xfile {</tgroup>}
+
+ puts $xfile {</informaltable>}
+ close $xfile
+}
+