Feed operators for Assemble Flow

Project Zero provides a collection of activities that are immediately available for manipulation of Feed.

The following sections of this article provide information about these activities that are built in to Assemble Flow:

feed

"feed" is a generic activity for fetching feed against the url given by the attribute "url". It can understand the RSS, ATOM, RDF format. If the url specified in the attribute "url" is an invalid one or fetching feed times out, an empty feed will be created. It has no input and returns an Atom1.0 feed.
<feed name="NCName" url="url" outputVarialbe="NCName"?>
  control*
</feed>

Notes:

  • url: an HTTP URL or relative-url to do the fetch feed against.
  • outputVariable: the optional variable into which a copy of the content of feed fetched is saved.

Sample:Fetch a CNN topstory feed.

<feed name="feed" url="http://rss.cnn.com/rss/cnn_topstories.rss" />

sortFeed

"sortFeed " is a generic activity to sort the entries of a feed by any entry element, such as the title or the updated of the entry.The sorting order can be ascending or descending. It has one input and returns an Atom1.0 feed.
<sortFeed name="NCName" orderBy ="CONDITION" outputVarialbe="NCName"?/>
   input
   control*
</sortFeed>
notes:
  • orderBy: required attribute to designate the sort rule, use ";" to separate different rules . Example:orderBy="+title;-updated", it means sorting a feed in title ascending and updated descending order.

Sample: Sort feed in an ascending order by the value of the "title" in each feed.

<sortFeed name="sort" orderBy="+title">
     <input value="${aggregate}"/>
</sortFeed>

aggregateFeeds

"aggregateFeeds" is a generic activity to merge two or more feeds together into a new one. It can accept two or more inputs and return an Atom1.0 feed.
<AggregateFeeds name="NCName" outputVarialbe="NCName"?/>
     input+
    control*
</AggregateFeeds>

Sample: Aggregate top story feed and world feed from CNN into one new feed.

<aggregateFeeds name="aggregate">
   <input value="${topstoriesfeed}"/>
   <input value="${worldfeed}"/>
</aggregateFeeds>

filterFeed

"filterFeed" is a generic activity to choose some entries of the input feed on your demand. To do simple filtering, you can just specify the keywords and flow engine will do filtering against the title, content, and summary of entries and return the entries that contains any of the key words. If you want to do advance filtering, you can give the "condition" which should be a valid Boolean XPath1.0 expression. Also you can give these two, if so the condition designated by the keywords and the "condition" is AND. It has one input and returns an Atom1.0 feed.
<filterFeed name="NCName" keywords="StringList"? 
               condition="XPath1.0-expr"? outputVarialbe="NCName"?>
       input
      control*
</filterFeed>
Notes:
  • condition: it is an optional attribute to designate the filter condition. It should be a valid Boolean XPath1.0 expression. Example: contains(atom:titlec,'Famed').
  • keywords: it is an optional attribute to designate the key words that you want to use to do filtering, Multiple key words should be separated by ",". key words is ignore-case.
  • Either keywords or condition is required.

Sample: Filter a feed by the key words "bush,iraq".

<filterFeed name="feedfilter" keywords="bush, iraq">
       <input value="${sort}"/>
</filterFeed>

unique

"unique" is a generic activity to remove the entries that contain duplicate strings.You can decide which element of an entry to filter on, the duplicates are removed from the input feed. For example, the input feed has six entries with the same title, you can use 'unique' so only one of these items is included in the output feed. It has one input and returns an Atom1.0 feed.
<unique name="NCName" by="CONDITION " outputVariable="NCName">
     input
    control*
</unique>
Notes:
  • by: It is an optional attribute to designate the unique element, "atom:id" as its default value.

Sample: Unique a feed by the value of title of each entry.

<unique name="unique" by="atom:title">
     <input value="${feed}"/>   
</unique>

truncate

"truncate" is a generic activity to return a specific number of the entries from the top of the input feed. This activity allows you to limit the amount of the entries in the output feed. The amount of entries emitted is given by attribute “number”. It has one input and returns an Atom1.0 feed.
<truncate name="NCName" number="num">
        input
       control*
</truncate>
Notes:
  • number: An integer as a required attribute to designate how many entries you want to emit. If it is greater than the total number of the entries, then all entries would be emitted. Example: number="3".

Sample: retrieve the first three entries from the CNN top stories feed.

<truncate name="truncate" number="3">
   <input value="${cnn_topstories}" />
</truncate>

XPath

"XPath" is a generic activity to select a node list of the input feed. The xpath is specified by the attribute "select" which should be a valid XPath1.0 expression. It has one input and return a nodelist.
<XPath name="NCName" select="XPath1.0-expr">
         input
        control*
</XPath>
Notes:
  • select: required attribute to designate the xpath1.0 expression.

Sample: select the entries in a feed, return an entry list.

<XPath name="xpath" select="//atom:entry ">
        <input value="${feed}"/>
</XPath>

XSLT

"XSLT" is a generic activity to perform the XSLT transform. The transform rule is specified by the attribute ”url” which should be XSLT file url. It has at least one input.
<XSLT name="NCName" url="relative-url">
        <input value="Expression"/>
        <input name="variables" value="Map"/>
        <control/>*
</XSLT>
Notes:
  • url: it is a required attribute to designate the .xls file.
  • input: the input without "name" is the source that is to be transformed against. The other input is to designate the variables which will be used in .xls file.

Sample: Transform the MexicoStoreFeed to a new one by excuting the script in the "currency.xsl" file.

<XSLT name="GenerateTranslatedFeedOfMexicoStore" url="./currency.xsl">
    <input value="MexicoStoreFeed"/>
    <input name="variables" value="${[exchangeRate :0.088]}"/>
</XSLT>

-- yili - 18 Oct 2007

r3 - 22 Oct 2007 - 08:54:28 - yili
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site