#!/iw/perl/current/bin/perl # File : tm2xml # Purpose : Converts trademark in raw format to XML # limit scope package Trademark::tm2xml; my $Id =<<'EoI'; # $Id: //depot/isms/skulker/trademark/1.0/bin/tm2xml#10 $ EoI my $RELEASE = sprintf("%d", $Id =~ /^# \$Id: .*#(\d+)/); my($VERSION) = "1.0"; BEGIN { my $iw_root = ($ENV{IW}) ? $ENV{IW} : "/iw"; my $mark_root = "$iw_root/skulker/trademark/current"; $mapperFile = "$mark_root/etc/markspace.tcl"; # where we find our local libraries my($libdir) = "$mark_root/lib"; if ( -d $libdir) { unshift(@INC, $libdir); } unshift(@INC, "$iw_root/skulker/common/current/lib"); require 'tm-lib.pl'; } # Skulking libraries use IW::Skulker; use IW::Parse; # for processing command line options use Getopt::Std; # process command line options if any my(%opt); getopts('fv', \%opt); if($opt{'v'}) { print &version($VERSION, $RELEASE), "\n"; exit; } # Sub getversion sub version { my($version, $release) = @_; return __PACKAGE__ . " " . $version . "r" . $RELEASE; } # Get sub string sub getSubstring { my($data, $start, $length) = @_; my($subStr) = ""; if(length($data) >= $start) { $subStr = substr($data, $start, $length); } return $subStr; } # Sub to get Block Name sub getBlockName { my(%hashData) = @_; my($blockName) = "doc.us.mark."; if($hashData{'fileSegment'} eq 'TRMK') { $blockName .= "TRMK." . substr($hashData{'serial.number'}, 0, 2) . "." . substr($hashData{'serial.number'}, 2, 3) . "." . substr($hashData{'serial.number'}, 5, 3); } elsif($hashData{'fileSegment'} eq 'TSGN') { $blockName .= "TSGN.$hashData{'reel.number'}.$hashData{'frame.number'}"; } elsif($hashData{'fileSegment'} eq 'TKAB') { $blockName .= "TKAB." . substr($hashData{'proceeding.number'}, 0, 2) . "." . substr($hashData{'proceeding.number'}, 2, 3) . "." . substr($hashData{'proceeding.number'}, 5, 3); } return $blockName; } # Sub to start XML block sub XMLHeader { my(%hashData) = @_; # my($XMLout) = "\n"; my($XMLout) = ""; $XMLout .= "\n"; my(%parsedDate); $XMLout .= "$Trademark::lib::fileSegment{$hashData{'fileSegment'}}\n"; $XMLout .= "\n"; $XMLout .= "\n"; $XMLout .= "\n"; $XMLout .= "$Trademark::lib::keyAction{$hashData{'keyAction'}}\n"; # Parse Transaction Date %parsedDate = &IW::Skulker::parseDate(text => $hashData{'transactionDate'}); $XMLout .= "$hashData{'transactionDate'}\n"; $XMLout .= "\n"; $XMLout .= "\n"; if($hashData{'fileSegment'} eq 'TRMK') { $XMLout .= "\n"; } elsif($hashData{'fileSegment'} eq 'TSGN') { $XMLout .= "\n"; } elsif($hashData{'fileSegment'} eq 'TKAB') { $XMLout .= "\n"; } return $XMLout; } # Sub to end XML Block sub XMLTrailer { my(%hashData) = @_; my($XMLout); if($hashData{'fileSegment'} eq 'TRMK') { $XMLout = "\n"; } elsif($hashData{'fileSegment'} eq 'TSGN') { $XMLout = "\n"; } elsif($hashData{'fileSegment'} eq 'TKAB') { $XMLout = "\n"; } $XMLout .= "\n"; $XMLout .= "\n"; $XMLout .= "\n"; $XMLout .= "\n"; return $XMLout; } # Sub to trim the data sub trim { my($data) = @_; my($ret) = $data || ""; $ret =~ s/^\s+//g; $ret =~ s/\s+$//g; return $ret; } # Sub to get Date XML sub getDateXML { my($tag, $val) = @_; my($xmlStr) = ""; my(%parsedDate); if($val !~ /^0+$/ && $val !~ /\s+/) { %parsedDate = &IW::Skulker::parseDate(text => $val); $xmlStr = "<$tag month=\"$parsedDate{'month'}\" day=\"$parsedDate{'day'}\" year=\"$parsedDate{'year'}\">$val\n"; } return($xmlStr); } # Sub to get Flag XML sub getFlagXML { my($tag, $val) = @_; my($xmlStr) = ""; if($val eq 'T') { $xmlStr = "<$tag>NULLData\n"; } return($xmlStr); } # Sub to get GENV XML sub getGenvXML { my($code, $seq, $text, %hashData) = @_; my($tag) = $Trademark::lib::genvTags{$code}; if($seq eq '0001') { $hashData{'genv'} =~ s/<$tag>/<$tag >/g; $hashData{'genv'} .= "<$tag>$text\n"; } else { $hashData{'genv'} =~ s/<$tag>(.*)<\/$tag>/<$tag>$1$text<\/$tag>/; } return %hashData; } # Sub to get GENV XML for GS and AF only sub getGenvGSAFXML { my($code, $seq, $text, $primeclass, %hashData) = @_; my($tag) = $Trademark::lib::genvTags{$code}; if($seq eq '0001') { $hashData{'genv'} .= "<$tag prime-class=\"$primeclass\">$text\n"; } else { $hashData{'genv'} =~ s/<$tag prime-class=\"$primeclass\">(.*)<\/$tag>/<$tag prime-class=\"$primeclass\">$1$text<\/$tag>/; } return %hashData; } # Sub to get GENV XML with month and year attributes sub getGenvMYXML { my($code, $seq, $text, $month, $year, %hashData) = @_; my($tag) = $Trademark::lib::genvTags{$code}; # Convert month number to actual month $month =~ s/^0//; $month = trim($month); $month = $Trademark::lib::months{$month}; if($seq eq '0001') { $hashData{'genv'} .= "<$tag month=\"$month\" year=\"$year\">$text\n"; } else { $hashData{'genv'} =~ s/<$tag month=\"$month\" year=\"$year\">(.*)<\/$tag>/<$tag month=\"$month\" year=\"$year\">$1$text<\/$tag>/; } return %hashData; } # Sub to get OWNX XML sub getOwnxXML { my($code, $seq, $text, %hashData) = @_; my($tag) = $Trademark::lib::ownxTags{$code}; $text = &IW::Skulker::encodeData(text => $text); if($seq eq '0001') { $hashData{'ownx'} .= "<$tag>$text\n"; } else { $hashData{'ownx'} =~ s/<$tag>(.*)<\/$tag>/<$tag>$1$text<\/$tag>/; } return %hashData; } # Sub to get class description sub getClasDesc { my($code, $type) = @_; my($desc); $code =~ s/^0+//; $code =~ s/\s+$//; if($code >= 1 && $code <= 34 && $type eq 'intl') { $desc = "Trademarks and Service Marks - Goods"; } elsif($code >= 35 && $code <= 42 && $type eq 'intl') { $desc = "Trademarks and Service Marks - Services"; } elsif($code >=1 && $code <=52 && $type eq 'us') { $desc = "Trademarks and Service Marks - Goods"; } elsif($code >= 100 && $code <=107 && $type eq 'us') { $desc = "Trademarks and Service Marks - Services"; } elsif($code =~ /[A-Z]/) { $desc = "Certification Marks"; } else { $desc = "Collective Membership Marks"; } return $desc; } # Sub to get postal XML sub getPostalXML { my($address1, $address2, $city, $zip, $region) = @_; my($postal); $postal = "\n"; if($address1 || $address2) { $address1 = &IW::Skulker::encodeData(text => $address1); $address2 = &IW::Skulker::encodeData(text => $address2); $postal .= "" . $address1 . " " . $address2 . "\n"; } if($city) { $city = &IW::Skulker::encodeData(text => $city); $postal .= "$city\n"; } $region = trim($region); if(length($region) == 2) { $postal .= "$Trademark::lib::usStateCodes{$region}\n"; } elsif(length($region) > 3) { $postal .= "$region\n"; } if($zip) { $zip = &IW::Skulker::encodeData(text => $zip); $postal .= "$zip\n"; } if(length($region) == 3) { $postal .= "$Trademark::lib::countryCodes{$region}\n"; } $postal .= "\n"; return $postal; } # Sub to get name XML sub getNameXML { my($tag, $value) = @_; my($fname, $lname, $mname); my($XML, %parsedName); $XML = ""; $value = &IW::Skulker::encodeData(text => $value); # Parse out name %parsedName = &IW::Skulker::parseName(text => $value); if($value =~ /\w+/) { $fname = $parsedName{'firstname'} || ""; $mname = $parsedName{'middlename'} || ""; $lname = $parsedName{'lastname'} || ""; $XML = "<$tag first-name=\"$fname\" middle-name=\"$mname\" last-name=\"$lname\">$value\n"; } return $XML; } # Sub to parse correspondence address sub getCorrAddressXML { my($text) = @_; my($XML, $i, @street, $str, $name); $name = ""; # Insert commas into $text for($i=40; $i<=160; $i+=40) { if(length($text) > $i) { substr($text, $i, 0) = ","; } else { last; } } $text =~ s/\(//g; $text =~ s/\)//g; my(%parsedPostal) = &IW::Skulker::parsePostal(text => $text); $i = $parsedPostal{'street'}; @street = @$i; if($#street == 1) { $str = trim($street[0]); } else { $name = trim($street[0]); for($i=1; $i<=$#street; $i++) { $str .= trim($street[$i]); if($i < $#street) { $str .= ", "; } } } $XML = "\n"; $XML .= &getNameXML('name', $name); $XML .= &getPostalXML($str, '', $parsedPostal{'city'}, $parsedPostal{'code'}, $parsedPostal{'region'}); $XML .= "\n"; return $XML; } # Sub to get OWNR XML sub getOwnrXML { my(%hashData) = @_; my(%owner); my($i, $this); my(@record) = @{$hashData{'owner'}}; for($i = 0; $i <= $#record; $i++) { $hashData{'ownr'} .= "\n"; $this = $record[$i]{'partyType'}; $hashData{'ownr'} .= "$Trademark::lib::partyType{$this}\n"; if($record[$i]{'partyType'} ne '70') { $this = $record[$i]{'entityType'}; $hashData{'ownr'} .= "$Trademark::lib::entityType{$this}\n"; $hashData{'ownr'} .= &getNameXML('party.name', $record[$i]{'name'}); $this = $record[$i]{'citizenship'}; if(length($this) == 2) { $hashData{'ownr'} .= "$Trademark::lib::usStateCodes{$this}\n"; } elsif(length($this) == 3) { $hashData{'ownr'} .= "$Trademark::lib::countryCodes{$this}\n"; } $hashData{'ownr'} .= &getPostalXML($record[$i]{'address1'}, $record[$i]{'address2'}, $record[$i]{'city'}, $record[$i]{'zip'}, $record[$i]{'region'}); $this = trim($record[$i]{'name.change.text'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'ownr'} .= "$this\n"; } $this = trim($record[$i]{'composed.of.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'ownr'} .= "$this\n"; } $this = trim($record[$i]{'dba.aka.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'ownr'} .= "$this\n"; } $this = trim($record[$i]{'entity.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'ownr'} .= "$this\n"; } } else { $hashData{'ownr'} .= &getCorrAddressXML($record[$i]{'address1'}); } $hashData{'ownr'} .= "\n"; } return %hashData; } # Get ASGN XML sub getAsgnXML { my(%hashData) = @_; my($i, $this); my(@record) = @{$hashData{'asg'}}; for($i=0;$i<=$#record;$i++) { $hashData{'asgn'} .= "\n"; $this = $record[$i]{'signed.date'}; $hashData{'asgn'} .= &getDateXML('signed.date', $this); $this = $record[$i]{'acknowledged.date'}; $hashData{'asgn'} .= &getDateXML('acknowledged.date', $this); $this = $record[$i]{'asgn.type'}; $hashData{'asgn'} .= "NULLData\n"; $this = $record[$i]{'entity.type'}; $hashData{'asgn'} .= "$Trademark::lib::entityType{$this}\n"; $this = $record[$i]{'name'} || ""; $hashData{'asgn'} .= &getNameXML('asgn.name', $this); $this = trim($record[$i]{'citizenship'}); if(length($this) == 2) { $hashData{'asgn'} .= "$Trademark::lib::usStateCodes{$this}\n"; } elsif(length($this) == 3) { $hashData{'asgn'} .= "$Trademark::lib::countryCodes{$this}\n"; } $hashData{'asgn'} .= &getPostalXML($record[$i]{'address1'}, $record[$i]{'address2'}, $record[$i]{'city'}, $record[$i]{'zip'}, $record[$i]{'region'}); $this = trim($record[$i]{'composed.of.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'asgn'} .= "$this\n"; } $this = trim($record[$i]{'dba.aka.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'asgn'} .= "$this\n"; } $this = trim($record[$i]{'entity.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'asgn'} .= "$this\n"; } $hashData{'asgn'} .= "\n"; } return %hashData; } # Sub to get PART XML sub getPartXML { my(%hashData) = @_; my($this, $i); my(@record) = @{$hashData{'party'}}; for($i=0;$i<=$#record;$i++) { $hashData{'part'} .= "\n"; $this = $record[$i]{'name'} || ""; $hashData{'part'} .= &getNameXML('name', $this); $hashData{'part'} .= &getPostalXML($record[$i]{'address1'}, $record[$i]{'address2'}, $record[$i]{'city'}, $record[$i]{'zip'}, $record[$i]{'region'}); $this = trim($record[$i]{'composed.of.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'part'} .= "$this\n"; } $this = trim($record[$i]{'dba.aka.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'part'} .= "$this\n"; } $this = trim($record[$i]{'entity.statement'}); $this = &IW::Skulker::encodeData(text => $this); if($this) { $hashData{'part'} .= "$this\n"; } $hashData{'part'} .= "\n"; } return %hashData; } # Sub to get overflow record sub getOverflowRecord { my($tag, $element, %hashData) = @_; my($i, $overflow, $flag, $data1, $data2); my(@record) = @{$hashData{$element}}; if($tag eq 'flagAddress1') { $flag = "address1Done"; } elsif($tag eq 'flagAddress2') { $flag = "address2Done"; } elsif($tag eq 'flagName') { $flag = "nameDone"; } elsif($tag eq 'flagChangeName') { $flag = "nameChangeDone"; } elsif($tag eq 'flagCmpStat') { $flag = "cmpStatDone"; } elsif($tag eq 'flagDbaAka') { $flag = "dbaAkaDone"; } elsif($tag eq 'flagEntity') { $flag = "entityDone"; } for($i=0;$i<=$#record;$i++) { $data1 = $record[$i]{$tag} || ""; $data2 = $record[$i]{$flag} || ""; if($data1 eq 'T' && $data2 ne 'done') { $overflow = $i; last; } } return $overflow; } # Sub to parse GENX blocks sub parseGENX { my($record, %hashData) = @_; my($this, $flag1, $flag2, $flag3, $flag4, $flag5, $flag6); $hashData{'genx'} = "\n\n"; # Start extracting required data # Get file Segment $hashData{'fileSegment'} = &getSubstring($record, 0, 4); # Get key action $hashData{'keyAction'} = &getSubstring($record, 10, 2); # Get serial number $flag1 = &getSubstring($record, 18, 6); $flag2 = &getSubstring($record, 16, 2); $flag3 = $Trademark::lib::seriesCode{$flag2} || ""; $hashData{'genx'} .= "$flag2$flag1\n"; $hashData{'serial.number'} = &getSubstring($record, 16, 8); # Get blockname $hashData{'blockName'} = &getBlockName(%hashData); # Get registration number $this = &getSubstring($record, 24, 7); $hashData{'genx'} .= "$this\n"; # Get transaction date $hashData{'transactionDate'} = &getSubstring($record, 31, 8); # Get amend register date $this = &getSubstring($record, 39, 8); $hashData{'genx'} .= &getDateXML('amend.register.date', $this); # Get cancellation code $this = &getSubstring($record, 47, 1); $flag1 = $Trademark::lib::cancellationCode{$this} || ""; $hashData{'genx'} .= "$flag1\n"; # Get cancellation date $this = &getSubstring($record, 48, 8); $hashData{'genx'} .= &getDateXML('cancellation.date', $this); # Get filing date $this = &getSubstring($record, 56, 8); $hashData{'genx'} .= &getDateXML('filing.date', $this); $hashData{'filing.date'} = $this; # Get pub opposition date $this = &getSubstring($record, 64, 8); $hashData{'genx'} .= &getDateXML('pub.opposition.date', $this); # Get pub date $this = &getSubstring($record, 72, 8); $hashData{'genx'} .= &getDateXML('pub.date', $this); # Get registration date $this = &getSubstring($record, 80, 8); $hashData{'genx'} .= &getDateXML('registration.date', $this); # Get status date $this = &getSubstring($record, 88, 8); $hashData{'genx'} .= &getDateXML('status.date', $this); # Get flag amend principal register $this = &getSubstring($record, 96, 1); $hashData{'genx'} .= &getFlagXML('flag.amend.principal.register', $this); # Get flag amend supp register $this = &getSubstring($record, 97, 1); $hashData{'genx'} .= &getFlagXML('flag.amend.supp.register', $this); # Get mark type code # Get flag trademark $flag1 = &getSubstring($record, 98, 1); # Get flag collective mark $flag2 = &getSubstring($record, 99, 1); # Get flag service mark $flag3 = &getSubstring($record, 100, 1); # Get flag collective service $flag4 = &getSubstring($record, 101, 1); # Get flag collective membership mark $flag5 = &getSubstring($record, 102, 1); # Get flag certification mark $flag6 = &getSubstring($record, 103, 1); $hashData{'genx'} .= "NULLData\n"; # Get flag cancel pending $this = &getSubstring($record, 104, 1); $hashData{'genx'} .= &getFlagXML('flag.cancel.pending', $this); # Get flag pub concurrent $this = &getSubstring($record, 105, 1); $hashData{'genx'} .= &getFlagXML('flag.pub.concurrent', $this); # Get flag concurrent use $this = &getSubstring($record, 106, 1); $hashData{'genx'} .= &getFlagXML('flag.concurrent.use', $this); # Get flag concurrent use proc $this = &getSubstring($record, 107, 1); $hashData{'genx'} .= &getFlagXML('flag.concurrent.use.proc', $this); # Get flag interference pending $this = &getSubstring($record, 108, 1); $hashData{'genx'} .= &getFlagXML('flag.interference.pending', $this); # Get flag opposition pending $this = &getSubstring($record, 110, 1); $hashData{'genx'} .= &getFlagXML('flag.opposition.pending', $this); # Get flag repub section 12 c $this = &getSubstring($record, 111, 1); $hashData{'genx'} .= &getFlagXML('flag.repub.section.12c', $this); # Get flag section 2f $this = &getSubstring($record, 112, 1); $hashData{'genx'} .= &getFlagXML('flag.section.2f', $this); # Get flag section 2f part $this = &getSubstring($record, 113, 1); $hashData{'genx'} .= &getFlagXML('flag.section.2f.part', $this); # Get flag section 8 accept $this = &getSubstring($record, 114, 1); $hashData{'genx'} .= &getFlagXML('flag.section.8.accept', $this); # Get flag section 15 ack $this = &getSubstring($record, 115, 1); $hashData{'genx'} .= &getFlagXML('flag.section.15.ack', $this); # Get flag renewal filed $this = &getSubstring($record, 116, 1); $hashData{'genx'} .= &getFlagXML('flag.renewal.filed', $this); # Get flag supp register $this = &getSubstring($record, 117, 1); $hashData{'genx'} .= &getFlagXML('flag.supp.register', $this); # Get flag section 8 filed $this = &getSubstring($record, 118, 1); $hashData{'genx'} .= &getFlagXML('flag.section.8.filed', $this); # Get flag section 8 partial accept $this = &getSubstring($record, 119, 1); $hashData{'genx'} .= &getFlagXML('flag.section.8.partial.accept', $this); # Get flag section 15 filed $this = &getSubstring($record, 120, 1); $hashData{'genx'} .= &getFlagXML('flag.section.15.filed', $this); # Get flag foreign priority claimed $this = &getSubstring($record, 121, 1); $hashData{'genx'} .= &getFlagXML('flag.foreign.priority.claimed', $this); # Get flag change registration $this = &getSubstring($record, 122, 1); $hashData{'genx'} .= &getFlagXML('flag.change.registration', $this); # Get status code $this = &getSubstring($record, 123, 3); $flag1 = $Trademark::lib::statusCode{$this} || ""; $hashData{'genx'} .= "$flag1\n"; # Get mark drawing code $this = &getSubstring($record, 126, 4); ($flag1, $flag2, $flag3) = ($this =~ /(.)(.)(..)/); $flag1 = $Trademark::lib::mdcPhysicalAppearance{$flag1} || ""; $flag2 = $Trademark::lib::mdcSizingCode{$flag2} || ""; $hashData{'genx'} .= "NULLData\n"; # Get actual mark $this = &getSubstring($record, 130, 40); $this = trim($this); $this = &IW::Skulker::encodeData(text => $this); $hashData{'genx'} .= "$this\n"; # Get law office $this = &getSubstring($record, 170, 1); $this = trim($this); if($this) { $flag1 = $Trademark::lib::tmLawOffice{$this} || ""; $hashData{'genx'} .= "$flag1\n"; } # Get flag intent to use $this = &getSubstring($record, 171, 1); $hashData{'genx'} .= &getFlagXML('flag.intent.to.use', $this); # Get flag intent to use current $this = &getSubstring($record, 172, 1); $hashData{'genx'} .= &getFlagXML('flag.intent.to.use.current', $this); # Get renewal date $this = &getSubstring($record, 173, 8); $hashData{'genx'} .= &getDateXML('renewal.date', $this); # Get attorney docket number $this = &getSubstring($record, 181, 12); $this = trim($this); $this = &IW::Skulker::encodeData($this); if($this) { $hashData{'genx'} .= "$this\n"; } $hashData{'genx'} .= "\n\n"; return %hashData; } # Sub to parse GENV blocks sub parseGENV { my($record, %hashData) = @_; my($i, $code, $text, $seq, $this, $primeclass, $month, $year); $hashData{'genv'} .= "\n"; # Start extracting out necessary data for($i = 39; $i < 289; $i += 50) { if(length($record) > $i) { $code = &getSubstring($record, $i, 2); $seq = &getSubstring($record, $i+6, 4); $primeclass = &getSubstring($record, $i+2, 3); $year = &getSubstring($record, $i+2, 2); $month = &getSubstring($record, $i+4, 2); $text = &getSubstring($record, $i+10, 40); $text = trim($text); $text = &IW::Skulker::encodeData(text => $text); if($code eq 'MK') { $hashData{'genx'} =~ s/(.*)<\/actual.mark>/$1 $text<\/actual.mark>/; } elsif($code eq 'GS' || $code eq 'AF') { %hashData = &getGenvGSAFXML($code, $seq, $text, $primeclass, %hashData); } elsif($code eq 'A0' || $code eq 'B0' || $code eq 'CU' || $code eq 'MD' || $code eq 'OR') { %hashData = &getGenvMYXML($code, $seq, $text, $month, $year, %hashData); } elsif($code eq 'CS' || $code eq 'DM' || $code eq 'D0' || $code eq 'D1' || $code eq 'LS' || $code eq 'N0' || $code eq 'PM' || $code eq 'TF' || $code eq 'TR') { %hashData = &getGenvXML($code, $seq, $text, %hashData); } } else { last; } } $hashData{'genv'} .= "\n\n"; return %hashData; } # Sub to parse PRUS blocks sub parsePRUS { my($record, %hashData) = @_; my($this, $i); my($code, $value, $data1); $hashData{'prus'} .= "\n"; # Extract the required data # Get and others $this = &getSubstring($record, 39, 1); $hashData{'prus'} .= &getFlagXML('and.others', $this); # Get prior group for($i = 40; $i < 319; $i += 9) { if(length($record) >= ($i+9)) { $code = &getSubstring($record, $i, 1); $value = &getSubstring($record, $i+1, 8); $value = trim($value); $data1 = $Trademark::lib::priorGroup{$code} || ""; $hashData{'prus'} .= "NULLData\n"; } else { last; } } $hashData{'prus'} .= "\n\n"; return %hashData; } # Sub to parse FRGN blocks sub parseFRGN { my($record, %hashData) = @_; my($this, $data1); $hashData{'frgn'} .= "\n"; # Start extracting data # Get foreign filing date $this = &getSubstring($record, 39, 8); $hashData{'frgn'} .= &getDateXML('foreign.filing.date', $this); # Get foreign registration date $this = &getSubstring($record, 47, 8); $hashData{'frgn'} .= &getDateXML('foreign.registration.date', $this); # Get foreign expiration date $this = &getSubstring($record, 55, 8); $hashData{'frgn'} .= &getDateXML('foreign.expiration.date', $this); # Get foreign renewal date $this = &getSubstring($record, 63, 8); $hashData{'frgn'} .= &getDateXML('foreign.renewal.date', $this); # Get foreign ren exp date $this = &getSubstring($record, 71, 8); $hashData{'frgn'} .= &getDateXML('foreign.ren.exp.date', $this); # Get foreign app number $this = &getSubstring($record, 82, 12); $this = trim($this); if($this) { $hashData{'frgn'} .= "$this\n"; } # Get foreign country code $this = &getSubstring($record, 94, 3); $data1 = $Trademark::lib::countryCodes{$this} || ""; $hashData{'frgn'} .= "$data1\n"; # Get foreign reg number $this = &getSubstring($record, 97, 12); $this = trim($this); if($this) { $hashData{'frgn'} .= "$this\n"; } # Get foreign ren number $this = &getSubstring($record, 109, 12); $this = trim($this); if($this) { $hashData{'frgn'} .= "$this\n"; } # Get foreign priority claimed $this = &getSubstring($record, 121, 1); $hashData{'frgn'} .= &getFlagXML('flag.foreign.priority.claimed', $this); $hashData{'frgn'} .= "\n\n"; return %hashData; } # Sub to parse CLAS blocks sub parseCLAS { my($record, %hashData) = @_; my($this, $i, $cic, $cus, $data1); $hashData{'clas'} .= "\n"; # Start extracting data # Get cic $cic = &getSubstring($record, 39, 2); # Get cus $cus = &getSubstring($record, 41, 2); # Get international class for($i = 43; $i < 43 + 3*$cic; $i += 3) { $this = &getSubstring($record, $i, 3); $hashData{'clas'} .= "" . &getClasDesc($this, 'intl') . "\n"; } # Get us class for($i = 133; $i < 133 + 3*$cus; $i += 3) { $this = &getSubstring($record, $i, 3); $hashData{'clas'} .= "" . &getClasDesc($this, 'us') . "\n"; } # Get class status $this = &getSubstring($record, 223, 1); $data1 = $Trademark::lib::classStatus{$this} || ""; $hashData{'clas'} .= "$data1\n"; # Get class status date $this = &getSubstring($record, 224, 8); $hashData{'clas'} .= &getDateXML('class.status.date', $this); # Get first use date $this = &getSubstring($record, 232, 8); $hashData{'clas'} .= &getDateXML('first.use.date', $this); # Get first use commerce date $this = &getSubstring($record, 240, 8); $hashData{'clas'} .= &getDateXML('first.use.commerce.date', $this); # Get prime class $this = &getSubstring($record, 248, 3); if($this eq 'NRN') { $hashData{'clas'} .= "NULLData\n"; } elsif($hashData{'filing.date'} < 19730901) { $hashData{'clas'} .= "NULLData\n"; } elsif($hashData{'filing.date'} >= 19730901) { $hashData{'clas'} .= "NULLData\n"; } $hashData{'clas'} .= "\n"; return %hashData; } # Sub to parse OWNR blocks sub parseOWNR { my($record, %hashData) = @_; my(%owner, $this); # Start extracting data # Get address 1 $owner{'address1'} = &getSubstring($record, 39, 40); # Get address 2 $owner{'address2'} = &getSubstring($record, 79, 40); # Get citizenship $this = &getSubstring($record, 119, 3); $owner{'citizenship'} = trim($this); # Get city $this = &getSubstring($record, 122, 40); $owner{'city'} = trim($this); # Get entity type $this = &getSubstring($record, 162, 2); $owner{'entityType'} = trim($this); # Get name $owner{'name'} = &getSubstring($record, 166, 120); # Get party type $owner{'partyType'} = &getSubstring($record, 286, 2); # Get state/country $owner{'region'} = &getSubstring($record, 288, 3); # Get zip code $owner{'zip'} = &getSubstring($record, 291, 9); $owner{'zip'} = trim($owner{'zip'}); # Get address1 overflow $owner{'flagAddress1'} = &getSubstring($record, 300, 1); # Get address2 overflow $owner{'flagAddress2'} = &getSubstring($record, 301, 1); # Get name change flag $owner{'flagChangeName'} = &getSubstring($record, 302, 1); # Get composed of statement flag $owner{'flagCmpStat'} = &getSubstring($record, 303, 1); # Get dba aka flag $owner{'flagDbaAka'} = &getSubstring($record, 304, 1); # Get entity flag $owner{'flagEntity'} = &getSubstring($record, 305, 1); # Get name overflow $owner{'flagName'} = &getSubstring($record, 306, 1); # Fix address stuff if party type is 70 if($owner{'partyType'} eq '70') { $owner{'address1'} = $owner{'name'} . " " . $owner{'address1'} . " " . $owner{'address2'}; $owner{'address2'} = ""; $owner{'name'} = ""; } $owner{'address1'} = trim($owner{'address1'}); $owner{'address2'} = trim($owner{'address2'}); $owner{'name'} = trim($owner{'name'}); push(@{$hashData{'owner'}}, \%owner); return %hashData; } # Sub to parse OWNX blocks sub parseOWNX { my($record, %hashData) = @_; my($i, $code, $seq, $text, $specialNum); my($overflowFlag, $doneFlag, $tag); $hashData{'ownx'} .= "\n"; # Start extracting data for($i = 39; $i < 289; $i+= 50) { $code = &getSubstring($record, $i, 2); $specialNum = &getSubstring($record, $i+2, 4); $seq = &getSubstring($record, $i+6, 4); $text = &getSubstring($record, $i+10, 40); $text = trim($text); if($code eq 'AI' || $code eq 'AS' || $code eq 'CO' || $code eq 'DB' || $code eq 'EN' || $code eq 'NC' || $code eq 'PN') { if($code eq 'AI') { $overflowFlag = "flagAddress1"; $doneFlag = "address1Done"; $tag = "address1"; } elsif($code eq 'AS') { $overflowFlag = "flagAddress2"; $doneFlag = "address2Done"; $tag = "address2"; } elsif($code eq 'CO') { $overflowFlag = "flagCmpStat"; $doneFlag = "cmpStatDone"; $tag = "composed.of.statement"; } elsif($code eq 'DB') { $overflowFlag = "flagDbaAka"; $doneFlag = "dbaAkaDone"; $tag = "dba.aka.statement"; } elsif($code eq 'EN') { $overflowFlag = "flagEntity"; $doneFlag = "entityDone"; $tag = "entity.statement"; } elsif($code eq 'NC') { $overflowFlag = "flagChangeName"; $doneFlag = "nameChangeDone"; $tag = "name.change.text"; } elsif($code eq 'PN') { $overflowFlag = "flagName"; $doneFlag = "nameDone"; $tag = "name"; } if($seq eq '0001') { if($specialNum ne '9999') { # Get the overflow OWNR record $Trademark::tm2xml::overflow = &getOverflowRecord($overflowFlag, 'owner', %hashData); $hashData{'owner'}[$Trademark::tm2xml::overflow]{$doneFlag} = "done"; $hashData{'owner'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } } else { $hashData{'owner'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } } elsif($code eq 'AT' || $code eq 'DR') { %hashData = &getOwnxXML($code, $seq, $text, %hashData); } } $hashData{'ownx'} .= "\n\n"; return %hashData; } # Sub to parse DSGN blocks sub parseDSGN { my($record, %hashData) = @_; my($i, $data1, $data2, $data3); $hashData{'dsgn'} .= "\n"; # Start extracting data for($i=39; $i<327;$i+=6) { if(length($record) >= $i+6) { $data1 = &getSubstring($record, $i, 2); $data2 = &getSubstring($record, $i+2, 2); $data3 = &getSubstring($record, $i+4, 2); $hashData{'dsgn'} .= "$data1.$data2.$data3\n"; } else { last; } } $hashData{'dsgn'} .= "\n"; return %hashData; } # Sub to parse DEED blocks sub parseDEED { my($record, %hashData) = @_; my($this, $data1); $hashData{'deed'} .= "\n"; # Start extracting data # Get file segment $hashData{'fileSegment'} = &getSubstring($record, 0, 4); # Get key action $hashData{'keyAction'} = &getSubstring($record, 10, 2); # Get transaction date $hashData{'transactionDate'} = &getSubstring($record, 24, 8); # Get reel number $this = &getSubstring($record, 16, 4); $hashData{'deed'} .= "$this\n"; $hashData{'reel.number'} = $this; # Get frame number $this = &getSubstring($record, 20, 4); $hashData{'deed'} .= "$this\n"; $hashData{'frame.number'} = $this; # Get block name $hashData{'blockName'} = &getBlockName(%hashData); # Get date recorded $this = &getSubstring($record, 32, 8); $hashData{'deed'} .= &getDateXML('recorded.date', $this); # Get number pages $this = &getSubstring($record, 40, 3); $hashData{'deed'} .= "$this\n"; # Get correspondence address $this = &getSubstring($record, 43, 200); # $hashData{'deed'} .= "$this\n"; $hashData{'deed'} .= &getCorrAddressXML($this); # Get brief code $this = &getSubstring($record, 243, 2); $data1 = $Trademark::lib::briefCode{$this} || ""; $hashData{'deed'} .= "$data1\n"; $hashData{'brief.code'} = $this; $hashData{'deed'} .= "\n\n"; return %hashData; } # Sub to parse DEEX blocks sub parseDEEX { my($record, %hashData) = @_; my($date, $jur, $this, $num); $hashData{'deex'} .= "\n"; # Start extracting data # Get record number $num = &getSubstring($record, 32, 2); # Get brief text $this = &getSubstring($record, 34, 280); $this = trim($this); $this = &IW::Skulker::encodeData(text => $this); $hashData{'brief.code'} =~ s/^0+//; if($hashData{'brief.code'} == 4 || $hashData{'brief.code'} == 40) { if($num == 1) { $hashData{'deex'} .= "$this\n"; } else { $hashData{'deex'} =~ s/(.*)<\/brief.text>/$1 $this<\/brief.text>/; } } elsif($hashData{'brief.code'} == 9 || $hashData{'brief.code'} == 19 || $hashData{'brief.code'} == 21) { $date = &getSubstring($record, 34, 8); $jur = &getSubstring($record, 42, 3); $jur = trim($jur); $hashData{'deex'} .= &getDateXML('deed.effective.date', $date); if(length($jur) == 2) { $hashData{'deex'} .= "$Trademark::lib::usStateCodes{$jur}\n"; } elsif(length($jur) == 3) { $hashData{'deex'} .= "$Trademark::lib::countryCodes{$jur}\n"; } } elsif($hashData{'brief.code'} >=12 && $hashData{'brief.code'} <= 16) { $date = &getSubstring($record, 34, 8); $hashData{'deex'} .= &getDateXML('deed.effective.date', $date); } $hashData{'deex'} .= "\n"; return %hashData; } # Sub to parse ASGN blocks sub parseASGN { my($record, %hashData) = @_; my(%asg, $this); # Start extracting data # Get signed date $asg{'signed.date'} = &getSubstring($record, 32 ,8); # Get ack date $asg{'acknowledged.date'} = &getSubstring($record, 40, 8); # Get asgn type $asg{'asgn.type'} = &getSubstring($record, 48, 3); if($asg{'asgn.type'} >= 1 && $asg{'asgn.type'} <=399) { $asg{'asgn.type'} = "Assignor"; } elsif($asg{'asgn.type'} >= 400 && $asg{'asgn.type'} <= 599) { $asg{'asgn.type'} = "name_change"; } elsif($asg{'asgn.type'} > 599) { $asg{'asgn.type'} = "Assignee"; } # Get asgn.name $this = &getSubstring($record, 51, 120); $asg{'name'} = trim($this); # Get address1 $this = &getSubstring($record, 171, 40); $asg{'address1'} = trim($this); # Get address2 $this = &getSubstring($record, 211, 40); $asg{'address2'} = trim($this); # Get city $this = &getSubstring($record, 251, 40); $asg{'city'} = trim($this); # Get region $asg{'region'} = &getSubstring($record, 291, 3); # Get zip $this = &getSubstring($record, 294, 9); $asg{'zip'} = trim($this); # Get citizenship $asg{'citizenship'} = &getSubstring($record, 303, 3); # Get entity type $asg{'entity.type'} = &getSubstring($record, 306, 2); # Get address1 overflow $asg{'flagAddress1'} = &getSubstring($record, 308, 1); # Get address2 overflow $asg{'flagAddress2'} = &getSubstring($record, 309, 1); # Get composed of statement $asg{'flagCmpStat'} = &getSubstring($record, 310, 1); # Get dba aka $asg{'flagDbaAka'} = &getSubstring($record, 311, 1); # Get entity $asg{'flagEntity'} = &getSubstring($record, 312, 1); # Get name $asg{'flagName'} = &getSubstring($record, 313, 1); push(@{$hashData{'asg'}}, \%asg); return %hashData; } # Sub to parse ASGX blocks sub parseASGX { my($record, %hashData) = @_; my($this, $code, $seq, $text, $i); my($overflowFlag, $doneFlag, $tag); for($i = 32; $i<282; $i+=50) { $code = &getSubstring($record, $i, 2); $seq = &getSubstring($record, $i+6, 4); $text = &getSubstring($record, $i+10, 40); $text = trim($text); if($code eq 'AI') { $overflowFlag = "flagAddress1"; $doneFlag = "address1Done"; $tag = "address1"; } elsif($code eq 'AS') { $overflowFlag = "flagAddress2"; $doneFlag = "address2Done"; $tag = "address2"; } elsif($code eq 'CO') { $overflowFlag = "flagCmpStat"; $doneFlag = "cmpStatDone"; $tag = "composed.of.statement"; } elsif($code eq 'DB') { $overflowFlag = "flagDbaAka"; $doneFlag = "dbaAkaDone"; $tag = "dba.aka.statement"; } elsif($code eq 'EN') { $overflowFlag = "flagEntity"; $doneFlag = "entityDone"; $tag = "entity.statement"; } elsif($code eq 'PN') { $overflowFlag = "flagName"; $doneFlag = "nameDone"; $tag = "name"; } if($seq eq '0001') { # Get the overflow ASGN record $Trademark::tm2xml::overflow = &getOverflowRecord($overflowFlag, 'asg', %hashData); $hashData{'asg'}[$Trademark::tm2xml::overflow]{$doneFlag} = "done"; $hashData{'asg'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } else { $hashData{'asg'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } } return %hashData; } # Sub to parse PROP blocks sub parsePROP { my($record, %hashData) = @_; my($i, $data1, $data2, $data3, $data4); $hashData{'prop'} .= "\n"; # Start extracting data for($i=32;$i<317;$i+=15) { if(length($record) >= $i+15) { $data1 = &getSubstring($record, $i, 2); $data4 = $Trademark::lib::seriesCode{$data1} || ""; $data2 = &getSubstring($record, $i+2, 6); $data3 = &getSubstring($record, $i+8, 7); $hashData{'prop'} .= "NULLData\n"; } } $hashData{'prop'} .= "\n"; return %hashData; } # Sub to parse TTAB blocks sub parseTTAB { my($record, %hashData) = @_; my($this, $data1, $data2); $hashData{'ttab'} .= "\n"; # Start extracting data # Get file Segment $hashData{'fileSegment'} = &getSubstring($record, 0, 4); # Get key action $hashData{'keyAction'} = &getSubstring($record, 10, 2); # Get transaction date $hashData{'transactionDate'} = &getSubstring($record, 24, 8); # Get proceeding number $this = &getSubstring($record, 18, 6); $data1 = &getSubstring($record, 16, 2); $data2 = $Trademark::lib::proceedingType{$data1} || ""; $hashData{'ttab'} .= "$data1$this\n"; $hashData{'proceeding.number'} = $data1 . $this; # Get Block Name $hashData{'blockName'} = &getBlockName(%hashData); # Get filing date $this = &getSubstring($record, 32, 8); $hashData{'ttab'} .= &getDateXML('filing.date', $this); # Get status date $this = &getSubstring($record, 40, 8); $hashData{'ttab'} .= &getDateXML('status.date', $this); # Get status code $this = &getSubstring($record, 48, 3); $this =~ s/^0+//; $this =~ s/0+$//; $data1 = $Trademark::lib::ttabStatusCode{$this} || ""; $hashData{'ttab'} .= "$data1\n"; $hashData{'ttab'} .= "\n"; return %hashData; } # Sub to parse PART blocks sub parsePART { my($record, %hashData) = @_; my(%part, $this); # Start extracting data # Get name $this = &getSubstring($record, 35, 120); $part{'name'} = trim($this); # Get address1 $this = &getSubstring($record, 155, 40); $part{'address1'} = trim($this); # Get address2 $this = &getSubstring($record, 195, 40); $part{'address2'} = trim($this); # Get city $this = &getSubstring($record, 235, 40); $part{'city'} = trim($this); # Get region $part{'region'} = &getSubstring($record, 275, 3); # Get zip $this = &getSubstring($record, 278, 9); $part{'zip'} = trim($this); # Get flag address1 $part{'flagAddress1'} = &getSubstring($record, 287, 1); # Get flag address2 $part{'flagAddress2'} = &getSubstring($record, 288, 1); # Get flag composed statement $part{'flagCmpStat'} = &getSubstring($record, 289, 1); # Get flag dba aka $part{'flagDbaAka'} = &getSubstring($record, 290, 1); # Get flag name $part{'flagName'} = &getSubstring($record, 291, 1); push(@{$hashData{'party'}}, \%part); return %hashData; } # Sub to parse PARX blocks sub parsePARX { my($record, %hashData) = @_; my($i, $code, $seq, $text, $overflowFlag, $doneFlag, $tag); # Start extracting data for($i=32;$i<282;$i+=50) { $code = &getSubstring($record, $i, 2); $seq = &getSubstring($record, $i+6, 4); $text = &getSubstring($record, $i+10, 40); $text = trim($text); if($code eq 'A1') { $overflowFlag = "flagAddress1"; $doneFlag = "address1Done"; $tag = "address1"; } elsif($code eq 'A2') { $overflowFlag = "flagAddress2"; $doneFlag = "address2Done"; $tag = "address2"; } elsif($code eq 'CO') { $overflowFlag = "flagCmpStat"; $doneFlag = "cmpStatDone"; $tag = "composed.of.statement"; } elsif($code eq 'DB') { $overflowFlag = "flagDbaAka"; $doneFlag = "dbaAkaDone"; $tag = "dba.aka.statement"; } elsif($code eq 'PN') { $overflowFlag = "flagName"; $doneFlag = "nameDone"; $tag = "name"; } if($seq eq '0001') { # Get the overflow PART record $Trademark::tm2xml::overflow = &getOverflowRecord($overflowFlag, 'party', %hashData); $hashData{'party'}[$Trademark::tm2xml::overflow]{$doneFlag} = "done"; $hashData{'party'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } else { $hashData{'party'}[$Trademark::tm2xml::overflow]{$tag} .= " $text"; } } return %hashData; } # Sub to parse PARC blocks sub parsePARC { my($record, %hashData) = @_; my($this, $att); # Start extracting data # Get correspondence address $this = &getSubstring($record, 32, 200); # Get party entry number $att = &getSubstring($record, 232, 3); $hashData{'parc'} .= "\n"; # $hashData{'parc'} .= "$this\n"; $hashData{'parc'} .= &getCorrAddressXML($this); $hashData{'parc'} .= "\n"; return %hashData; } # Sub to parse APNR blocks sub parseAPNR { my($record, %hashData) = @_; my($i, $data1, $data2, $data3, $data4 ); $hashData{'apnr'} .= "\n"; # Start extracting data for($i=32;$i<320;$i+=18) { if(length($record) >= $i+18) { $data1 = &getSubstring($record, $i, 2); $data2 = &getSubstring($record, $i+2, 6); $data3 = &getSubstring($record, $i+8, 7); $data4 = &getSubstring($record, $i+15, 2); $data1 = $Trademark::lib::seriesCode{$data1} || ""; $hashData{'apnr'} .= "NULLData\n"; } } $hashData{'apnr'} .= "\n"; return %hashData; } # Sub to parse APPH blocks sub parseAPPH { my($record, %hashData) = @_; my($this, $data1, $data2, $data3, $data4, $data5, $i, $data6, $data7); $hashData{'apph'} .= "\n"; # Start extracting data for($i=32; $i<320; $i+=23) { if(length($record) >= $i+23) { $data1 = &getSubstring($record, $i, 3); $data2 = &getSubstring($record, $i+3, 3); $data3 = &getSubstring($record, $i+6, 1); $data4 = &getSubstring($record, $i+7, 8); $data5 = &getSubstring($record, $i+15, 8); $data6 = $Trademark::lib::entryCodes{$data1} || ""; $data7 = $Trademark::lib::apphEntryType{$data3} || ""; $hashData{'apph'} .= "\n"; $hashData{'apph'} .= &getDateXML('due.date', $data4); $hashData{'apph'} .= &getDateXML('entry.date', $data5); $hashData{'apph'} .= "\n"; } } $hashData{'apph'} .= "\n"; return %hashData; } # Sub to parse TTAX blocks sub parseTTAX { my($record, %hashData) = @_; my($data1, $data2, $data3, $i, $seq); # Start extracting data $hashData{'ttax'} .= "\n"; for($i=32;$i<282;$i+=50) { $data1 = &getSubstring($record, $i, 2); if($data1 eq 'MK') { $data1 = "Mark"; } elsif($data1 eq 'PH') { $data1 = "Free form text prosecution history"; } $data2 = &getSubstring($record, $i+2, 3); $seq = &getSubstring($record, $i+6, 4); $data3 = &getSubstring($record, $i+10, 40); $data3 = trim($data3); $data3 = &IW::Skulker::encodeData(text => $data3); if($seq eq '0001') { if($data1 eq 'Mark') { $hashData{'ttax'} =~ s/$data3\n"; } else { if($data1 eq 'Mark') { $hashData{'ttax'} =~ s/()(.*)<\/ttax.data.group>/$1$2$data3<\/ttax.data.group>/gsi; } elsif($data1 eq 'Free form text prosecution history') { $hashData{'ttax'} =~ s/()(.*)<\/ttax.data.group>/$1$2$data3<\/ttax.data.group>/gsi; } } } $hashData{'ttax'} .= "\n"; return %hashData; } # Sub to put stuff together sub toXML { my(%hashData) = @_; my($XML) = ""; if($hashData{'fileSegment'} eq 'TRMK') { $XML .= $hashData{'genx'}; $hashData{'genv'} =~ s/\n<\/record.genv>//gsi; $hashData{'genv'} =~ s/ >/>/g; $XML .= $hashData{'genv'} || ""; $XML .= $hashData{'prus'} || ""; $XML .= $hashData{'frgn'} || ""; $XML .= $hashData{'clas'} || ""; %hashData = &getOwnrXML(%hashData); $XML .= $hashData{'ownr'} || ""; $hashData{'ownx'} =~ s/\n<\/record.ownx>//gsi; $XML .= $hashData{'ownx'} || ""; $XML .= $hashData{'dsgn'} || ""; } elsif($hashData{'fileSegment'} eq 'TSGN') { $XML .= $hashData{'deed'}; $hashData{'deex'} =~ s/\n<\/record.deex>//gsi; $XML .= $hashData{'deex'}; %hashData = &getAsgnXML(%hashData); $XML .= $hashData{'asgn'}; $XML .= $hashData{'prop'}; } elsif($hashData{'fileSegment'} eq 'TKAB') { $XML .= $hashData{'ttab'}; %hashData = &getPartXML(%hashData); $XML .= $hashData{'part'}; $XML .= $hashData{'parc'}; $XML .= $hashData{'apnr'}; $XML .= $hashData{'apph'}; $hashData{'ttax'} =~ s/< / $dir, mode => 0777); # Write file $fileName = $dir . $fileName; open(OUT, ">$fileName") || warn "Error writing $fileName: $!\n"; print OUT $XMLout; close OUT; return $fileName; } # Main # Global variable $Trademark::tm2xml::overflow = ""; my($file, $record); my($keySeq, $recordType); my($XMLout, $funcName, $dataFile); my(%hashData); my($first) = 1; $XMLout = ""; $dataFile = ""; my($fileName); # default input from STDIN unless (@ARGV) { push(@ARGV, "<&STDIN"); } foreach $file(@ARGV) { # Open the file open(FILE, $file); # Start parsing out the file while() { $record = $_; # First encode record # Get Key sequence $keySeq = substr($record, 4, 6); # Check to see if this is a new record if($keySeq eq '000001' && $first == 0) { $XMLout = &XMLHeader(%hashData); $XMLout .= &toXML(%hashData); $XMLout .= &XMLTrailer(%hashData); if($hashData{'blockName'} =~ /\w+/) { if($opt{'f'}) { $fileName = &toFile($hashData{'blockName'}, $XMLout); print $fileName, "\n"; } &IW::Parse::getDataFile($XMLout, $mapperFile, $hashData{'blockName'}); } $XMLout = ""; %hashData = (); } # Get record type $recordType = substr($record, 12, 4); # Get the function name to call $funcName = $Trademark::lib::recordFunc{$recordType} || ""; if($funcName =~ /\w+/) { %hashData = &$funcName($record, %hashData); } else { print STDERR "Invalid Record Type : $recordType\n"; } $first = 0; } if($opt{'f'}) { &IW::Parse::writeLastFile(); } close(FILE); } =head1 NAME tm2xml - Trademark Skulker =head1 PACKAGE Trademark::tm2xml =head1 REQUIRED Perl, version 5.001 or higher =head1 DESCRIPTION Trademark skulking routines. Takes in trademark raw data file names as command line input, skulks the data and writes the output XML into the block server. =over 3 =item usage: tm2xml Example: tm2xml VOL1C28133.data =head1 METHODS =head2 getBlockName =item * Accepts the trademark hash as parameter and returns the block name. Block Name format: =item * Mark Data - doc.us.mark.TRMK.{series code}.{first 3 char ser-num}.{last 3 char sernum} =item * Assignment Data - doc.us.mark.TSGN.{reel number}.{frame number} =item * Adversary Proceeding Data - doc.us.mark.TKAB.{proceeding type}.{first 3 char ser-num}.{last 3 char ser-num} =item example: $hashData{'blockName'} = &Trademark::tm2xml::getBlockName(%hashData); =head2 XMLHeader =item * Accepts the trademark hash as parameter and returns the XML Header =item example: $XMLout = &Trademark::tm2xml::XMLHeader(%hashData); =head2 XMLTrailer =item * Accepts the trademark hash as parameter and returns the XML trailer =item example: $XMLout .= &Trademark::tm2xml::XMLTrailer(%hashData); =head2 trim =item * Accepts a string as parameter, trims it and returns it back. =item example: $data = &Trademark::tm2xml::trim($data); =head2 getDateXML =item * Accepts the tag name and a date string as parameters and returns a Date XML string in the format datestring =item example: $dateStr = &Trademark::tm2xml::getDateXML('issue.date', 19991215); =head2 getFlagXML =item * Accepts the tag name and a single character flag(T or F) as parameters and returns a Flag XML string if the flag is 'T'. The format of the XML string returned is NULLData. Returns null if flag is 'F'. =item example: $flagStr = &Trademark::tm2xml::getFlagXML('flag.supp.register', 'T'); =head2 getGenvXML =item * Accepts the tag, sequence, data of a GENV record and the trademark hash as parameters, modifies the 'genv' key of the hash and returns the hash. =item example: $hashData = &Trademark::tm2xml::getGenvXML($code, $seq, $text, %hashData); =head2 getOwnxXML =item * Accepts the tag, sequence, data of a OWNX record and the trademark hash as parameters, modifies the 'ownx' key of the hash and returns the hash. =item example: $hashData = &Trademark::tm2xml::getOwnxXML($code, $seq, $text, %hashData); =head2 getClasDesc =item * Accepts class type and class code as parameters and returns the class description. This is with respect to the CLAS record. =item example: $classDesc = &Trademark::tm2xml::getClasDesc($code, $type); =head2 getPostalXML =item * Accepts address line1, address line2, city, region and zip code as parameters and returns a postal XML string in the format: =item * =item * ... =item * ... =item * ... =item * ... =item * ... =item * =item example: $postalXML = &Trademark::tm2xml::getPostalXML($street1, $street2, $city, $region, $code); =head2 getNameXML =item * Accepts the tag name and the value as parameters and returns a Name XML string in the format full name =item example: $nameXML = &Trademark::tm2xml::getNameXML('owner.name', $value); =head2 getCorrAddressXML =item * Accepts a correspondence address string, parses it and returns an XML string in the format: =item * =item * full name =item * =item * ... =item * ... =item * ... =item * ... =item * ... =item * =item example: $corrXML = &Trademark::tm2xml::getCorrAddressXML($corrAddress); =head2 getOwnrXML =item * Accepts the trademark hash as parameter, converts data from OWNR record into XML, puts it back in the hash and returns the hash. =item example: %hashData = &Trademark::tm2xml::getOwnrXML(%hashData); =head2 getAsgnXML =item * Accepts the trademark hash as parameter, converts data from ASGN record into XML, puts it back in the hash and returns the hash. =item example: %hashData = &Trademark::tm2xml::getAsgnXML(%hashData); =head2 getPartXML =item * Accepts the trademark hash as parameter, converts data from PART record into XML, puts it back in the hash and returns the hash. =item example: %hashData = &Trademark::tm2xml::getPartXML(%hashData); =head2 parseGENX =item * Accepts a GENX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseGENX($record, %hashData); =head2 parseGENV =item * Accepts a GENV record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseGENV($record, %hashData); =head2 parsePRUS =item * Accepts a PRUS record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parsePRUS($record, %hashData); =head2 parseFRGN =item * Accepts a FRGN record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseFRGN($record, %hashData); =head2 parseCLAS =item * Accepts a CLAS record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseCLAS($record, %hashData); =head2 parseOWNR =item * Accepts a OWNR record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseOWNR($record, %hashData); =head2 parseOWNX =item * Accepts a OWNX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseOWNX($record, %hashData); =head2 parseDSGN =item * Accepts a DSGN record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseDSGN($record, %hashData); =head2 parseDEED =item * Accepts a DEED record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseDEED($record, %hashData); =head2 parseDEEX =item * Accepts a DEEX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseDEEX($record, %hashData); =head2 parseASGN =item * Accepts a ASGN record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseASGN($record, %hashData); =head2 parseASGX =item * Accepts a ASGX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseASGX($record, %hashData); =head2 parsePROP =item * Accepts a PROP record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parsePROP($record, %hashData); =head2 parseTTAB =item * Accepts a TTAB record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseTTAB($record, %hashData); =head2 parsePART =item * Accepts a PART record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parsePART($record, %hashData); =head2 parsePARX =item * Accepts a PARX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parsePARX($record, %hashData); =head2 parsePARC =item * Accepts a PARC record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parsePARC($record, %hashData); =head2 parseAPNR =item * Accepts a APNR record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseAPNR($record, %hashData); =head2 parseAPPH =item * Accepts a APPH record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseAPPH($record, %hashData); =head2 parseTTAX =item * Accepts a TTAX record and the trademark hash as parameters, parses the record, stores the parsed XML in the hash and returns the hash =item example: %hashData = &Trademark::tm2xml::parseTTAX($record, %hashData); =head2 toXML =item * Accepts the trademark hash as parameter, combines all the records and returns the XML string =item example: $XML = &Trademark::tm2xml::toXML(%hashData); =head2 toFile =item * Accepts the trademark block name and the XML string as parameters and writes the block into the block server. =item example: &toFile($block, $XMLout); =back =head1 COPYRIGHT Copyright 2000 Invisible Worlds =head1 AUTHOR Trademark::tm2xml was written by Gautam Yegnanarayan . =cut