<?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>The Bruised Edge &#187; XQuery</title>
	<atom:link href="http://weblog.kevinclarke.info/category/xquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblog.kevinclarke.info</link>
	<description>Digital Libraries, Repositories, Programming, Technology, Librarianship, etc.</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:19:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Elsevier XQuery Challenge</title>
		<link>http://weblog.kevinclarke.info/2008/09/23/elsevier-xquery-challenge/</link>
		<comments>http://weblog.kevinclarke.info/2008/09/23/elsevier-xquery-challenge/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 21:04:40 +0000</pubDate>
		<dc:creator>ksclarke</dc:creator>
				<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://weblog.kevinclarke.info/?p=125</guid>
		<description><![CDATA[Elsevier has been doing cool things with XQuery for awhile now.  Now, they are holding a contest where each contestant will get access to 7,500 full-text XML articles from Elsevier journals.  The winner will be the one that can develop the best &#8220;unique yet useful web-based journal article rendering application.&#8221; So all you library-land XQuery [...]]]></description>
			<content:encoded><![CDATA[<p>Elsevier has been <a title="Elsevier announces xqDoc" href="http://www.econtentmag.com/Articles/ArticleReader.aspx?ArticleID=7779">doing cool things</a> with XQuery for awhile now.  Now, they are holding a contest where each contestant will get access to 7,500 full-text XML articles from Elsevier journals.  The winner will be the one that can develop the best &#8220;unique yet useful web-based journal article rendering application.&#8221;</p>
<p>So all you library-land XQuery hackers start your (XQuery) engines, here is the official story that came across the XQuery-Talk mailing list:</p>
<blockquote><p><span style="font-size: small;font-family: Times New Roman"><span style="font-size: 12pt">Elsevier Labs is inviting creative individuals who have wanted the opportunity to view and work with scientific journal article content on the web to enter the Elsevier Article 2.0 Contest. Each contestant will be provided online access to approximately 7,500 full-text XML articles from Elsevier journals, including the associated images, and the Elsevier Article 2.0 API to develop a unique yet useful web-based journal article rendering application.  The sample apps (including source code) we have provided on the Article 2.0 Contest web site were developed in XQuery.  While the contest does not mandate the use of XQuery, our experience has shown the technology is a natural fit for building these types of applications.</span></span></p>
<p><span style="font-size: small;font-family: Times New Roman"><span style="font-size: 12pt"> </span></span></p>
<p><span style="font-size: small;font-family: Times New Roman"><span style="font-size: 12pt">If you are interested in the contest, please visit the web site (<a title="http://article20.elsevier.com/" href="http://article20.elsevier.com/" target="_blank">http://article20.elsevier.com</a>) and apply for an Article 2.0 API Key. </span></span></p>
<p><span style="font-size: small;font-family: Times New Roman"><span style="font-size: 12pt"> </span></span></p>
<p><span style="font-size: small;font-family: Times New Roman"><span style="font-size: 12pt">If you have any questions about the contest, drop us an email at <a href="mailto:info-article20@elsevier.com" target="_blank">info-article20@elsevier.com</a>.</span></span></p></blockquote>
<p>Very cool&#8230; Oh, did I mention first prize is $4000, second prize is $2000, and third prize is $1000?  Not too shabby!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.kevinclarke.info/2008/09/23/elsevier-xquery-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MARC2Solr (Slight Return)</title>
		<link>http://weblog.kevinclarke.info/2007/02/19/marc2solr-slight-return/</link>
		<comments>http://weblog.kevinclarke.info/2007/02/19/marc2solr-slight-return/#comments</comments>
		<pubDate>Mon, 19 Feb 2007 19:55:52 +0000</pubDate>
		<dc:creator>ksclarke</dc:creator>
				<category><![CDATA[Search]]></category>
		<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://kevinclarke.info/weblog/?p=199</guid>
		<description><![CDATA[Awhile back, Andrew Nagy posted an XSLT for turning MARCXML into Solr&#8217;s XML indexing format. I thought it would be fun to take his XSLT and do the same thing in XQuery. I think it is pretty much a 1 to 1 conversion. For the upcoming Code4Lib preconference, I thought about forming an XQuery group. [...]]]></description>
			<content:encoded><![CDATA[<p>Awhile back, Andrew Nagy <a href="http://www.mail-archive.com/code4lib@listserv.nd.edu/msg01213.html" title="marc2solr.xslt">posted</a> an XSLT for turning MARCXML into Solr&#8217;s XML indexing format.  I thought it would be fun to take his XSLT and <a href="http://lisforge.net/xqsolr/marc2solr.xq" title="marc2solr.xq">do the same thing in XQuery</a>.  I think it is pretty much a 1 to 1 conversion.</p>
<p>For the upcoming <a href="http://code4lib.org/node/139" title="Code4lib preconference">Code4Lib preconference</a>, I thought about forming an XQuery group.  I ended up joining the Java group, though, because there aren&#8217;t any native HTTP libs in XQuery (so I&#8217;d have to do that as an extension in Java anyway).   I still think doing an XQuery group would be fun though.</p>
<p>For instance, one nice feature of XQuery is that is allows you to be as strongly or loosely typed as you&#8217;d like. Take off all the &#8220;as &#8230;&#8221; statements from the XQuery and it still works just fine (it just won&#8217;t be so picky about what you pass into (or return from) its functions).</p>
<p>Recently, I&#8217;ve found myself on both sides of this fence; when working with a little bit of throw-away Java code, I&#8217;ve found myself wishing for a little of Ruby&#8217;s loose typing.  On the other hand sometimes, when experimenting with Ruby, I mutter to myself: &#8220;Why can&#8217;t this just be strongly typed so I know what to expect and do?&#8221;</p>
<p>XQuery really gives you the best of both worlds.  This isn&#8217;t to say XQuery can do everything those other languages can (it can&#8217;t&#8230; and far from it). But, if you are working with XML (and want to focus on the data rather than the data&#8217;s source) I can&#8217;t think of a nicer language to use.  It will be interesting to watch XQuery <a href="http://tinyurl.com/2o7uy8" title="XQueryP">grow as a programming language</a>.</p>
<p>So anyway&#8230; since my marc2solr.xq is written as a module you&#8217;ll need to call it from something else.  This little XQuery (<a href="http://lisforge.net/xqsolr/solr.xq" title="solr.xq">also here</a>) works fine from Saxon (pass in the location of a MARCXML file on the file system as $input):</p>
<blockquote><pre>xquery version "1.0";

import module
  namespace marc2solr = "http://lisforge.net/ns/marc2solr"
  at "marc2solr.xq";

declare variable $input external;

marc2solr:add-records(doc($input))</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://weblog.kevinclarke.info/2007/02/19/marc2solr-slight-return/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XQ and Default External Variables</title>
		<link>http://weblog.kevinclarke.info/2006/02/09/xq-and-default-external-variables/</link>
		<comments>http://weblog.kevinclarke.info/2006/02/09/xq-and-default-external-variables/#comments</comments>
		<pubDate>Fri, 10 Feb 2006 00:54:56 +0000</pubDate>
		<dc:creator>ksclarke</dc:creator>
				<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://kevinclarke.info/weblog/?p=206</guid>
		<description><![CDATA[One thing that I really think XQuery needs is the ability to specify a default value for an external variable. I wrote a workaround for our XQuery servlet awhile back but, since I needed to update our XQs with the newest release of our native XML database (it supports a newer version of the spec), [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that I really think XQuery needs is the ability to specify a default value for an external variable. I wrote a workaround for our XQuery servlet awhile back but, since I needed to update our XQs with the newest release of our native XML database (it supports a newer version of the spec), I’m looking at the problem again.</p>
<p>Currently, defining a variable that will be passed into the XQuery from an external source is pretty easy:</p>
<blockquote><pre>declare variable $xsl as external;</pre>
</blockquote>
<p>The problem is… what if you don’t want to pass in default values for every variable (wouldn’t it be nice if you could define them in the XQ itself)? On my first time through this problem I received a sensible (though verbose) suggestion to define another variable:</p>
<blockquote><pre>declare variable $xsl as external;
declare variable $_xsl := if ($xsl) then $xsl else 'default.xsl';</pre>
</blockquote>
<p>That looks good, looks like it should work, but with my particular native XML database (and perhaps others?) you still need to pass in an empty value for the variable itself. If you don’t have <code>xquery.xq?xsl=</code> then it will fail with an ‘unknown external variable xsl’ exception. The person who made this suggestion, told me empty values could be passed in the code that calls the XQ.</p>
<p>But, I don’t think I should have to tell the XQ what its variables are. In my case, where I have a single XQuery servlet that evaluates all *.xq, this means I need to keep track of all the relevant variables for any given XQ (which is what I currently do by parsing the XQ to see what external variables it defines (this could also be done easier with an XQuery Java API)). It seems like a lot of work though (even if it is cached) compared with what would be a nice, simple solution:</p>
<blockquote><pre>declare variable $xsl external 'default';</pre>
</blockquote>
<p>Or, something like that… this way, when an external variable isn’t passed in there would be some way to specify what the default value that be should be used is. I don’t know if something like this is in the works for XQuery but it seems like it would make sense to me. Or, perhaps, there is another way around this problem that I’m missing(?)</p>
]]></content:encoded>
			<wfw:commentRss>http://weblog.kevinclarke.info/2006/02/09/xq-and-default-external-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
