0% found this document useful (0 votes)
30 views

Rel B0 To XML83 SOTM

This document contains Tcl procedures for processing and formatting document metadata. The procedures take in document filenames, properties, and lists as arguments. They perform operations like retrieving directory locations, checking and modifying names, getting file sizes and dates, sorting lists, and writing metadata to output files. The overall purpose is to extract and transform document metadata into a standardized XML format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Rel B0 To XML83 SOTM

This document contains Tcl procedures for processing and formatting document metadata. The procedures take in document filenames, properties, and lists as arguments. They perform operations like retrieving directory locations, checking and modifying names, getting file sizes and dates, sorting lists, and writing metadata to output files. The overall purpose is to extract and transform document metadata into a standardized XML format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Copy of RelB0toXML83SOTM.

mql 7/31/2007

set context person joan.giovino password "";


tcl;

proc LDir {directoryKey} {

#Location of directory listing. KEEP UP TO DATE!!!


set DIRECTORY_LISTING_FILE "C:/WINDOWS/MATRIX_CD.INI"
set directoryLocation ""
append directoryKey "*"

#Read all of the contents out of the directory listing file.


set ReadFile [ open $DIRECTORY_LISTING_FILE "r" ]

while {[gets $ReadFile sLineData] >= 0} {


if {[string match $directoryKey $sLineData] == 1} {
set sList [split $sLineData "="]
set directoryLocation [string trim [lindex $sList 1]]
}
}
return $directoryLocation
}

proc checkName {iType iName} {


if {$iType == "Master Instruction (MI)"} {
return "MI $iName"
} else {
return $iName
}
}

proc getTopFolderName {iFileName} {


set iExtension [string range [string tolower $iFileName] [expr {[
string length $iFileName] - 4}] end]
set folder ../
if {$iExtension == ".pdf"} {
if {[string range [string tolower $iFileName] 0 1] == "b0"} {
append folder [string range $iFileName 0 4]
} elseif {[string range [string tolower $iFileName] 0 1] == "mi"} {
append folder [string range $iFileName 0 1]
} else {
append folder vendor
}
} elseif {$iExtension == ".xls"} {
append folder spreadsheet
} elseif {$iExtension == ".hlp"} {
append folder help
}

append folder /
return [string tolower $folder]
}

proc formatSize {s} {


if {($s == 0) || ($s == "")} {return "0 KB"}

set sSizeKB [expr ($s / 1024)]


if {$sSizeKB < 1024}\
then {return "$sSizeKB KB"}\
else {\
set sSizeMB [expr ($s / 1048576.0)]
set sSizeMB [string range $sSizeMB 0 [expr {[string first . $sSizeMB]
+ 1}]]

1
Copy of RelB0toXML83SOTM.mql 7/31/2007

return "$sSizeMB MB"


}
}

proc formatDate {s} {


if {$s != ""} {
while {[string first - $s] != -1} {
set str [string range $s 0 [expr ([string first - $s] - 1)]]
append str " "
append str [string range $s [expr ([string first - $s] + 1)] end]
set s $str
}
set secs [clock scan "$s"]
set date [clock format $secs -format "%m/%d/%Y"]
} else {
set date ""
}
return "$date"
}

proc addSpace {s} {


set length [string length $s]
set name [string range $s 0 [expr ($length - 3)]]
append name " "
append name [string range $s [expr ($length - 2)] end]
}

proc subString {s} {


set i [string first & $s]
if {$i < 0}\
then {return $s}\
else {\
return [string range $s 0 [expr ($i - 1)]]
}
}

proc fixNameSpace {s} {


set sub $s
set i [string first & $sub]
set name ""

while {[string first & $sub] >= 0} {


append name [subString $sub]
append name {&amp;}
set sub [string range $s [expr ($i + 1)] end]
set i [expr $i + [string first & $sub] + 1]
}
append name [subString $sub]
return $name
}

proc getDescription {sFileName} {


set sFileNamePath [LDir "MATRIX_SOURCE"]
append sFileNamePath "/"
append sFileNamePath $sFileName

set mqlLocation [LDir "MQL_LOCATION"]


append mqlLocation "/GetProperties.vbs"
mql shell wscript "$mqlLocation" "$sFileNamePath"

set tempFolder [LDir "TEMP_FOLDER"]


set sTMPFile "$tempFolder/sDescription.txt"

set sTmpId [ open $sTMPFile "r" ]

2
Copy of RelB0toXML83SOTM.mql 7/31/2007

while {[gets $sTmpId sLineData] >= 0} {


set sDescription [lindex [split $sLineData \n] 0]
}
close $sTmpId
return $sDescription
}

proc fixList {sList oList} {


set i 0
set sVar ""
foreach sCtcDoc $sList {
set sType [lindex [split $sCtcDoc "\t"] 0]

if {$sType == "User Document (B0)" || $sType == "Master Instruction


(MI)"} {
set sVar "$sCtcDoc"
set oList [linsert $oList $i "$sVar" ]
incr i
} else {
set sVar "$sVar|$sCtcDoc"
set j [expr ($i - 1)]
set oList [ lreplace $oList $j $j "$sVar" ]
}
}
set oList [lsort $oList]
return $oList
}

proc fixList2 {sList oList} {


set i 0
set sVar ""
foreach sCtcDoc $sList {
set tabCount [regsub -all \t $sCtcDoc () ignore]
if {$tabCount > 1} {
set sVar "$sCtcDoc"
set oList [linsert $oList $i "$sVar" ]
incr i
} else {
set sVar "$sVar|$sCtcDoc"
set j [expr ($i - 1)]
set oList [ lreplace $oList $j $j "$sVar" ]
}
}
set oList [lsort $oList]
return $oList
}

proc writeBookInfo {sFileId sName sRev sDescription sStateDate sCategory


sState sFileName sFileSize} {
if {[string length $sFileName] < 1} {
set sFileName [string tolower "$sName\_$sRev\.pdf"]
}
set matrixAlternate [LDir "MATRIX_ALTERNATE"]
append matrixAlternate "/$sFileName"
if {$sFileSize == ""} {
if {[file exists "$matrixAlternate"]} {
set sFileSize [file size "$matrixAlternate"]
}
}
if {$sStateDate == ""} {
set sStateDate "07/25/07"
}
puts $sFileId "<book>"

3
Copy of RelB0toXML83SOTM.mql 7/31/2007

puts $sFileId "<num>$sName</num>"


puts $sFileId "<rev>$sRev</rev>"
puts $sFileId "<title>[fixNameSpace $sDescription]</title>"
puts $sFileId "<reldate>[formatDate $sStateDate]</reldate>"
puts $sFileId "<category>$sCategory</category>"
puts $sFileId "<status>$sState</status>"
puts $sFileId "<path>[getTopFolderName $sFileName]$sFileName</path>"
puts $sFileId "<size>[formatSize $sFileSize]</size>"
puts $sFileId "</book>"
}

eval {
set sTmpTemp "$env(TEMP)"
regsub -all {\\} $sTmpTemp "/" sTemp

set sCDList [split [mql expand bus DOCMAN K0173WT H\


select bus current\
select relationship attribute\[Related I/A Series Release\] dump "\t"] \n]

#Append release info correctly


#
set sCDFixList {}
set sCDFixList [fixList2 $sCDList $sCDFixList]
set sCDFixList2 {}

foreach sCDFixDoc $sCDFixList {


set sType [lindex [split $sCDFixDoc "\t"] 3]
set sName [lindex [split $sCDFixDoc "\t"] 4]
set sRev [lindex [split $sCDFixDoc "\t"] 5]
set sState [lindex [split $sCDFixDoc "\t"] 6]
set sIARelease [lindex [split $sCDFixDoc "\t"] 7]

puts "$sType\t$sName\t$sRev"

if {$sState == "Cancelled"} {
if {[mql temp query bus $sType $sName * where ' revision > $
sRev ' dump] != "" } {

set subList [split [mql temp query bus $sType $sName *


\
where ' revision > $sRev '\
select current dump "\t"] \n]

set sMatch "FALSE"

foreach subDoc $subList {


set subType [lindex [split $subDoc "\t"]
0]
set subName [lindex [split $subDoc "\t"]
1]
set subRev [lindex [split $subDoc "\t"]
2]
set subState [lindex [split $subDoc "\t"]
3]

if {$subState == "Released" || $subState ==


"Cancelled"} {
lappend sVerifyList
"$subType\t$subName\t$subRev"

set subList2 [split [mql expand bus $


subType $subName $subRev\
select bus current\
select relationship attribute\[Related I/A

4
Copy of RelB0toXML83SOTM.mql 7/31/2007

Series Release\] dump "\t"] \n]

set subFixList {}
set subFixList [fixList2 $subList2
$subFixList]

set k 0

foreach subFixDoc $subFixList {


set k [expr ($k+1)]
set sCDType [lindex [split
$subFixDoc "\t"] 3]
set sCDName [lindex [split
$subFixDoc "\t"] 4]
set sCDRev [lindex [split
$subFixDoc "\t"] 5]
set sCDState [lindex [split
$subFixDoc "\t"] 6]
set sCDIARelease [
lindex [split $subFixDoc "\t"]
7]

#puts "--> $subType2 |


$subName2 | $subRev2 |
$subState2 | $subIARelease2"

if {$sCDName == "K0173WT" && $


sCDRev == "H"} {
set sMatch "TRUE"
if {([string match
"*8.3 SOTM*" $
sCDIARelease] == "0")}
{
#
puts "What
should I do
with
$subType\t$sub
Name\t$subRev"
if {([string
match "*8.3
SOTM*" $
sIARelease] ==
"0")} {
puts
"-
Removi
ng
$sType
\t$sNa
me\t$s
Rev
from
list"
} else {

lappen
d
sCDFix
List2
"$sTyp
e\t$sN
ame\t$
sRev"

5
Copy of RelB0toXML83SOTM.mql 7/31/2007

puts
"+
Newer
revisi
on
connec
ts to
WT.H
but
does
not
apply
to
*8.3
SOTM*"
}
} else {
#Newer
revision is a
match,
therefore
remove
cancelled from
list
puts "-
Skipping
$sType\t$sName
\t$sRev"
}
}
if {$k == [llength
$subFixList] && $sMatch ==
"FALSE"} {
#Add to List
if {([string match
"*8.3 SOTM*" $
sIARelease] == "0")} {
puts "-
Removing
$sType\t$sName
\t$sRev from
list"
} else {
lappend
sCDFixList2
"$sType\t$sNam
e\t$sRev"
puts "+ Newer
revision does
not connect to
WT.H"
}
}
}
}
}

} else {
# If cancelled and no later revision exists, add to
list
if {([string match *8.3 SOTM* $sIARelease] == "0")} {
puts "- Removing $sType\t$sName\t$sRev from
list"
} else {

6
Copy of RelB0toXML83SOTM.mql 7/31/2007

lappend sCDFixList2 "$sType\t$sName\t$sRev"


puts "+ No newer revision available"
}
}

if {$sState == "Released" || $sState == "Print Services" || $sState ==


"Archived" || $sState == "Concept"} {
if {([string match "*8.3 SOTM*" $sIARelease] == "0")} {
puts "- Removing $sCDFixDoc from list"
} else {
lappend sCDFixList2 "$sType\t$sName\t$sRev"
puts "+ No newer revision available"
}
}
}

set sCtcFixList4 {}

foreach sCDFixDoc2 $sCDFixList2 {


set sType [lindex [split $sCDFixDoc2 "\t"] 0]
set sName [lindex [split $sCDFixDoc2 "\t"] 1]
set sRev [lindex [split $sCDFixDoc2 "\t"] 2]

set sCDFixList3 [split [mql temp query bus $sType $sName $sRev\
select Description\
current\
{attribute[Document Date]}\
{attribute[Related I/A Series Release]} \
{attribute[B0 Category]}\
{format[Adobe Reader].file.name}\
{format[Adobe Reader].file.size}\
{format[MS Excel].hasfile}\
{format[MS Excel].file.name}\
{format[MS Excel].file.size}\
dump "\t"] \n]

foreach sCDFixDoc3 $sCDFixList3 {


lappend sCtcFixList4 $sCDFixDoc3
}
}

set sCtcList {}
set sCtcList [fixList $sCtcFixList4 $sCtcList]

set sXMLFile [LDir "VB_LOCATION"]


append sXMLFile "/b0.xml"
set sFileId [ open $sXMLFile "w" ]
puts $sFileId "<books>"

foreach sCtcDoc $sCtcList {

set sType [lindex [split $sCtcDoc "\t"] 0]


set sName [checkName $sType [string toupper [lindex [split $
sCtcDoc "\t"] 1]]]

set sRev [lindex [split $sCtcDoc "\t"] 2]


set sDescription [lindex [split $sCtcDoc "\t"] 3]
set sState [lindex [split $sCtcDoc "\t"] 4]
set sStateDate [lindex [split $sCtcDoc "\t"] 5]
puts "$sType\t$sName\t$sRev"

7
Copy of RelB0toXML83SOTM.mql 7/31/2007

if {$sName != "MI 020-495"} {


set sCategory [lindex [split $sCtcDoc "\t"] 7]
} else {
set sCategory "System Configurators"
}
if {($sName != "B0193AX") && ($sName != "B0193RT") && ($sName !=
"B0700CU")} {
set sFileName [lindex [split $sCtcDoc "\t"] 8]
set sFileSize [lindex [split $sCtcDoc "\t"] 9]
set sHasExcel [lindex [split $sCtcDoc "\t"] 10]

writeBookInfo $sFileId $sName $sRev $sDescription $sStateDate $


sCategory $sState $sFileName $sFileSize

if {$sHasExcel == "TRUE"} {
set tabCount [regsub -all \t $sCtcDoc () ignore]
puts "$sName\t$tabCount"
set nExcel [expr (($tabCount - 10)/2)]
puts "Excel: $nExcel"
set i 0
while {$i < $nExcel} {
set sFileName [lindex [split $sCtcDoc "\t"] [expr ($
i + 11)]]
set sFileSize [lindex [split $sCtcDoc "\t"] [expr ($
i + $nExcel + 11)]]
set sDescription "[getDescription $sFileName]"
writeBookInfo $sFileId $sName $sRev $sDescription $
sStateDate $sCategory $sState $sFileName $sFileSize
set i [expr ($i+1)]
}

}
} elseif {($sName == "B0193AX")} {
set tabCount [regsub -all \t $sCtcDoc () ignore]
puts "$sName\t$tabCount"
puts "$sCtcDoc"
set nPDF [expr (($tabCount - 8)/2)]
set i 0
while {$i < $nPDF} {
set sFileName [lindex [split $sCtcDoc "\t"] [expr ($i + 8)]]
set sFileSize [lindex [split $sCtcDoc "\t"] [expr ($i + $
nPDF + 8)]]
set sDescription1 "$sDescription (Vol [expr ($i+1)])"

if {$i == 0} {
set sDescription1 "$sDescription1 (ACCUM - DTIME)"
} elseif {$i == 1} {
set sDescription1 "$sDescription1 (ECB - MOVLV)"
} elseif {$i == 2} {
set sDescription1 "$sDescription1 (MSG - VLV)"
}

writeBookInfo $sFileId $sName $sRev $sDescription1 $sStateDate


$sCategory $sState $sFileName $sFileSize
set i [expr ($i+1)]
}
} elseif {($sName == "B0193RT")} {
set tabCount [regsub -all \t $sCtcDoc () ignore]
set nPDF [expr (($tabCount - 8)/2)]
set i 0
while {$i < $nPDF} {
set sFileName [lindex [split $sCtcDoc "\t"] [expr ($i + 8)]]
set sFileSize [lindex [split $sCtcDoc "\t"] [expr ($i + $
nPDF + 8)]]

8
Copy of RelB0toXML83SOTM.mql 7/31/2007

if {[string length $sFileName] < 14} {


writeBookInfo $sFileId $sName $sRev $sDescription $sStateDate
$sCategory $sState $sFileName $sFileSize
} else {
writeBookInfo $sFileId $sName "D" "Winchester Systems FlashDisk
RAID Controller Reference Manual (Vendor Documentation)"
"08/22/02" $sCategory $sState $sFileName $sFileSize
}
set i [expr ($i+1)]
}
} elseif {($sName == "B0700CU")} {
set tabCount [regsub -all \t $sCtcDoc () ignore]
set nPDF [expr (($tabCount - 8)/2)]
set i 0
while {$i < $nPDF} {
set sFileName [lindex [split $sCtcDoc "\t"] [expr ($i + 8)]]
set sFileSize [lindex [split $sCtcDoc "\t"] [expr ($i + $
nPDF + 8)]]
if {[string length $sFileName] < 14} {
writeBookInfo $sFileId $sName $sRev $sDescription $sStateDate
$sCategory $sState $sFileName $sFileSize
} else {
writeBookInfo $sFileId $sName "B" "Winchester Systems FlashDisk
RAID 1 and RAID 5 Instructions (Vendor Documentation [expr $i])"
"08/22/02" $sCategory $sState $sFileName $sFileSize
}
set i [expr ($i+1)]
}
}
}

writeBookInfo $sFileId "Help" "" "System Management Displays" "09/19/1997"


"Operations" "Released" "smdh_hlp.hlp" "1232608"
writeBookInfo $sFileId "Help" "" "Integrated Control Configurator"
"03/30/2001" "System Configurators" "Released" "icchelp.hlp" "8791244"
writeBookInfo $sFileId "Help" "" "Operator Action Journal" "02/28/2001"
"System Configurators" "Released" "oaj.hlp" "38087"
writeBookInfo $sFileId "Help" "" "Process Summary Report Configurator"
"01/31/1999" "System Configurators" "Released" "psr.hlp" "49157"
writeBookInfo $sFileId "B0700AV" "B" "FBM228 H1 Load (.xls)" "12/15/2004"
"Planning" "Released" "FBM228_H1_Load.xls" "95232"
#writeBookInfo $sFileId "MI 020-495" "B" "Intelligent Field Device
Configurator IFDC for use with I/A Series Systems and PC20 for use with
Windows--Based PCs" "06/28/2002" "System Configurators" "Released"
"../mi/mi_020-495_B.pdf" "3887893"

puts $sFileId "</books>"


close $sFileId

set runCreateHTM [LDir "VB_LOCATION"]


append runCreateHTM "/createHTM.vbs"
set xmlLocation [LDir "VB_LOCATION"]
append xmlLocation "/b0.xml"

puts "$runCreateHTM $xmlLocation"


mql shell wscript "$runCreateHTM" "$xmlLocation"

set runCopyPDF [LDir "VB_LOCATION"]


append runCopyPDF "/copyPDF.vbs"

puts "$runCopyPDF $xmlLocation"


mql shell wscript "$runCopyPDF" "$xmlLocation"
}

You might also like