<?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>YQL Blog</title>
	<atom:link href="http://yqlblog.net/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://yqlblog.net/blog</link>
	<description>Yahoo! Query Language</description>
	<lastBuildDate>Thu, 22 Jul 2010 17:19:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Changelog for build 8743</title>
		<link>http://yqlblog.net/blog/2010/07/22/changelog-for-build-8743/</link>
		<comments>http://yqlblog.net/blog/2010/07/22/changelog-for-build-8743/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 17:05:20 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=154</guid>
		<description><![CDATA[New Feature Highlights

Store recent queries using HTML5 container
Console y.ahoo.it url shortener integrated into the console when permalinking queries &#8211; now it’s easier to grab and share long console query

New core tables

Yahoo Mail API
Social Relationship API

Other features

y.cache.incr() should return the new value
geo.placetypes adds language support

Changes

Preserve newlines in console output

Bug fixes, including

Aliased input keys are not available [...]]]></description>
			<content:encoded><![CDATA[<p><strong>New Feature Highlights</strong></p>
<ul>
<li>Store recent queries using HTML5 container</li>
<li>Console y.ahoo.it url shortener integrated into the console when permalinking queries &#8211; now it’s easier to grab and share long console query</li>
</ul>
<p><strong>New core tables</strong></p>
<ul>
<li>Yahoo Mail API</li>
<li>Social Relationship API</li>
</ul>
<p><strong>Other features</strong></p>
<ul>
<li>y.cache.incr() should return the new value</li>
<li>geo.placetypes adds language support</li>
</ul>
<p><strong>Changes</strong></p>
<ul>
<li>Preserve newlines in console output</li>
</ul>
<p><strong>Bug fixes, including</strong></p>
<ul>
<li>Aliased input keys are not available as variables in &lt;execute&gt;</li>
<li>In console set publiclyCallable to false if a user is not logged in and runs a query with an auth required table</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2010/07/22/changelog-for-build-8743/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 8367</title>
		<link>http://yqlblog.net/blog/2010/06/16/changelog-for-build-8367/</link>
		<comments>http://yqlblog.net/blog/2010/06/16/changelog-for-build-8367/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 00:14:18 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=150</guid>
		<description><![CDATA[New Feature Highlights:


Allow an &#60;execute&#62; outside the execute blocks to add libraries, functions
y.rest().ping() add a way to beacon data to statistics gathering services



New core tables

Fantasy Sports API

Other features

Improve ability to throw exceptions from execute tables
Update tidy library to support HTML5
Add y.tidy(String html) to tidy the html and return a document

&#60;execute&#62; changes

Core HTTP changes to enable [...]]]></description>
			<content:encoded><![CDATA[<div><strong>New Feature Highlights:</strong></div>
<div>
<ul>
<li>Allow an &lt;execute&gt; outside the execute blocks to add libraries, functions</li>
<li>y.rest().ping() add a way to beacon data to statistics gathering services</li>
</ul>
</div>
<div>
<p><strong>New core tables</strong></p>
<ul>
<li>Fantasy Sports API</li>
</ul>
<p><strong>Other features</strong></p>
<ul>
<li>Improve ability to throw exceptions from execute tables</li>
<li>Update tidy library to support HTML5</li>
<li>Add y.tidy(String html) to tidy the html and return a document</li>
</ul>
<p><strong>&lt;execute&gt; changes</strong></p>
<ul>
<li>Core HTTP changes to enable better connection management and reuse</li>
</ul>
<p><strong><strong style="background-color: #ffffff;">Bug fixes, including:</strong></strong></p>
<ul>
<li>Fix Diagnostics service-time included y.query time</li>
<li>Fix Can&#8217;t &#8220;desc yql.env&#8221;</li>
<li>Fix Json array returned by a rest call results in an exception</li>
<li>Fix Debug output does not handle special characters</li>
<li>Fix paging with mode=&#8217;offset&#8217; is ignoring the start default attribute</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2010/06/16/changelog-for-build-8367/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 6122</title>
		<link>http://yqlblog.net/blog/2010/04/13/changelog-for-build-6122/</link>
		<comments>http://yqlblog.net/blog/2010/04/13/changelog-for-build-6122/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 19:02:37 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=143</guid>
		<description><![CDATA[New Feature Highlights:

new &#60;meta&#62; element in YQL response  envelope returns information &#8220;about&#8221; the result list
social.updates.search  table &#8211; access the social updates firehose
changes to environment feature and capabilities

new &#8220;env&#8221;  statement. You can now load envs using the &#8220;env&#8221; statement as part of  the regular YQL syntax.
&#8220;env&#8221;s may now be nested &#8211; you [...]]]></description>
			<content:encoded><![CDATA[<div><strong>New Feature Highlights:</strong></p>
<ul>
<li>new &lt;meta&gt; element in YQL response  envelope returns information &#8220;about&#8221; the result list</li>
<li>social.updates.search  table &#8211; access the social updates firehose</li>
<li>changes to environment feature and capabilities
<ul>
<li>new &#8220;env&#8221;  statement. You can now load envs using the &#8220;env&#8221; statement as part of  the regular YQL syntax.</li>
<li>&#8220;env&#8221;s may now be nested &#8211; you can  include one env from another</li>
<li>&#8220;sets&#8221; on one environment do NOT apply to any other, unless the environment is nested</li>
</ul>
</li>
</ul>
<p><strong>New core tables</strong></p>
<ul>
<li>social.updates.search</li>
<li>yql.table.desc, yql.table.list and yql.tables tables (reflect  on the available YQL tables)</li>
</ul>
<p><strong>Other features</strong></p>
<ul>
<li>show tables now reports the security required to use the table</li>
<li>desc &lt;table&gt; now works for all tables irrespective of security  or connection restrictions (https) on tables</li>
</ul>
<p><strong>&lt;execute&gt; changes</strong></p>
<ul>
<li>added response.meta to enable &lt;meta&gt; element to be set on the response object</li>
<li>added forceCharset(String charset) to request/y.rest(..) as a way of   overriding the return contentType charset.</li>
</ul>
<p><strong><strong style="background-color: #ffffff;">Bug fixes, including:</strong></strong></p>
<ul>
<li>fixed debug=true always reported the method as GET in network dump</li>
<li>including a store:// url in execute y.include intermittently caused  no results to be returned &#8211; fix</li>
<li>yahoo:uri is no longer in the response envelope</li>
<li>yahoo.identity fixed</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2010/04/13/changelog-for-build-6122/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 5275</title>
		<link>http://yqlblog.net/blog/2010/03/19/changelog-for-build-5275/</link>
		<comments>http://yqlblog.net/blog/2010/03/19/changelog-for-build-5275/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 21:01:01 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=136</guid>
		<description><![CDATA[New Core tables

yql.env, automatically apply environments per app or per user per app

Bug fixes, including:

&#8220;content&#8221; can be used to filter in WHERE clause
fixed charset parameter handling in HTML table (was broken in previous build)
another custom redirect fix (for SPARQL table)
update now supports &#8220;in&#8221; as where clause


]]></description>
			<content:encoded><![CDATA[<div><strong>New Core tables</strong></p>
<ul>
<li>yql.env, automatically apply environments per app or per user per app</li>
</ul>
<p><strong><strong style="background-color: #ffffff;">Bug fixes, including:</strong></strong></p>
<ul>
<li>&#8220;content&#8221; can be used to filter in WHERE clause</li>
<li>fixed charset parameter handling in HTML table (was broken in previous build)</li>
<li>another custom redirect fix (for SPARQL table)</li>
<li>update now supports &#8220;in&#8221; as where clause</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2010/03/19/changelog-for-build-5275/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding rate limits and getting banned in YQL and Pipes: Caching is your friend</title>
		<link>http://yqlblog.net/blog/2010/03/12/avoiding-rate-limits-and-getting-banned-in-yql-and-pipes-caching-is-your-friend/</link>
		<comments>http://yqlblog.net/blog/2010/03/12/avoiding-rate-limits-and-getting-banned-in-yql-and-pipes-caching-is-your-friend/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 20:03:04 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=137</guid>
		<description><![CDATA[Web caches are great pieces of software: they lower the load on servers; and serve content faster to clients. YQL and Pipes love caches for this very reason, and we reward clients making good use of our reverse proxy caches by not subjecting those who get cached content to rate limits. That&#8217;s right &#8211; if [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Http_cache">Web caches</a> are great pieces of software: they lower the load on servers; and serve content faster to clients. <a href="http://developer.yahoo.com/yql">YQL</a> and <a href="http://pipes.yahoo.com">Pipes</a> love caches for this very reason, and we reward clients making good use of our reverse proxy caches by not subjecting those who get cached content to rate limits. That&#8217;s right &#8211; if we can give you your content from cache you can call it as often as you like, no need to cache locally just to save on calls.</p>
<p>Unfortunately we&#8217;ve seen a lot of requests to us that could easily take advantage of our caches but don&#8217;t. Here&#8217;s a list of some DOs and DONTs for calling YQL and Pipes, and let&#8217;s use the example of fetching the weather for a zipcode:</p>
<p><a href="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&amp;format=xml">http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where location=90210</a></p>
<p><strong>DON&#8217;T cachebust</strong><br />
&#8220;Cachebusting&#8221; means changing your request just a little so that the cache can&#8217;t give you a copy of the response it&#8217;s seen before, often using a random value or timestamp on the end of the query parameters, for example:</p>
<p><a href="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&amp;format=xml&amp;rnd=_12312">http://query.yahooapis.com/v1/public/yql?q=select  * from weather.forecast where location=90210&amp;rnd=_12312</a></p>
<p><strong>Beware of client-side JS libraries &#8220;helping&#8221; you</strong><br />
Often developers aren&#8217;t even aware they are doing this, but various web client libraries, particular client-side Javascript ones, seem to think cachebusting by default is a sensible thing to do. Its not. It just makes our servers work harder, the downstream sources of data work harder, and the response come back slower to the client. It also stops your own browser cache from helping your app behave faster.</p>
<p>For example, jQuery provides an automatic JSONP callback library that creates a randomly named global function name for each callback. This causes it to cachebust on every call as the function name changes all the time. By taking the time to add a few extra lines of code you can benefit from our caches:</p>
<pre>$.ajax({
   url: 'http://query.yahooapis.com/v1/public/yql?q=show%20tables&amp;format=json',
   dataType: 'jsonp',
   jsonp: 'callback',
   jsonpCallback: 'cbfunc'
});
function cbfunc(data){
   $.each(data.query.results.table, function(i,item){
   $('#tables').append('&lt;p&gt;'+item+'&lt;/p&gt;');
});
}</pre>
<p>By defining your own global function in your script you can be sure that it won&#8217;t change from request to request, and you can leverage our caches.</p>
<p><strong>If you must cachebust, use a &#8220;window&#8221; of time</strong><br />
Sometimes the content gets cached for longer than you want, and sometimes your clients are IE6 web browsers which don&#8217;t respect cache headers correctly [shudder]. The best solution to this is to append a parameter that changes gradually at the same rate as the content you are requesting. For example, back to our example of fetching the weather forecast for a zipcode. The forecast will probably change throughout the day, but not every single second, so you&#8217;re probably ok fetching that every hour and therefore can create a cachebusting header that uses a timestamp that only changes once per hour, for example:</p>
<p><a href="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&amp;format=xml&amp;rnd=_2010031310">http://query.yahooapis.com/v1/public/yql?q=select  * from weather.forecast where location=90210&amp;rnd=_2010031310</a></p>
<p>This uses a YYYYMMDDHH (year/month/day/hour) format for each request to fetch the weather. All requests arriving over the course of an hour will get a cache hit and you&#8217;ll use 1 unit of rate limit (per zipcode).</p>
<p><strong>DO put content into cache</strong><br />
On the flip side of caching busting, sometimes content isn&#8217;t cached as long as it should be, or you want it do be. Perhaps the content provider set it wrongly or your usage of the content doesn&#8217;t need it updating so frequently. You can take control of this in YQL in a couple of ways.</p>
<p>First, you can choose to explicitly set the cache &#8220;maxage&#8221; header in an open data table to whatever you want. Lets say you want the table data to be cached for 5 minutes, then in the <code>&lt;execute&gt;</code> statement you&#8217;d say <code>response.maxAge=300; </code> (its specified in seconds).</p>
<p>Secondly you can just ask YQL to cache the response to a statement for longer &#8211; just append the <code>_maxage</code> query parameter to your call and the result will be stored in cache for that length of time (but not shorter than it would have been originally):</p>
<p><a href="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&amp;format=xml&amp;_maxage=3600">http://query.yahooapis.com/v1/public/yql?q=select  * from weather.forecast where location=90210&amp;_maxage=3600</a></p>
<p>This is really useful when you&#8217;re using output from a table that&#8217;s not caching enough or an XML source without having to do any open table work.</p>
<p>By making a few small changes to the way your client calls YQL and Pipes you can gain almost infinite rate limit in many cases <strong>and</strong> provide better performance to your users.</p>
<p>Jonathan Trevor</p>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2010/03/12/avoiding-rate-limits-and-getting-banned-in-yql-and-pipes-caching-is-your-friend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 4264</title>
		<link>http://yqlblog.net/blog/2009/12/16/changelog-for-build-4264/</link>
		<comments>http://yqlblog.net/blog/2009/12/16/changelog-for-build-4264/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 23:16:35 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=132</guid>
		<description><![CDATA[New feature highlights:

Customizable caching. Execute can now set maxage header in response (response.maxAge=300), and clients can also request a greater maxage header for increased performance (&#38;_maxage=300).
 Query aliases. Name your YQL queries using meaningful short names.

Core Table changes

New global execute element outside of bindings is prepended to all executes (to enable common js to be [...]]]></description>
			<content:encoded><![CDATA[<div><strong>New feature highlights:</strong></p>
<ul>
<li>Customizable caching. Execute can now set maxage header in response (response.maxAge=300), and clients can also request a greater maxage header for increased performance (&amp;_maxage=300).</li>
<li> Query aliases. Name your YQL queries using meaningful short names.</li>
</ul>
<p><strong>Core Table changes</strong></p>
<ul>
<li>New global execute element outside of bindings is prepended to all executes (to enable common js to be run over all bindings)</li>
</ul>
<p><strong>New Core tables</strong></p>
<ul>
<li>answers.*, Yahoo answers API</li>
<li>data.uri, create data URIs from web sources (<a href="http://developer.yahoo.com/yql/console/?q=select%20*%20from%20data.uri%20where%20url%3D%22http%3A%2F%2Fl.yimg.com%2Fa%2Fi%2Fus%2Fpps%2Fyql32.png%22">select * from data.uri where url=&#8221;http://l.yimg.com/a/i/us/pps/yql32.png&#8221;</a>)</li>
<li>yql.queries.*, create nicely named query aliases for YQL (<a href="http://query.yahooapis.com/v1/public/yql/jonathan/tables">http://query.yahooapis.com/v1/public/yql/jonathan/tables</a>)</li>
</ul>
<p><strong>Execute changes</strong></p>
<ul>
<li>max-age header is now auto-calculated based upon queries and rest calls made in execute</li>
</ul>
<p><strong><strong style="background-color: #ffffff;">Bug fixes, including:</strong></strong></p>
<ul>
<li>Redirect handling improved</li>
<li>Upgraded memcache library</li>
<li>Batchable attribute now works correctly with paramType=&#8221;query&#8221; and &#8220;matrix&#8221;</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2009/12/16/changelog-for-build-4264/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 3396</title>
		<link>http://yqlblog.net/blog/2009/10/02/changelog-for-build-3396/</link>
		<comments>http://yqlblog.net/blog/2009/10/02/changelog-for-build-3396/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 18:35:21 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=130</guid>
		<description><![CDATA[New feature highlights:

y.rest and y.query now support timeouts

y.rest(..).timeout(30).get() will fail after 30ms
y.query(&#8230;,30) will fail after 30ms
An exception gets thrown if the timeout is hit




Open Data Table schema changes

url/urls is now optional in the schema

Bug fixes, including:

@ substitution works for paging parts of the query
url based paging works in more cases


]]></description>
			<content:encoded><![CDATA[<div><strong>New feature highlights:</strong></p>
<ul>
<li>y.rest and y.query now support timeouts
<ul>
<li>y.rest(..).timeout(30).get() will fail after 30ms</li>
<li>y.query(&#8230;,30) will fail after 30ms</li>
<li>An exception gets thrown if the timeout is hit</li>
</ul>
</li>
</ul>
<ul></ul>
<p><strong>Open Data Table schema changes</strong></p>
<ul>
<li>url/urls is now optional in the schema</li>
</ul>
<p><strong><strong style="background-color: #ffffff;">Bug fixes, including:</strong></strong></p>
<ul>
<li>@ substitution works for paging parts of the query</li>
<li>url based paging works in more cases</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2009/10/02/changelog-for-build-3396/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 3013</title>
		<link>http://yqlblog.net/blog/2009/09/03/changelog-for-build-3013/</link>
		<comments>http://yqlblog.net/blog/2009/09/03/changelog-for-build-3013/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 15:47:44 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=120</guid>
		<description><![CDATA[New feature highlights:

set verb for configuring static variables
yql.storage tables for storing tables, environments and more in YQL itself
debug mode for table development (debug=true)
multiple environment support

Core table changes:

update for geo.placemaker table
social.connections.updates results are sorted by date similar to social.updates
csv table now has a charset key (if the source doesn&#8217;t provide one this can be used instead [...]]]></description>
			<content:encoded><![CDATA[<p><strong>New feature highlights:</strong></p>
<ul>
<li>set verb for configuring static variables</li>
<li>yql.storage tables for storing tables, environments and more in YQL itself</li>
<li>debug mode for table development (debug=true)</li>
<li>multiple environment support</li>
</ul>
<p><strong>Core table changes:</strong></p>
<ul>
<li>update for geo.placemaker table</li>
<li>social.connections.updates results are sorted by date similar to social.updates</li>
<li>csv table now has a charset key (if the source doesn&#8217;t provide one this can be used instead of the utf-8 default)</li>
</ul>
<p><strong>New core tables:</strong></p>
<ul>
<li>meme.*</li>
</ul>
<p><strong>Open Data Table schema changes</strong></p>
<ul>
<li>input key &#8220;as&#8221; attribute for renaming parameters</li>
</ul>
<p><strong>Execute changes</strong></p>
<ul>
<li>y.env function so you can load up enviroments inside a YQL execute element.</li>
<li>y.crypto, for cryptographic signing</li>
<li>y.context (single value, table, contains the name used by the executor of this table)</li>
</ul>
<p><strong>Bug fixes, including:</strong></p>
<ul>
<li>xpath and multiple IN url selects on HTML page no longer fails</li>
<li>table name is now present in execute</li>
<li>sanitize() can now take no params</li>
<li>workaround to ruby/github client-ip bug</li>
<li>update query without where clause returns error message instead return null</li>
<li>const key values are no longer mutable by the keys in the YQL query</li>
<li>add client-ip to outgoing header based on incoming authenticated IP address</li>
<li>@variables other than urls now work on data tables</li>
<li>trim whitespace around json responses to parse better (fixes itunes issue)</li>
<li>post method reverse(field=&#8221;id&#8221;) displays correct method name in error message</li>
<li>User-Agent sent via HTML fetches through YQL should indicate Yahoo Pipes 2.0 (now uses: Mozilla/5.0 (compatible; Yahoo Pipes 2.0; +http://developer.yahoo.com/yql/provider) Gecko/20090729 Firefox/3.5.2)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2009/09/03/changelog-for-build-3013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changelog for build 2174</title>
		<link>http://yqlblog.net/blog/2009/07/08/changelog-for-build-2174/</link>
		<comments>http://yqlblog.net/blog/2009/07/08/changelog-for-build-2174/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:54:04 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[changelog]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=117</guid>
		<description><![CDATA[New feature highlights:

INSERT/UPDATE/DELETE bindings and language features
JSONP-X feature (XML string as JSON result if format=xml and JSONP callback is specified)

Core table changes:

social.updates defaults to sorting updates by date (most recent first)

New core tables:

social.profile.status
social.connections.updates (efficiently gets updates for all connections)
flickr.photoset
geo.placemaker

Open Data Table schema changes

new &#8220;url&#8221; paging model
new &#8220;insert&#8221;,&#8221;update&#8221; and &#8220;delete&#8221; bindings
new &#8220;map&#8221; and &#8220;value&#8221; input key [...]]]></description>
			<content:encoded><![CDATA[<p><strong>New feature highlights:</strong></p>
<ul>
<li>INSERT/UPDATE/DELETE bindings and language features</li>
<li>JSONP-X feature (XML string as JSON result if format=xml and JSONP callback is specified)</li>
</ul>
<p><strong>Core table changes:</strong></p>
<ul>
<li>social.updates defaults to sorting updates by date (most recent first)</li>
</ul>
<p><strong>New core tables:</strong></p>
<ul>
<li>social.profile.status</li>
<li>social.connections.updates (efficiently gets updates for all connections)</li>
<li>flickr.photoset</li>
<li>geo.placemaker</li>
</ul>
<p><strong>Open Data Table schema changes</strong></p>
<ul>
<li>new &#8220;url&#8221; paging model</li>
<li>new &#8220;insert&#8221;,&#8221;update&#8221; and &#8220;delete&#8221; bindings</li>
<li>new &#8220;map&#8221; and &#8220;value&#8221; input key types</li>
</ul>
<p><strong>Execute changes</strong></p>
<ul>
<li>New methods on y.rest():
<ul>
<li>post(content), post the value of content to the url.</li>
<li>put(content), put the value of the content to the url</li>
<li>del(), send delete http verb to the url (delete is a reserved word in JavaScript? so thats why this is del)</li>
<li>contentType(string), set the content type of the payload on content (e.g. application/json)</li>
<li>accept(string), set the accept http header to a mimetype, and tell YQL what we expect the response to contain (and how to parse it) </li>
</ul>
</li>
</ul>
<p><strong>Bug fixes, including:</strong></p>
<ul>
<li>No microformats in a page handled better</li>
<li>Words like &#8220;Select&#8221; and &#8220;Desc&#8221; now acceptable in projection, where and function clauses</li>
<li>Map input type now works in &#8220;Select&#8221;</li>
<li>Query parameters on the console are now passed through to the YQL service</li>
<li>y.log response.object and native object fixes</li>
<li>Multiple open data table authors now shown in &#8220;desc&#8221;</li>
<li>Json table now accepts top-level arrays.</li>
<li>response.object can be appended</li>
<li>CSV parser handles commas inside quoted strings</li>
<li>Javascript array.toString() works better</li>
<li>response.headers returns headers correctly now</li>
<li>y.jsonToXml now accepts javascript objects and empty values encoded as NULL </li>
<li>multi-key joins key ordering fixed</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2009/07/08/changelog-for-build-2174/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding value to a data feed using YQL Execute</title>
		<link>http://yqlblog.net/blog/2009/06/17/adding-value-to-a-data-feed-using-yql-execute/</link>
		<comments>http://yqlblog.net/blog/2009/06/17/adding-value-to-a-data-feed-using-yql-execute/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 19:00:45 +0000</pubDate>
		<dc:creator>yqlteam</dc:creator>
				<category><![CDATA[feature]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[earthquake]]></category>
		<category><![CDATA[usgs]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>
		<category><![CDATA[yql execute]]></category>

		<guid isPermaLink="false">http://yqlblog.net/blog/?p=92</guid>
		<description><![CDATA[I want USGS earthquake data.  More specifically, I&#8217;m interested in recent, substantial quakes.  Fortunately, data.gov makes this data easy to find.  After searching through the USGS raw data catalog for the text &#8220;earthquake&#8221;, I choose the Worldwide M2.5+ Earthquakes, Past 7 Days feed, and pull it into YQL for parsing.  It&#8217;s almost perfect, but I [...]]]></description>
			<content:encoded><![CDATA[<p>I want USGS earthquake data.  More specifically, I&#8217;m interested in recent, substantial quakes.  Fortunately, <a href="http://www.data.gov">data.gov</a> makes this data easy to find.  After <a href="http://www.data.gov/catalog/category/0/agency/30/filter/earthquakes/type/">searching through the USGS raw data catalog for the text &#8220;earthquake&#8221;</a>, I choose <a href="http://earthquake.usgs.gov/eqcenter/catalogs/7day-M2.5.xml">the <em>Worldwide M2.5+ Earthquakes, Past 7 Days</em> feed</a>, and <a href="http://developer.yahoo.com/yql/console/?q=select%20*%20from%20atom%20where%20url%3D%27http%3A%2F%2Fearthquake.usgs.gov%2Feqcenter%2Fcatalogs%2F7day-M2.5.xml%27">pull it into </a>YQL for parsing.  It&#8217;s almost perfect, but I want easy access to each quake&#8217;s magnitude, and the magnitude is buried in the &#8220;title&#8221; element.  No worries.  I&#8217;ll use <a href="http://developer.yahoo.com/yql/guide/yql-execute-chapter.html">YQL Execute</a> to split it out and give it its own element in the feed&#8217;s structure.  I can then visualize this data using something like Jon LeBlanc&#8217;s <a href="http://github.com/jonleblanc/yql-utilities/tree/master"><em>js-yql-display</em> project</a> on github.</p>
<p>Here are a few reasons why YQL is perfect for this task:<br />
1) I can take advantage of Yahoo!&#8217;s web-serving infrastructure to fetch, process, and cache the feed, reducing my server&#8217;s exposure and bandwidth costs.  My table is also cached, further reducing bandwidth usage.</p>
<p>2) Because YQL Execute employs standard <a href="http://en.wikipedia.org/wiki/E4X">E4X</a>, I am using and adding to my JavaScript skill set, instead of spending time learning a new language</p>
<p>3) E4X was built specifically for XML manipulation so it has a convenient syntax for this job</p>
<p>4) By using YQL to do the heavy lifting, I can minimize the code I send to the browser and keep it focused on the display logic.</p>
<p>Ok. Ok. Here&#8217;s the code:</p>
<pre>
<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>?</FONT>xml version<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"1.0"</FONT> encoding<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"UTF-8"</FONT><FONT COLOR=BLUE>?</FONT><FONT COLOR=BLUE>&gt;</FONT>
<FONT COLOR=BLUE>&lt;</FONT>table xmlns<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"http://query.yahooapis.com/v1/schema/table.xsd"</FONT><FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT>meta<FONT COLOR=BLUE>&gt;</FONT>
        <FONT COLOR=BLUE>&lt;</FONT>description<FONT COLOR=BLUE>&gt;</FONT>Extracts magnitude from item title in atom feed and adds it as an element to the item.  We can then filter by magnitude using yql's built-in operators<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>description<FONT COLOR=BLUE>&gt;</FONT>
	<FONT COLOR=BLUE>&lt;</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>select entry from usgs<FONT COLOR=BLUE><B>.</B></FONT>earthquakes<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>
	<FONT COLOR=BLUE>&lt;</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>select entry from usgs<FONT COLOR=BLUE><B>.</B></FONT>earthquakes where entry<FONT COLOR=BLUE><B>.</B></FONT>magnitude <FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>=</FONT> <FONT COLOR=YELLOW>6.0</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>

  <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>meta<FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT>bindings<FONT COLOR=BLUE>&gt;</FONT>
    <FONT COLOR=BLUE>&lt;</FONT>select itemPath<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>""</FONT> produces<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"XML"</FONT><FONT COLOR=BLUE>&gt;</FONT>
		<FONT COLOR=BLUE>&lt;</FONT>urls<FONT COLOR=BLUE>&gt;</FONT>

			<FONT COLOR=BLUE>&lt;</FONT>url<FONT COLOR=BLUE>&gt;</FONT>http<FONT COLOR=BLUE>:</FONT><FONT COLOR=GREEN><I>//earthquake.usgs.gov/eqcenter/catalogs/7day-M2.5.xml?11d&lt;/url&gt;
</I></FONT>		<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>urls<FONT COLOR=BLUE>&gt;</FONT>
		<FONT COLOR=BLUE>&lt;</FONT>execute<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>!</FONT><FONT COLOR=BLUE><B>[</B></FONT>CDATA<FONT COLOR=BLUE><B>[</B></FONT>

			default xml namespace <FONT COLOR=BLUE>=</FONT> <FONT COLOR=PURPLE>"http://www.w3.org/2005/Atom"</FONT><FONT COLOR=BLUE><B>;</B></FONT>
			<FONT COLOR=RED><B>var</B></FONT> xml <FONT COLOR=BLUE>=</FONT> request<FONT COLOR=BLUE><B>.</B></FONT>get<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>.</B></FONT>response<FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//call the url defined above

</I></FONT>			 	entries <FONT COLOR=BLUE>=</FONT> <FONT COLOR=BLUE>&lt;</FONT>entries<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>entries<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//prep the output object
</I></FONT>				entry <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//individual entry in xml obj. used in loop below.
</I></FONT>				magnitude <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>;</B></FONT><FONT COLOR=GREEN><I>//magnitude of quake.  used in loop below

</I></FONT>			<FONT COLOR=RED><B>for</B></FONT> each<FONT COLOR=BLUE><B>(</B></FONT>entry <FONT COLOR=RED><B>in</B></FONT> xml<FONT COLOR=BLUE><B>.</B></FONT>entry<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>{</B></FONT>
				magnitude <FONT COLOR=BLUE>=</FONT>
					entry<FONT COLOR=BLUE><B>.</B></FONT>title<FONT COLOR=GREEN><I>//eg M 3.0, Puerto Rico region

</I></FONT>					<FONT COLOR=BLUE><B>.</B></FONT>split<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=PURPLE>' '</FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=GREEN><I>//eg --&gt; 3.0,
</I></FONT>					<FONT COLOR=BLUE><B>.</B></FONT>replace<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=PURPLE>','</FONT><FONT COLOR=BLUE><B>,</B></FONT> <FONT COLOR=PURPLE>''</FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT><FONT COLOR=GREEN><I>//eg --&gt; 3.0

</I></FONT>				entry<FONT COLOR=BLUE><B>.</B></FONT>appendChild<FONT COLOR=BLUE><B>(</B></FONT> <FONT COLOR=BLUE>&lt;</FONT>magnitude<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>magnitude<FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>magnitude<FONT COLOR=BLUE>&gt;</FONT> <FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>
				entries<FONT COLOR=BLUE><B>.</B></FONT>appendChild<FONT COLOR=BLUE><B>(</B></FONT>entry<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>

			<FONT COLOR=BLUE><B>}</B></FONT>
			response<FONT COLOR=BLUE><B>.</B></FONT>object <FONT COLOR=BLUE>=</FONT> entries<FONT COLOR=BLUE><B>;</B></FONT>
		<FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>execute<FONT COLOR=BLUE>&gt;</FONT>

    <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>select<FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>bindings<FONT COLOR=BLUE>&gt;</FONT>
<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>table<FONT COLOR=BLUE>&gt;</FONT>
</pre>
<p>Now, we can put this table on a server, <a href="http://developer.yahoo.com/yql/console/?q=use%20%27http%3A%2F%2Fgithub.com%2Fspullara%2Fyql-tables%2Fraw%2Ff196ed25002a6ad616d1c53adda5e28ea51f3fe2%2Fusgs%2Fusgs.earthquakes.xml%27%20as%20table%3B%20select%20entry%20from%20table%20where%20entry.magnitude%20%3E%3D%206.0">load it up in YQL</a>, and easily access the magnitude using YQL&#8217;s parser.</p>
<p>For those unfamiliar with E4X, it&#8217;s worth noting the namespace declaration (<code>default xml namespace = "http://www.w3.org/2005/Atom";</code>).  It tells YQL&#8217;s JavaScript engine what kind of structure to expect.  We wouldn&#8217;t be able to access the feed&#8217;s elements without it.  Find the namespaces associated with your data by looking in the xml wrapper:   The <em>Atom</em> namespace governs my feed&#8217;s structure as a whole, which is why it was convenient to declare it as a default.  For access to specific elements using another namespace, e.g. georss data, it&#8217;s be easier to define the namespace locally like this:<br />
<code>var ns = Namespace("http://www.georss.org/georss");</code><br />
and then use it like this:<br />
<code>var latitude = xml.ns::Result.ns::Latitude;</code></p>
<p>Since we&#8217;ve gone to the trouble of defining a YQL table, we may as well add parsing for the <em>summary</em> element, which also contains some useful information in an inconvenient format.  Because this content is a bit more extensive, while still being somewhat predictable, a regular expression works well.  Here&#8217;s the code:</p>
<pre>
<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>?</FONT>xml version<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"1.0"</FONT> encoding<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"UTF-8"</FONT><FONT COLOR=BLUE>?</FONT><FONT COLOR=BLUE>&gt;</FONT>
<FONT COLOR=BLUE>&lt;</FONT>table xmlns<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"http://query.yahooapis.com/v1/schema/table.xsd"</FONT><FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT>meta<FONT COLOR=BLUE>&gt;</FONT>

	<FONT COLOR=BLUE>&lt;</FONT>description<FONT COLOR=BLUE>&gt;</FONT>Extracts magnitude from item title in atom feed and adds it as an element to the item.  We can then filter by magnitude using yql's built-in operators.  Additionally, it extracts summary cdata, parses it, wraps the parsed data in its own element, and adds this element to the xml output.  <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>description<FONT COLOR=BLUE>&gt;</FONT>
	<FONT COLOR=BLUE>&lt;</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>select entry from usgs<FONT COLOR=BLUE><B>.</B></FONT>earthquakes<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>

	<FONT COLOR=BLUE>&lt;</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>select entry<FONT COLOR=BLUE><B>.</B></FONT>title<FONT COLOR=BLUE><B>,</B></FONT> entry<FONT COLOR=BLUE><B>.</B></FONT>updated<FONT COLOR=BLUE><B>,</B></FONT> entry<FONT COLOR=BLUE><B>.</B></FONT>link from usgs<FONT COLOR=BLUE><B>.</B></FONT>earthquakes<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>

	<FONT COLOR=BLUE>&lt;</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>select entry<FONT COLOR=BLUE><B>.</B></FONT>summary from usgs<FONT COLOR=BLUE><B>.</B></FONT>earthquakes where entry<FONT COLOR=BLUE><B>.</B></FONT>summary<FONT COLOR=BLUE><B>.</B></FONT>type <FONT COLOR=BLUE>=</FONT> <FONT COLOR=PURPLE>"xml"</FONT> and entry<FONT COLOR=BLUE><B>.</B></FONT>summary<FONT COLOR=BLUE><B>.</B></FONT>depth<FONT COLOR=BLUE><B>.</B></FONT>km <FONT COLOR=BLUE>&gt;</FONT> <FONT COLOR=BROWN>99</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>sampleQuery<FONT COLOR=BLUE>&gt;</FONT>

  <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>meta<FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT>bindings<FONT COLOR=BLUE>&gt;</FONT>
    <FONT COLOR=BLUE>&lt;</FONT>select itemPath<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>""</FONT> produces<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"XML"</FONT><FONT COLOR=BLUE>&gt;</FONT>
		<FONT COLOR=BLUE>&lt;</FONT>urls<FONT COLOR=BLUE>&gt;</FONT>

			<FONT COLOR=BLUE>&lt;</FONT>url<FONT COLOR=BLUE>&gt;</FONT>http<FONT COLOR=BLUE>:</FONT><FONT COLOR=GREEN><I>//earthquake.usgs.gov/eqcenter/catalogs/7day-M2.5.xml?11d&lt;/url&gt;
</I></FONT>		<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>urls<FONT COLOR=BLUE>&gt;</FONT>
		<FONT COLOR=BLUE>&lt;</FONT>execute<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>!</FONT><FONT COLOR=BLUE><B>[</B></FONT>CDATA<FONT COLOR=BLUE><B>[</B></FONT>

			default xml namespace <FONT COLOR=BLUE>=</FONT> <FONT COLOR=PURPLE>"http://www.w3.org/2005/Atom"</FONT><FONT COLOR=BLUE><B>;</B></FONT>

			<FONT COLOR=RED><B>var</B></FONT> xml <FONT COLOR=BLUE>=</FONT> request<FONT COLOR=BLUE><B>.</B></FONT>get<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>.</B></FONT>response<FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//call the url defined above

</I></FONT>			 	entries <FONT COLOR=BLUE>=</FONT> <FONT COLOR=BLUE>&lt;</FONT>entries<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>entries<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//prep the output object
</I></FONT>				entry <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//individual entry in xml obj. used in loop below.
</I></FONT>				magnitude <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//magnitude of quake.  used in loop below

</I></FONT>				re <FONT COLOR=BLUE>=</FONT> <FONT COLOR=PURPLE>'&lt;img '</FONT><FONT COLOR=GREEN><I>//img tag opening bracket (note: trailing spaces here and below)
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'src="(http://earthquake\\.usgs\\.gov/images/globes/[\\d_-]+\\.jpg)" '</FONT><FONT COLOR=GREEN><I>//img src - capture
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'alt="([\\d\\.]+&amp;#176;(?:N|S) [\\d\\.]+&amp;#176;(?:W|E))" '</FONT><FONT COLOR=GREEN><I>//img alt - ignore (we already have coords from georss)

</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'align="(left|right)" '</FONT><FONT COLOR=GREEN><I>//img align - ignore
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'hspace="(\\d+)" '</FONT><FONT COLOR=GREEN><I>//img hspace - ignore
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'/&gt;'</FONT><FONT COLOR=GREEN><I>//img tag closing bracket
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;p&gt;'</FONT><FONT COLOR=GREEN><I>//opening p tag

</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'(\\w+, \\w+\\s+\\d+, \\d+ [\\d:]+) UTC'</FONT><FONT COLOR=GREEN><I>//utc date - capture (note: variable amt of whitespace btwn month and day)
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;br&gt;'</FONT><FONT COLOR=GREEN><I>//br tag
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'(\\w+, \\w+\\s+\\d+, \\d+ [\\d:]+ (?:AM|PM)) at epicenter'</FONT><FONT COLOR=GREEN><I>//local date at epicenter - capture

</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;/p&gt;'</FONT><FONT COLOR=GREEN><I>//closing p tag
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;p&gt;'</FONT><FONT COLOR=GREEN><I>//opening p tag
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;strong&gt;Depth&lt;/strong&gt;: '</FONT><FONT COLOR=GREEN><I>//descriptive text w/ strong tags

</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'([\\d\\.]+) km '</FONT><FONT COLOR=GREEN><I>//depth in kilometers - capture
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'\\(([\\d\\.]+) mi\\)'</FONT><FONT COLOR=GREEN><I>//depth in miles (enclosed in parenthesis) - capture
</I></FONT>					<FONT COLOR=BLUE>+</FONT> <FONT COLOR=PURPLE>'&lt;/p&gt;'</FONT><FONT COLOR=BLUE><B>,</B></FONT><FONT COLOR=GREEN><I>//closing p tag

</I></FONT>				cdata <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>,</B></FONT>
				summary <FONT COLOR=BLUE>=</FONT> null<FONT COLOR=BLUE><B>;</B></FONT>

			<FONT COLOR=RED><B>for</B></FONT> each<FONT COLOR=BLUE><B>(</B></FONT>entry <FONT COLOR=RED><B>in</B></FONT> xml<FONT COLOR=BLUE><B>.</B></FONT>entry<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>{</B></FONT>

				magnitude <FONT COLOR=BLUE>=</FONT>
					entry<FONT COLOR=BLUE><B>.</B></FONT>title<FONT COLOR=GREEN><I>//eg M 3.0, Puerto Rico region
</I></FONT>					<FONT COLOR=BLUE><B>.</B></FONT>split<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=PURPLE>' '</FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=GREEN><I>//eg --&gt; 3.0,

</I></FONT>					<FONT COLOR=BLUE><B>.</B></FONT>replace<FONT COLOR=BLUE><B>(</B></FONT><FONT COLOR=PURPLE>','</FONT><FONT COLOR=BLUE><B>,</B></FONT> <FONT COLOR=PURPLE>''</FONT><FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT><FONT COLOR=GREEN><I>//eg --&gt; 3.0
</I></FONT>				entry<FONT COLOR=BLUE><B>.</B></FONT>appendChild<FONT COLOR=BLUE><B>(</B></FONT> <FONT COLOR=BLUE>&lt;</FONT>magnitude<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>magnitude<FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>magnitude<FONT COLOR=BLUE>&gt;</FONT> <FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>

				cdata <FONT COLOR=BLUE>=</FONT> <FONT COLOR=BLUE>new</FONT> RegExp<FONT COLOR=BLUE><B>(</B></FONT>re<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>.</B></FONT>exec<FONT COLOR=BLUE><B>(</B></FONT>entry<FONT COLOR=BLUE><B>.</B></FONT>summary<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>

				summary <FONT COLOR=BLUE>=</FONT> <FONT COLOR=BLUE>&lt;</FONT>summary type<FONT COLOR=BLUE>=</FONT><FONT COLOR=PURPLE>"xml"</FONT><FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>!</FONT><FONT COLOR=BLUE><FONT COLOR=BLUE>-</FONT><FONT COLOR=BLUE>-</FONT></FONT> differentiate <FONT COLOR=BLUE>this</FONT> summary obj from native summary obj w<FONT COLOR=BLUE>/</FONT> type <FONT COLOR=PURPLE>'html'</FONT> <FONT COLOR=BLUE><FONT COLOR=BLUE>-</FONT><FONT COLOR=BLUE>-</FONT></FONT><FONT COLOR=BLUE>&gt;</FONT>

					<FONT COLOR=BLUE>&lt;</FONT>img alt<FONT COLOR=BLUE>=</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>2</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT> align<FONT COLOR=BLUE>=</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>3</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT> hspace<FONT COLOR=BLUE>=</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>4</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT> src<FONT COLOR=BLUE>=</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT> <FONT COLOR=BLUE>/</FONT><FONT COLOR=BLUE>&gt;</FONT>

					<FONT COLOR=BLUE>&lt;</FONT>date<FONT COLOR=BLUE>&gt;</FONT>
						<FONT COLOR=BLUE>&lt;</FONT>utc<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>5</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>utc<FONT COLOR=BLUE>&gt;</FONT>
						<FONT COLOR=BLUE>&lt;</FONT>local<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>6</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>local<FONT COLOR=BLUE>&gt;</FONT>

					<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>date<FONT COLOR=BLUE>&gt;</FONT>
					<FONT COLOR=BLUE>&lt;</FONT>depth<FONT COLOR=BLUE>&gt;</FONT>
						<FONT COLOR=BLUE>&lt;</FONT>km<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>7</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>km<FONT COLOR=BLUE>&gt;</FONT>

						<FONT COLOR=BLUE>&lt;</FONT>mi<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>{</B></FONT>cdata<FONT COLOR=BLUE><B>[</B></FONT><FONT COLOR=BROWN>8</FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>}</B></FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>mi<FONT COLOR=BLUE>&gt;</FONT>
					<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>depth<FONT COLOR=BLUE>&gt;</FONT>
				<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>summary<FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE><B>;</B></FONT>

				entry<FONT COLOR=BLUE><B>.</B></FONT>appendChild<FONT COLOR=BLUE><B>(</B></FONT>summary<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>

				entries<FONT COLOR=BLUE><B>.</B></FONT>appendChild<FONT COLOR=BLUE><B>(</B></FONT>entry<FONT COLOR=BLUE><B>)</B></FONT><FONT COLOR=BLUE><B>;</B></FONT>

			<FONT COLOR=BLUE><B>}</B></FONT>
			response<FONT COLOR=BLUE><B>.</B></FONT>object <FONT COLOR=BLUE>=</FONT> entries<FONT COLOR=BLUE><B>;</B></FONT>
		<FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE><B>]</B></FONT><FONT COLOR=BLUE>&gt;</FONT><FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>execute<FONT COLOR=BLUE>&gt;</FONT>

    <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>select<FONT COLOR=BLUE>&gt;</FONT>
  <FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>bindings<FONT COLOR=BLUE>&gt;</FONT>
<FONT COLOR=BLUE>&lt;</FONT><FONT COLOR=BLUE>/</FONT>table<FONT COLOR=BLUE>&gt;</FONT>
</pre>
<p>Now we&#8217;re talking!  <a href="http://developer.yahoo.com/yql/console/?q=use%20%27http%3A%2F%2Fgithub.com%2Fspullara%2Fyql-tables%2Fraw%2Ff196ed25002a6ad616d1c53adda5e28ea51f3fe2%2Fusgs%2Fusgs.earthquakes.xml%27%20as%20usgs.earthquakes%3B%20select%20entry.summary%20from%20usgs.earthquakes%20where%20entry.summary.type%20%3D%20%22xml%22%20and%20entry.summary.depth.km%20%3E%2099">Check it out in the console</a>.</p>
<p>Here are a couple implementation-level notes:<br />
1) this code will generate an additional <em>summary</em> object, i.e., it doesn&#8217;t replace the pre-existing one.  If the later behavior is preferred, replace<br />
<code>entry.appendChild(summary);</code><br />
with<br />
<code>entry.summary = summary;</code></p>
<p>2) the regular expression syntax used above is just the standard syntax for JavaScript, but be aware that the html is rendered using html entities, so the content I&#8217;m parsing using the regular expression looks different in the YQL console.  For example, add this as the first line inside the for loop:<br />
<code>y.log(entry.summary);</code> <br />
This will print the <em>cdata</em>-wrapped html to the <em>diagnostics</em> section of the YQL output.  Instead of &#8220;&lt;img src=&#8221;http://earthquake&#8230;-65.jpg&#8221; alt=&#8221;19.192&amp;#176;N &#8220;, as we see in the raw xml feed, it looks like &#8220;&amp;lt;img src=&#8221;http://earthquake&#8230;-65.jpg&#8221; alt=&#8221;19.192&amp;amp;#176;N &#8230;&#8221;, On the server, it actually <em>is</em> the raw html, so the regular expression must be constructed accordingly.</p>
<p>To conclude, this post presents a couple ways to restructure a USGS data feed using YQL Execute so it&#8217;s more convenient to consume.  I&#8217;ve also given a couple tips for working with E4X and YQL.  Because YQL does the fetching, processing, and caching for me, my data delivery is speedy and my client-side code is light.</p>
]]></content:encoded>
			<wfw:commentRss>http://yqlblog.net/blog/2009/06/17/adding-value-to-a-data-feed-using-yql-execute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
