<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ladysign Dev Blog &#187; yql</title>
	<atom:link href="http://www.ladysign-apps.com/blog/tag/yql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ladysign-apps.com/blog</link>
	<description>Girls can code.</description>
	<lastBuildDate>Mon, 12 Dec 2011 16:58:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mash-ups with YQL</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 11:00:32 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[YUI Library]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[corizon]]></category>
		<category><![CDATA[mash-ups]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=923</guid>
		<description><![CDATA[<h5>&#8230;and why Corizon mashups suck.</h5>
<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
It was because of working with Corizon that I became more interested in creating Mas[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<h5>&#8230;and why Corizon mashups suck.</h5>
<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
It was because of working with Corizon that I became more interested in creating Mash-ups*.<br />
During the last 2 years, I&#8217;ve seen a lot of mash-up tools, From the easy (&#8221;Lego-like&#8221;) Popfly from Microsoft which is recently discontinued, to large handy API&#8217;s or serverside Java frameworks; such as the nice but heavy <a title="SiteMesh" href="http://www.opensymphony.com/sitemesh/" id="i2v4">SiteMesh</a> framework.<br />
But it was the <a href="http://www.corizon.com/">Corizon mash-up</a> toolkit that I started to realize, coding mash-ups can have it&#8217;s ups and downs.</p>
<p>In my opinion creating a mash-up should be easy &amp; fast. Not buggy and heavy (running 2 or 3 Tomcat servers in the background *kuch*). Also it&#8217;s an unwritten rule that for a mash-up you should not first destroy and rebuild it&#8217;s components before you gonna mix them up. This means you can only mash-up content what&#8217;s in your maintenance and when one of your components changes, your mash-up is broken.<br />
It&#8217;s not a wonder that I became extremely positive about YQL, when I first saw this working.<br />
And now, after <a href="http://www.fronteers.nl">Fronteers 2009</a>, where I had a presentation and talk with <a href="http://icant.co.uk">Chris Heilmann</a> from Yahoo.</p>
<p>With YQL (Yahoo Query Language), you can make the same mash-ups, client or serverside and you don&#8217;t need thousands lines of code.<br />
<b>Why you should use YQL for a mash-up?</b></p>
<ul>
<li>You won’t use your own bandwidth, but the bandwidth from Yahoo.</li>
<li>It’s easy, just the basic SQL knowledge is required.</li>
<li>It’s lightweight.</li>
<li>It’s fast.</li>
</ul>
<p>But like every Mashup tool, there are also downside&#8217;s. So it&#8217;s good to consider:</p>
<p><b>Why you shouldn&#8217;t use YQL for a mash-up?</b></p>
<ul>
<li>When one of the including components is slow or has timeouts, you result object will be <strong>null</strong>.</li>
</ul>
<h5>Mash-ups with YQL</h5>
<p>Ok enough with the theory. Let&#8217;s practice with a simple YQL mash-up. As you might know, I like videogames. So I want to have a website with the release dates of games on my website, which I can watch on YouTube. Fokzine Games (<a href="http://games.fok.nl/overzicht.php?action=release">http://games.fok.nl/overzicht.php?action=release</a>) has a nice game release list.</p>
<ul>
<li>For using this tutorial, you will need a Yahoo Developer Account, which you can create for free. </li>
<li>Unless you like to write full XPath lines without any help,<br />
you’ll also need <a title="Mozilla Firefox" href="http://www.mozilla-europe.org/nl/firefox/" id="me3x">Mozilla Firefox</a> browser with the <a title="Firebug" href="https://addons.mozilla.org/en-US/firefox/addon/1843" id="f_1b">Firebug</a> plugin installed.</li>
</ul>
<ol>
<li><b>Register your Yahoo Dev account.</b><br />
Go to the below URL, register your Yahoo account and login<br />
to the YQL console:&nbsp;<a href="http://developer.yahoo.com/yql/console/" target="_blank">http://developer.yahoo.com/yql</a>
</li>
<li><b>Query the content.</b><br />
YQL is quite similar to SQL. To query content (the videogame<br />
release list) from an external website, I will select all the HTML nodes from an URL. With Xpath I can point to the part of the website I will need. (Now you’ll need Firebug, inspect the website, till you’ll reach the table tag of the release list. – In top of your Firebug screen, you will see the full Xpath line.<br />
– Just right click, and “Copy Xpath”. This will be your YQL query for selecting the table tag on Fok.nl Game Release Page:</p>
<pre class="brush: sql; title: ;">
select * from html where url ='http://games.fok.nl/overzicht.php?action=release' and xpath ='//*[@id=&quot;itemtext&quot;]'
//or select the tr tag on Fok.nl Game Release page
//(note that I removed “tbody” from the xpath line to make it work)
select * from html where url ='http://games.fok.nl/overzicht.php?action=release' and xpath ='/html/body/div[4]/table/tr/td[2]/div[2]/div/table/tr'
</pre>
<p>Hit enter (or press “Test”) and you can switch between formatted view or tree view to see the result. Result can be in XML of JSON.<br />
Also note that you can copy the REST URL Query, from the console:<br />
<strong><br />
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%20%3D%20&#8242;http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease&#8217;%20and%20xpath%20%3D%20&#8242;%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr&#8217;&amp;format=xml<br />
</strong><br />
<img src="yql.jpg" alt="YQL Console" />
</li>
<li>
<b>How the retrieved XML looks like:</b></p>
<pre class="brush: xml; title: ;">&lt;query xmlns:yahoo=&quot;http://www.yahooapis.com/v1/base.rng&quot;yahoo:count=&quot;50&quot; yahoo:created=&quot;2009-09-25T12:14:12Z&quot;yahoo:lang=&quot;en-US&quot; yahoo:updated=&quot;2009-09-25T12:14:12Z&quot;
yahoo:uri=&quot;http://query.yahooapis.com/v1/yql?q=select+*+from+html+where+url+%3D+%27http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease%27+and+xpath+%3D+%27%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr%27&quot;&gt;
&lt;diagnostics&gt;
&lt;publiclyCallable&gt;true&lt;/publiclyCallable&gt;
&lt;url execution-time=&quot;263&quot; proxy=&quot;DEFAULT&quot;&gt;&lt;![CDATA[http://games.fok.nl/overzicht.php?action=release]]&gt;&lt;/url&gt;
&lt;user-time&gt;272&lt;/user-time&gt;
&lt;service-time&gt;263&lt;/service-time&gt;
&lt;build-version&gt;3130&lt;/build-version&gt;
&lt;/diagnostics&gt;
&lt;results&gt;
 &lt;tr bgcolor=&quot;#E0E0E0&quot;&gt;
  &lt;td&gt;
   &lt;img alt=&quot;PC&quot; src=&quot;http://images.fok.nl/ads/games/IB_PC.png&quot;/&gt;
  &lt;/td&gt;
  &lt;td&gt;
   &lt;p&gt;29-09-2009&lt;/p&gt;
  &lt;/td&gt;
  &lt;td&gt;
   &lt;a class=&quot;invisiblelink&quot; href=&quot;gameinfo.php?gameid=9985&quot;&gt;Tales of Monkey Island episode 3&lt;/a&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
  ..
&lt;/results&gt;
&lt;/query&gt;</pre>
<p><b>How your JSON (Javascript object looks like:</b></p>
<pre class="brush: jscript; title: ;">releaseList({
 &quot;query&quot;:{
 &quot;count&quot;:&quot;50&quot;,
 &quot;created&quot;:&quot;2009-09-25T12:10:17Z&quot;,
 &quot;lang&quot;:&quot;en-US&quot;,
 &quot;updated&quot;:&quot;2009-09-25T12:10:17Z&quot;,
 &quot;uri&quot;:&quot;http://query.yahooapis.com/v1/yql?q=select+*+from+html+where+url+%3D+%27http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease%27+and+xpath+%3D+%27%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr%27&quot;,
 &quot;diagnostics&quot;:{
  &quot;publiclyCallable&quot;:&quot;true&quot;,
  &quot;url&quot;:{
   &quot;execution-time&quot;:&quot;28&quot;,
   &quot;proxy&quot;:&quot;DEFAULT&quot;,
   &quot;content&quot;:&quot;http://games.fok.nl/overzicht.php?action=release&quot;
  },
 &quot;user-time&quot;:&quot;36&quot;,
 &quot;service-time&quot;:&quot;28&quot;,
 &quot;build-version&quot;:&quot;3130&quot;
 },
&quot;results&quot;:{
 &quot;tr&quot;:[{
 &quot;bgcolor&quot;:&quot;#E0E0E0&quot;,
 &quot;td&quot;:[.. ]
 }
..
 ]
}}});</pre>
</li>
<li><b>Use the YQL widget.</b><br />
Create a new HTML page. In this page, you&#8217;ll include the YQL JS Widget:<br />
<a href="http://github.com/sh1mmer/dotnet-yql-tutorial/blob/master/yql_js_widget.js" target="_blank">http://github.com/sh1mmer/dotnet-yql-tutorial/blob/master/yql_js_widget.js</a><br />
This is a pre-made Javascript widget. If you check out the links on the end of this article, you can check out other implementations as well. (Such as Dojo-YQL or JQuery YQL).<br />
For this article, we will use vanilla Javascript.</li>
<li><b>Create the Mash-up.</b><br />
The only think what you&#8217;ll need now is the logic to implement the previous made YQL query, to have the YQL results in your Document Object Model (DOM).<br />
With the Firebug plug-in, you can check the &#8220;Net&#8221; tab, to see if the correct object is retrieved. You can walk through the results, and implement it in your Javascript to do fancy things with it.</li>
<pre class="brush: xml; title: ;">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;YQL - Game Release&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;yql-js-widget.js&quot; &gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var config = {};
var format = '&lt;li class=&quot;{td[0].img.alt}&quot;&gt;{td[1].p} - &lt;a href=&quot;http://games.fok.nl/{td[2].a.href}&quot; target=&quot;_blank&quot;&gt;{td[2].a.content}&lt;/a&gt; - &lt;a href=&quot;http://www.youtube.com/results?search_query={td[2].a.content}&quot; target=&quot;_blank&quot;&gt;Watch on YouTube&lt;/a&gt;&lt;/li&gt;';
var gameQuery = &quot;select * from html where url = 'http://games.fok.nl/overzicht.php?action=release' and xpath = '/html/body/div[4]/table/tr/td[2]/div[2]/div/table/tr'&quot;;
yqlWidget.push(gameQuery, config, format, &quot;widgetContainer&quot;);
yqlWidget.render();
&lt;/script&gt;&lt;ul id=&quot;widgetContainer&quot;&gt;&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Well that&#8217;s it. See how easy it is to create a nice Mash-up? As long as you can reach the DOM, you can mash-up everything. Below my article, I&#8217;ve written some nice links. If you liked my article or you would like to discuss with me about YQL or Mash-up technologies; feel free to add me on <a title="LinkedIn" href="http://www.linkedin.com/in/leeboonstra" id="a93_">LinkedIn</a> or <a title="Twitter" href="http://twitter.com/ladysign" id="e:f5">Twitter</a>.</p>
<ul>
<li>YQL Community:<a href="http://github.com/yql/" target="_blank"> http://github.com/yql/</a></li>
<li>YQL video by Jonathan LeBlanc: <a href="http://developer.yahoo.com/yui/theater/video.php?v=leblanc-yql" target="_blank">http://developer.yahoo.com/yui/theater/video.php?v=leblanc-yql</a></li>
</ul>
<h6>* In webdevelopment, a mashup is a web page or application that combines<br />
data or functionality from two or more external sources to create a new<br />
service. An example of a Mash-up is a Google Map combined with Wikipedia<br />
town information and a (accuweather.com) Weather indicator.</h6>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

