Example 5 |
Top Previous Next |
This filter script is designed to work with the National Weather service's XML content, which is generated by polling their web API.
<Debug> <Console> <Active>True</Active> </Console> <File> <Active>True</Active> <Name>weatherfilter.txt</Name> <Append>False</Append> </File> <LogInputFile>True</LogInputFile> <LogOutputFile>True</LogOutputFile> </Debug>
<Filter> <Comment>Delete if no severe weather alerts</Comment> <Search> <Type>Literal</Type> <Variable>All</Variable> <Text><title>There are no active watches, warnings or advisories</title></Text> </Search> <MatchFound> <Replace> <Type>Literal</Type> <Variable>All</Variable> <Scope>Entire</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Check to see if this is the raw weather data or the ascii formatted data. If the latter, skip to Process.</Comment> <Search> <Type>Literal</Type> <Variable>Sender</Variable> <Text>WeatherSend</Text> </Search> <MatchFound> <Goto>Process</Goto> </MatchFound> </Filter>
<Filter> <Comment>Turn each entry block in to a separate file.</Comment> <FilterName>EntryLoop</FilterName> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text>(?s)(<entry>.*?<\/entry>)</Text> </Search> <MatchFound> <Replace> <Variable>Temp8</Variable> <Scope>Entire</Scope> <Text>YourRecipientOrGroup\013\010WeatherSend\013\010%Group1%</Text> </Replace> <WriteFile> <Variable>Temp8</Variable> <Name>INSERT THE PATH TO YOUR WEATHER FOLDER\posts\%InputFileNameBase%-%FilterIndex%.asc</Name> </WriteFile> </MatchFound> <MatchNotFound> <Replace> <Variable>All</Variable> <Scope>Entire</Scope> <Text></Text> </Replace> <Goto>Finished</Goto> </MatchNotFound> </Filter>
<Filter> <Comment>Get rid of the entry block processed, then loop back until there are no more entry blocks</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text>(?s)<entry>.*?<\/entry></Text> </Search> <MatchFound> <Replace> <Variable>All</Variable> <Scope>Match</Scope> <Text></Text> </Replace> <Goto>EntryLoop</Goto> </MatchFound> <MatchNotFound> <Goto>Finished</Goto> </MatchNotFound> </Filter>
<Filter> <FilterName>Process</FilterName> <Comment>Grab cap:effective and put it in Temp4</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><cap:effective>(.*)?<\/cap:effective></Text> </Search> <MatchFound> <Replace> <Variable>Temp4</Variable> <Scope>Entire</Scope> <Text>%Group1%</Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Grab cap:expires and put it in Temp5, then put the final ID in Temp6</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><cap:expires>(.*)?<\/cap:expires></Text> </Search> <MatchFound> <Replace> <Variable>Temp5</Variable> <Scope>Entire</Scope> <Text>%Group1%</Text> </Replace> <Replace> <Variable>Temp6</Variable> <Scope>Entire</Scope> <Text>%Temp4%%Temp5%</Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment> Turn Temp6 in to a valid file name and put it in Temp7. It will be used to read/write the requestId files</Comment> <Search> <Type>RegEx</Type> <Variable>Temp6</Variable> <Text>[^a-zA-Z0-9\-]</Text> </Search> <MatchFound> <Replace> <Type>RegEx</Type> <Variable>Temp7</Variable> <Scope>Entire</Scope> <Text>%Group1%</Text> <ReplaceAll>True</ReplaceAll> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Pull in the ID from the file</Comment> <MatchNotFound> <ReadFile> <Variable>Temp9</Variable> <Name>INSERT THE PATH TO YOUR WEATHER FOLDER\ids\%Temp7%.asc</Name> </ReadFile> </MatchNotFound> </Filter>
<Filter> <Comment>Check to see if the ID already exists. If it does, delete everything. If it doesn't, write the ID file</Comment> <Search> <Type>Literal</Type> <Variable>Temp9</Variable> <Text>%Temp7%</Text> </Search> <MatchFound> <Replace> <Variable>All</Variable> <Scope>Entire</Scope> <Text></Text> </Replace> <Goto>Finished</Goto> </MatchFound> <MatchNotFound> <WriteFile> <Variable>Temp7</Variable> <Name>INSERT THE PATH TO YOUR WEATHER FOLDER\ids\%Temp7%.asc</Name> </WriteFile> </MatchNotFound> </Filter>
<Filter> <Comment>Remove from cap:event to cap:certainty</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text>(?s)<cap:event>.*?<\/cap:certainty></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <ReplaceAll>True</ReplaceAll> <Variable>All</Variable> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove from entry to author</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text>(?s)<entry>.*?<\/author></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <ReplaceAll>True</ReplaceAll> <Variable>All</Variable> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Replace cap:areaDesc with LOCATION</Comment> <Search> <Type>Literal</Type> <Variable>All</Variable> <Text><cap:areaDesc></Text> </Search> <MatchFound> <Replace> <ReplaceAll>True</ReplaceAll> <Variable>All</Variable> <Scope>Match</Scope> <Text>\013\010LOCATION:\032</Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove the XML tags from the link</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><link href="(.*)"\/></Text> </Search> <MatchFound> <Replace> <Variable>All</Variable> <Scope>Match</Scope> <Text>%Group1%</Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove from cap:polygon to cap:entry</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text>(?s)<cap:polygon>.*?<\/entry></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <ReplaceAll>True</ReplaceAll> <Variable>All</Variable> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove the summary</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><summary>.*<\/summary></Text> </Search> <MatchFound> <Replace> <Variable>All</Variable> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove the opening title tag</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><title></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <Variable>All</Variable> <ReplaceAll>True</ReplaceAll> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter> <Filter> <Comment>Remove the closing title tag</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><\/title></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <Variable>All</Variable> <ReplaceAll>True</ReplaceAll> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Remove the closing cap:areaDesc tag</Comment> <Search> <Type>Regex</Type> <Variable>All</Variable> <Text><\/cap:areaDesc></Text> </Search> <MatchFound> <Replace> <Type>Regex</Type> <Variable>All</Variable> <ReplaceAll>True</ReplaceAll> <Scope>Match</Scope> <Text></Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Clean up the text, part 1</Comment> <Search> <Type>Literal</Type> <Variable>All</Variable> <Text>\013\010\013\010</Text> </Search> <MatchFound> <Replace> <ReplaceAll>True</ReplaceAll> <Variable>All</Variable> <Scope>Match</Scope> <Text>\013\010</Text> </Replace> </MatchFound> </Filter>
<Filter> <Comment>Processing completed</Comment> <FilterName>Finished</FilterName> <MatchNotFound> </MatchNotFound> </Filter> |