#!/usr/bin/perl -w use SOAP::Lite; use XML::Simple; use Mac::AppleScript qw(RunAppleScript); # set up the web service connection and retrieve the XML my $service = SOAP::Lite -> service('http://localhost:55555/cgi-bin/WebObjects/WeatherHub.woa/ws/XML?wsdl'); my $weatherXml = $service->buildCompleteXml(); # Change special character back into their proper forms. # The character substitutions were made by WebObjects because this XML # was imbedded in another XML during transit. $weatherXml =~ s/"/"/g; $weatherXml =~ s/>/>/g; $weatherXml =~ s/</ ['id']); # There is great documentation for XML::Simple at # http://homepages.paradise.net.nz/gmclean1/cpan/ # Open the file to use as our data file my $outfile = "/tmp/weatherOut.txt"; open(OUT, ">$outfile"); # This first line is required by Bee Docs' Timeline print OUT "Label\tStart Time\tEnd Time\n"; # make a line for each data item from the data structure we # created based on the XML foreach my $itemId (keys %{$config->{data}->{item}}) { my $thisItem = $config->{data}->{item}->{$itemId}; my $typeId = $thisItem->{typeId}; print OUT $config->{measureTypes}->{type}->{$typeId}->{name} . ": "; print OUT $thisItem->{data} . "\t"; print OUT $thisItem->{time} . "\t\n"; } close(OUT); # Use Applescript to open the tab delimited data file # in Bee Docs' Timeline and set the colors and fonts. my $script = qq(tell application "Timeline" activate open POSIX file "$outfile" tell first document set font name to "HelveticaNeue-Bold" set font size to "12.0" set background color to {28583, 35517, 42334} set the returned_events to every event repeat with i from 1 to the count of the returned_events set thisLabel to label of event i if thisLabel starts with "Temp" then set event color of event i to {65535, 65535, 65535} set label of event i to thisLabel & "¡ F" else set event color of event i to {1758, 8435, 15546} end if end repeat end tell end tell); my $result = RunAppleScript( $script ) || die "Couldn't run script: $script";