One of the things I really like about our bits is the fact that I can build little "libraries" by example.
In this case I wanted to create an RSS Reader, a library we should have but do not yet have. We can use our existing capabilities, however, to build one quite easily that we can use elsewhere.
For this particular example I will use the current cloud bits. These bits do not have the complete facelift that we are doing for the overall Data Explorer user model and interface so I am still calling this a Montego post. It will be awesome when we have the whole Data Explorer user model implemented and people can start using it... some of these posts may make more sense then :) ... for now I hope they give folks a little bit of a teaser as to what we have done so far and what they will be able to do when they get their hands on the bits.
In order to build an RSS reader I started by pointing Montego at an existing RSS fead, in this case a feed on goal.com. I did this by creating a new Montego mashup and using the Web Contents data source with the URL of the RSS feed:
From this I get a basic preview that indicates we got something back. In the toolbar the XML icon is active which means that I can turn this into XML:
Pressing the XML button adds a new task that allows me to preview and interact with the XML:
In the above image I can see the top level values and attributes. I want the Values so I right-click on the Values table and choose use as next Task:
At this point I see a preview of the rows of values. From this I decided that I just want the "items" so I choose the Filter Rows action from the toolbar that gives me the builder below to configure my filter. By time folks get the Data Explorer labs bits you will be able to right click on the column and value (cell) you want to filter on instead of having to use the full builder:
After filtering for just the items we still have a nested structure. What I really want to do is lift the values that I care about (title, description and link) from the rows of items. I can do that by adding custom columns that project up the fields I care about. First I project up the title. To do this one can use the Insert Custom Column action:
Then I use the builder to configure what I want inserted:
In this case, I had looked at the contents of the Item structure and I knew that in each Item the title was the second row and I needed the value cell from that row.
The next thing I wanted to pull out was the description field. It was basically the same steps as the Title so rather than use the builder it was quicker to edit this in the formula bar. I added another custom column but then collapsed the builder and pasted in the previous formula. I had to tweak a couple of the arguments in the formula:
The Table.AddColumn formula takes the following argument:
1: The table that you want to add a column to
2: The name of the new column
3: The expression you want to use to populate each cell in the new column
In this case I wanted to reference the table that was the output of the previous task which was named InsertedCustom, I wanted the name of the new Column to be Description and instead of the second row I wanted the 5th row (it says 4 because we are zero based).
I then wanted to do the same thing for the Link field so I added another custom column and did the same changes to the formula in the formula bar:
At this point I have all the fields I care about Title, Description, Link... I could have added more if I wanted. Now I want to hide all the extra columns so I use the Hide Column action from the toolbar to hide the columns that I dont want:
Here one can select the columns to hide (again, in the labs release of Data Explorer you will be able to just right-click on the columns that you want to hide rather than using the builder as I am here). The final shape with the hidden columns gone looks like:
So at this point we have a resource that pulls data from an RSS feed and projects the result as a table that we can mash up with other data. The real goal was to make a general RSS Reader function, in order to do this I want to introduce folks to the "Formulas View". All of the demos and posts thus far have been talking about the surface UX. Under the covers we have a document format that is what one is actually building up when adding tasks and resources. You can see the formulas by right-clicking on the section header (bottom of the UX) and choosing view formulas:
When one does this you get the text representation of the mashup:
If you look at the above, the Resource we were working with was called WwwGoalCom (the default name that was created by pointing at the goal.com rss feed). All of the formulas you would see if you selected each task that we did are enumerated there for the resource.
In order to generalize this we want to edit this resource and turn it into a function:
I have highlighted the changes I made in yellow:
#1: I removed the "shared" keyword. That means that the function is only usable to the current document (this will become more interesting later on)
#2: I added a parameter (url) and changed the name of the function to ReadRss ... ReadRss = (url)
#3: I changed the first line to be RssContent and then in the second line to reference that accordingly ... makes more sense for someone reading the function instead of the argument being WwwGoalCom
We now have a new Function that we can leverage. In order to illustrate how to consume it I will add a new Resource but instead of pointing at a new data source I will choose "Formula" which means I will manually write in the formula I want:
From this I get a new resource where I can reference the function that we wrote. I can just say = [expression], in this case I want to say = [Function(args)]. Here is what the result looks like:
At this point we have a function that we can use in this mashup document. Recall that we did not make this function shared. We can make the function shared by just toggling the little eye next to the resource:
The effect of this is the same as just adding back the "shared" keyword to the formula by hand. Looking at the formulas we see that it was indeed added back:
At this point we should try this out from a new mashup document. In this case I saved this document then created a new document. The first thing I did was use the Import.Document function to reference the Document with the ReadRss function:
Notice that I get a preview of the shared resources in the other document (in this case the ReadRss function. Notice, also, that it shows that it is a function).
I can reference the function and it will show me the signature:
I can now use it just as I did before to get the results of the RSS feed:
So now we have a Function that we can use from our other Mashup documents to pull in RSS feeds. I could have made the function much more robust by dereferencing rows by a given value (like Name=title) instead of position but the purpose here was just to show how you can use the experience to access something then generalize it so that you can use it elsewhere.
I'm dying to find out what is the technology of this "Cloud" part of DataExplorer .. is it WPF/Silverlight or HTML5
It seriously looks like Silverlight, which I really hope it is because that would mean it can easily port to Win8 Metro when the time comes (assuming it makes sense to).