<?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>blog.humaneguitarist.org &#187; Saxon</title>
	<atom:link href="http://blog.humaneguitarist.org/tag/saxon/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.humaneguitarist.org</link>
	<description>discoveries in digital audio, music notation, and information encoding</description>
	<lastBuildDate>Tue, 07 Feb 2012 03:33:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>running XQuery online</title>
		<link>http://blog.humaneguitarist.org/2009/11/08/running-xquery-online/</link>
		<comments>http://blog.humaneguitarist.org/2009/11/08/running-xquery-online/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 01:26:54 +0000</pubDate>
		<dc:creator>nitin</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Saxon]]></category>
		<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://blog.humaneguitarist.org/?p=450</guid>
		<description><![CDATA[A while ago, I&#160;posted about my first experience with XQuery and how I&#39;d used the .NET version of the Saxon processor on my local Windows machine. Obviously, I&#160;want to extend that experience to running XQueries online. So far, I&#160;know this can easily be done with a native XML database server like eXist. That is to [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I&nbsp;posted about my <a href="http://blog.humaneguitarist.org/?p=152">first experience with XQuery</a> and how I&#39;d used the .NET version of the <a href="http://saxon.sourceforge.net/">Saxon</a> processor on my local Windows machine.</p>
<p>Obviously, I&nbsp;want to extend that experience to running XQueries online. So far, I&nbsp;know this can easily be done with a native XML database server like <a href="http://exist-db.org/">eXist</a>. That is to say, when I installed eXist on my local machine and made it go live: bam! &#8211; instant XML server with built-in XQuery functionality, accessible from anywhere.</p>
<p>Another way is to use one of the more popular web-scripting languages to execute XQuery syntax. I nearly killed myself this weekend trying to install the <a href="http://www.ibm.com/developerworks/opensource/library/x-zorba/index.html">Zorba PHP binding for XQuery</a> (i.e. run XQuery natively from within a PHP&nbsp;script). I just couldn&#39;t get all the dependencies successfully installed on my virtual install of <a href="http://www.ubuntu.com/getubuntu/download-netbook?info=EXLINK">Ubuntu Netbook Remix</a> (BTW: I&nbsp;use Sun&#39;s <a href="http://www.virtualbox.org/">VirtualBox</a> for virtualization). Perhaps I&#39;ll be able to make it work another time.</p>
<p>Now, even though it makes all the sense in the world to stick with a native XML server like eXist if I want to make a large collection of searchable XML documents online (and I&nbsp;do), I&#39;m feeling non-sensical. What I&nbsp;decided to try was to run my computer as a more traditional server using the X-Apache-MySql-PHP model, specifically <a href="http://www.wampserver.com/en/">WampServer</a>.</p>
<p>From there, I&nbsp;placed my sample document, &quot;<a href="http://www.w3schools.com/XQuery/books.xml">books.xml</a>&quot; and my &quot;test.xquery&quot; file from last time:</p>
<pre class="brush:xml">&lt;ul&gt;
{
for $x in doc(&quot;books.xml&quot;)/bookstore/book/title
order by $x
return &lt;li&gt;{data($x)}&lt;/li&gt;
}
&lt;/ul&gt;</pre>
<p>in WAMP&#39;s &quot;www&quot; directory &#8211; i.e. the directory which is accessible from the browser, the place where one would put all their HTML files, etc. for the world to see.</p>
<p>Of course, I was still missing the actual XQuery processor at this point. What I tried is to put the relevant executables for Saxon in the &quot;www&quot; directory as well.</p>
<p>&#8230; Now, I&#39;m sure this is totally unsafe or something, but I was just testing and I only make my computer &quot;go live&quot;&nbsp;as a server for short periods of time.</p>
<p>Anyway, from there I&nbsp;used PHP to call the Saxon processor and to display the results in the browser. It actually worked!</p>
<p>Here&#39;s the code:</p>
<pre class="brush:php">&lt;?php
echo &quot;Hi. I&#39;m going to use XQuery to list the books alphabetically.&quot;;
exec(&quot;query.exe test.xquery !indent=yes&quot;, $results);
foreach ($results as $value)
    {
       echo &quot;$value&quot;;
    }
?&gt; </pre>
<p>You can see that the PHP &quot;exec&quot; command called the Saxon executable named &quot;query.exe&quot; and executes the &quot;test.xquery&quot; file.</p>
<p>It saves the results in a variable called &quot;results&quot; and then prints each value of the results in the browser.</p>
<p>For now, I&#39;m OK with this, but I need to eventually do the same thing with the Java version of Saxon, I&nbsp;suppose, if I&#39;m ever going to run this on a Linux server. It shouldn&#39;t present any new hurdles, but I need to try it to make sure, of course.</p>
<p>If anyone out there has any thoughts or recommendations on a more elegant method to achieve these results &#8211; and what the security risks of the approach I&#39;ve outlined presents (since I didn&#39;t use a CGI-bin), please speak up. I&#39;m all ears.</p>
<p><img alt=":)" src="http://blog.humaneguitarist.org/wp-content/plugins/fckeditor-for-wordpress-plugin/ckeditor/plugins/smiley/images/regular_smile.gif" title=":)" /></p>
<p>&#8230;</p>
<p><strong>Update, November, 2009:</strong> No problems with using the Java version of Saxon. I&nbsp;did place it in a &quot;bin&quot; directory on my local server so that the Java file wouldn&#39;t reside in the directory that users have direct access to.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.humaneguitarist.org/2009/11/08/running-xquery-online/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

