<?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>@TheKeyboard &#187; xquery</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/tag/xquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Wed, 08 Sep 2010 01:58:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Babysteps with xQuery</title>
		<link>http://www.littlehart.net/atthekeyboard/2007/10/26/babysteps-with-xquery/</link>
		<comments>http://www.littlehart.net/atthekeyboard/2007/10/26/babysteps-with-xquery/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 20:39:42 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[xquery]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2007/10/26/babysteps-with-xquery/</guid>
		<description><![CDATA[I know what you&#8217;re thinking: &#8220;Chris, aren&#8217;t you supposed to be talking about CakePHP, or PHP, or your ever-changing working conditions?!?&#8221;. Alas, enough about my storied working career. Working here now means that I&#8217;m going to become Mr. &#8220;I know how to manipulate XML&#8221; in a hurry. Lucky for me, I can use PHP 5 [...]]]></description>
			<content:encoded><![CDATA[<p>I know what you&#8217;re thinking:  &#8220;Chris, aren&#8217;t you supposed to be talking about CakePHP, or PHP, or your ever-changing working conditions?!?&#8221;.  Alas, enough about my storied working career.  Working <a href="http://www.xmlteam.com">here</a> now means that I&#8217;m going to become Mr. &#8220;I know how to manipulate XML&#8221; in a hurry.  Lucky for me, I can use PHP 5 and have access to SimpleXML to make fooling around with raw XML (is that actually a term?) so much easier.  I remember working with <a href="http://www.sportsticker.com">PA Sportsticker</a> XML feeds and having to write code to parse stuff out in PHP 4.  Compare that to using SimpleXML in PHP 5.  Go ahead, I&#8217;ll wait while you go and look it up.</p>
<p>
So, for a project I&#8217;m working on (no names until it goes beta) I&#8217;m having to write and retrieve information from an XML document repository system (<a href='http://www.caucho.com/resin-3.1/'>Resin</a>  + <a href='http://exist.sourceforge.net/'>eXist</a>).  Now, I&#8217;m not too bad with database stuff but this system doesn&#8217;t use SQL.  It uses something called <a href="http://www.w3.org/TR/xquery/">XQuery</a> to retrieve information.  I can pull back XML snippets, whole XML documents, or just extract data from it.  On the storing side, you can simply insert whole XML documents into it and then eXist takes care of indexing etc so you can look for information inside those documents.</p>
<p>
Lucky for me, my company has a subscription to O&#8217;Reilly&#8217;s <a href="http://safari.oreilly.com">Safari</a> system so I grabbed &#8216;XQuery Kick Start&#8217; and started reading up on how xQuery works and how I can cheat and only learn what I needed to do for this first task. So, what I had to do was this:</p>
<blockquote><p>
Give me all games that belong to this league
</p></blockquote>
<p>So, I had the key for the league, and every document that was a game has the key for the league as an attribute.  Now, if I was doing SQL you&#8217;d have something like:<br />
<code><br />
SELECT * FROM games WHERE league_id = $leagueKey<br />
</code><br />
and then you iterate through the results like normal.  Let me tell you, xQuery is VERY different.  <a href="http://bin.cakephp.org/saved/24839" target="new">Here&#8217;s what it looked like</a>.  My apologies for the link to the saved paste but it was looking terrible in preview. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
<p>Wow, not too intuitive at first glance, is it.  Anyway, here&#8217;s what the output looked like:<br />
<code><br />
2007-10-25 01:00:00AM|Monrovia Madness|Monrovia Madness,<br />
2007-10-26 04:00:00AM|Monrovia Madness|Monrovia Madness,<br />
</code><br />
Note the extra &#8216;,&#8217; at the end.  I&#8217;ll have to figure out how to stop it from doing that so I don&#8217;t have to do any code workarounds based on the output.  Sorry for the ultra-boring and non-informative test data, but you gotta start somewhere.  Now, the syntax does actually make a little bit of sense to me now that I&#8217;ve had the chance to muddle through from where I started.  I&#8217;ll keep you posted as I get into some more-than-basic uses of xQuery.</p>
<div class="fb-widget" id="fbtb-44a105fb5c054e3f89c6cd3bcc552654" style="border:0; outline:0; padding:0; margin:0; position:relative;" itemscope="" itemid="http://www.freebase.com/id/en/xquery" itemtype="http://www.freebase.com/id/computer/programming_language"> <form class="fb-widget-placeholder" style="border:0; outline:0; padding:0; margin:0;"> <input name="src" value="http://www.freebase.com/widget/topic?track=topicblocks_plugin_tags&amp;mode=content&amp;id=%2Fen%2Fxquery" type="hidden" /> <input name="width" value="413" type="hidden" /> <input name="height" value="285" type="hidden" /> <span style="line-height:1; border:0; outline:0; padding:0; margin:0; display:inline-block; padding:5px; background:#eee; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px;"> <div style="text-align:left; vertical-align:baseline; line-height:1; border:0; outline:0; margin:0 0 5px 5px;"> <a style="text-align:left; vertical-align:baseline; font-family:'Helvetica Neue', Arial, sans-serif; font-size:13px; font-weight:bold; line-height:1.6; text-decoration:none; color:#17b; border:0; outline:0; padding:0; margin:0;" href="http://www.freebase.com/view/en/xquery" target="_blank" > XQuery </a> </div> <div style="vertical-align:top; border:1px solid #ddd; outline:0; padding:0; margin:0; position: relative; width:400px; height:220px; overflow:auto; background-color:#fff"> <img src="http://img.freebase.com/api/trans/image_thumb/en/xquery?pad=1&amp;errorid=%2Ffreebase%2Fno_image_png&amp;maxheight=150&amp;mode=fillcropmid&amp;maxwidth=150" title="XQuery" style="border:0; outline:0; padding: 0; margin: 28px auto; display: block;"> </div> </span> </form> </div>]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2007/10/26/babysteps-with-xquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
