Polycom PDS 2000 Car Stereo System User Manual


 
Polycom Digital Signage Administrator Guide Data Source Tutorial
188 Polycom, Inc.
Finally, let's extract the day part's weather image URL and download the
image file so that it's available on the local machine. The image URL is made
up of the web site address (http://www.erh.noaa.gov) concatenated with the
value of the HTML <img> element's src attribute. First, we extract the value of
the src attribute with a GetTag rule:
<ParsingRule type="GetTag" source="DaySource"
result="ImageURL">
<StartTag>img src=&quot;</StartTag>
<EndTag>&quot;</EndTag>
</ParsingRule>
Then we use a StrCat rule to prepend the web site's address to form the
complete URL:
<ParsingRule type="StrCat" result="ImageURL">
<String1>http://www.erh.noaa.gov</String1>
<String2>|ImageURL|</String2>
<AddSpace>False</AddSpace>
</ParsingRule>
StrCat's String1 and String2 parameters are taggable, so we use the special
|ImageURL| syntax to specify the contents of the ImageURL container as the
value for String2. These preceding two rules give us a full URL for the image
(e.g. http://www.erh.noaa.gov/images/wtf/tsra70.jpg).
We can now download the image file. First we obtain the image's file name
with a GetTag rule that extracts strings that lie between a "/" and ".jpg":
<ParsingRule type="GetTag" source="ImageURL"
result="LocalImage">
<StartTag>/</StartTag>
<EndTag>.jpg</EndTag>
</ParsingRule>
This extracts "tsra70" from the ImageURL container. This seems
counter-intuitive: Why didn't the GetTag rule instead extract
"/www.erh.noaa.gov/images/wtf/tsra70" (i.e. everything between the first
"/" and ",jpg")? The answer lies in how GetTag handles nested tags. GetTag
always returns the innermost instance. For example, if the source string were
"Mary had a <<li<<tt>>le>> lamb" and the StartTag were "<<" and the EndTag
were ">>", then GetTag would return "tt".
What this means in our case is that when GetTag notices that the StartTag ("/")
still shows up in the string following its first occurrence, GetTag will move
forward through the string until the StartTag no longer appears. Thus for
"http://www.erh.noaa.gov/images/wtf/tsra70.jpg" GetTag analyses the
following strings:
http://www.erh.noaa.gov/images/wtf/tsra70.jpg
/www.erh.noaa.gov/images/wtf/tsra70.jpg
/images/wtf/tsra70.jpg
/wtf/tsra70.jpg