Adam Retters XQuery Blog CodeAdam Retter's Bloghttp://www.adamretter.org.uk/blog.xql2013-05-11T15:49:05.982+01:00Adam Retterhttp://www.adamretter.org.uktag:www.adamretter.org.uk,2009-07-22:/blog.xqlAuthenticating with Redstone XML-RPC Proxytag:www.adamretter.org.uk,2013-05-11:/blog/entries/redstone-xml-rpc-authentication.xml2013-05-11T15:49:05.982+01:002013-05-11T15:49:05.982+01:00Adam RetterRedstone is an excellent and simple XML-RPC library. Recently when trying to create a simple XML-RPC client using Redstone in some example code for a book I am writing, I needed to be able to authenticate with the 3rd-party XML-RPC server.The server that I was attempting to communicate with (eXist) requires at least HTTP Basic Authentication for operations that require a user to have been granted various permissions. Redstone provides no explicit functionality for authentication or information on how to achieve such things. However as its Open Source, I dug through the code and discovered that it uses a standard java.net.HttpUrlConnection. Whilst it is quite possible to do HTTP Basic Authentication with HttpUrlConnections by setting the correct HTTP Header, I was making use of Redstone's XML-RPC Proxy facility, to help keep my client code simple, which unfortunately does not expose anymore than an instance of the Interface you proxy. Another quick examination of the Redstone code showed that they were using java.lang.reflect.Proxy to create a dynamic proxy of the provided Interface.We can use Proxy.getInvocationHandler on our XML-RPC proxy to get the Invocation Handler, which happens to be an instance of redstone.xmlrpc.XmlRpcProxy which offers us the method setRequestProperty(name, value). Any request properties set in this way are set as Headers on the Http Request used by the XML-RPC proxy.XQuery Matching Based on Word Distancetag:www.adamretter.org.uk,2012-08-18:/blog/entries/xquery-matching-based-on-word-distance.xml2012-08-19T16:36:00.000+01:002012-08-18T18:43:00.000+01:00Adam RetterWhilst at this moment I am meant to be preparing my sessions of the XML Summer School this year, I was reviewing Priscilla Walmsley's slides from last year and saw the following example given as a 'Search and Browse' use-case for XQuery:"What medical journal articles since 2004 mention "artery" and "plaque" within 3 words of each other?"I immediately thought to myself 'Hmm... that would be a tricky one to code in XQuery!. Of course the easy answer would be to use the W3C XPath and XQuery Full-Text extensions, for example:Sadly however, eXist-db, which is the XQuery platform I like to use, does not implement the W3C Full-Text extensions yet. Instead it has its own full-text extensions based on Lucene, so in eXist-db the equivalent would be:If I stopped there however, it would be quite a short blog post. It also appears from the implementation test results that the W3C XPath and XQuery Full-Text specification is not widely implemented. So how about implementing this in pure XQuery? I took the challenge, and my Solution is below.I would be interested to see attempts at a more elegant implementation or suggestions for improvements.Keeping GitHub pages up to date with your mastertag:www.adamretter.org.uk,2012-08-19:/blog/entries/keeping-github-gh-pages-and-master-in-sync.xml2012-08-19T12:03:00.000+01:002012-08-19T12:03:00.000+01:00Adam Retter
For the RESTXQ specification
that I am working on as part of my EXQuery efforts,
I need to write up a "formal" specification for RESTXQ.
The EXQuery RESTXQ code base lives on GitHub
(http://github.com/exquery/exquery),
and the specification has been authored in the exquery-restxq-specification module.
The RESTXQ specification is authored in HTML using Robin Berjon's excellent
ReSpec tool.
As specifications are arguably meant to be read by people, it would be nice if we could present the
work in progress from the source repository to users as a web page.
Fortunately GitHub provides a nice facility for web pages called
...EXPath HTTP Client and Heavens Abovetag:www.adamretter.org.uk,2012-04-29:/blog/entries/expath-http-client-heavens-above.xml2012-04-29T14:28:00.000+01:002012-04-29T14:28:00.000+01:00Adam RetterWhilst writting a data mash-up service for the Predict the Sky challenge at the NASA Space Apps hack day at the Met Office, I hit a very strange problem with the EXPath HTTP Client. I needed to scrape data from a webpage on the Heavens Above website http://heavens-above.com/PassSummary.aspx?showAll=x&satid=25544&lat=50.7218&lng=-3.5336&loc=Unspecified&alt=0&tz=CET and so I wrote the following XQuery:However that query would always return a HTTP 404 result:Now, this seemed very strange to me as I could paste that URL into any Web Browser and be returned a HTML Web Page! So I broke out one of my old favourite tools, Wireshark, to examine the differences between the HTTP request made by the EXPath HTTP Client (which is really the Apache Commons HTTP Components Client underneath) and cURL. I decided to use cURL as its very simple and so therefore I knew it would not insert unnessecary headers into a request, of course I made sure it worked first!NASA Space Apps Challengetag:www.adamretter.org.uk,2012-04-22:/blog/entries/nasa-space-apps.xml2012-04-23T19:13:00.000+01:002012-04-22T21:01:00.000+01:00Adam RetterThis weekend I returned to Devon and attended the NASA Space Apps Challenge at the Met Office. This is only the second hackathon I have attended outside of the eXist-db sessions I have done in the past and it was great fun.When we arrived we were given a few somewhat cheesy welcome videos from NASA and then presented with the challenges, I chose to join the “Predict the Sky” challenge.The goal of the 'Predict the Sky' project was to create applications which would allow a user to know what objects are in the sky over their location at night, and the chances of them being able...Connecting to OpenIndiana by XDMCPtag:www.adamretter.org.uk,2011-07-23:/blog/entries/open-indiana-enable-xdmcp.xml2011-07-23T17:02:00.000+02:002011-07-23T17:02:00.000+02:00Adam RetterI have a small NAS which I have built which run's OpenIndiana oi_151 and I wanted to be able to headlessly administer it, whilst I have SSH and thats all I really need, sometimes its nice to use a remote desktop environment.XDMCP is a fundamental part of the X Window System, and one feature it offers is the ability to export your display across a network.To enable XDMCP on OpenIndiana simply modify the XDMCP section in the file /etc/gdm/custom.conf so that it looks something like this -Now you just need to restart the GDM service -...Installing Netatalk on OpenIndianatag:www.adamretter.org.uk,2011-07-23:/blog/entries/configure-openindiana-as-mac-fileserver.xml2011-07-23T15:57:00.000+02:002011-07-23T15:57:00.000+02:00Adam RetterIt is possible to configure your OpenIndiana system to operate as a file server for your Mac using the AFP protocol, and if you have lots of lovely ZFS storage attached then it makes lots of sense. You can also configure OpenIndiana to act as as Time Capsule for your Mac's Time Machine!The instructions below relate to OpenIndiana oi_151, and Apple Mac OSX Snow Leopard, however the procedure is probably much the same for all OpenIndiana versions. The Time Machine configuration does not work yet for Apple Mac OSX Lion, when I figure this out I will post the details.First you need to install the pre-requisites for building Netatalk on OpenIndiana. You need gcc and BerkelyDB -You can download Berkeley DB from here. There are reported issues with version 5 and Netatalk, and so I used the latest 4.8 release. You then need to build and install Berkeley DB -Netatalk is a software package that acts as an AFP server. You can download Netatalk from here. You then need to build and install Netatalk -After the...Installing Postgres 9.0 onto Amazon EC2 Linuxtag:www.adamretter.org.uk,2011-07-09:/blog/entries/ec2-amazon-linux-and-postgres9.xml2011-07-09T16:02:00.000+02:002011-07-09T16:02:00.000+02:00Adam RetterAmazon EC2 Linux is based on a customised version of Redhat Enterprise Linux, but sadly they do not seem to have Postgres 9.0 available from their Yum repositories. However with a bit of fiddling around I was able to get it to install, so I have reproduced the details here for everyone else.1) Download and install the appropriate YUM repository configuration from here - http://yum.pgrpms.org/reporpms/repoview/pgdg-redhat.html2) You need to manually edit the Yum repo file that has just been installed for Postgres 9, as otherwise an unknown release version (as far as the Postgres repo is concerned) will be used, and you wont be able to download and install the packages.
Edit the file /etc/yum.repos.d/pgdg-90-redhat.repo and replace the string “$releasever” with “6.0”3) You can now install Postgres 9.0 using Yum.4) You can now start up the database5) Check that you can login to the serverDone :-)LDAP query for Active Directory User's Primary Grouptag:www.adamretter.org.uk,2011-07-01:/blog/entries/active-directory-ldap-users-primary-group.xml2011-07-01T22:57:00.000+02:002011-07-01T22:57:00.000+02:00Adam RetterWhen querying AD (Active Directory) with LDAP (Light-weight Directory Access Protocol), it is possible to easily retrieve a lot of attribute information about a user. However, it is not obvious or straight-forward to understand how to find out the Primary Group that a user belongs to. Whilst you can get a list of groups from the 'memberOf' attribute on the 'user' object class, or even find groups by their members through the 'member' attribute of the 'group' object class, these lists do not include information about the User's Primary Group.The 'user' Class, does provide a 'primaryGroupID' attribute, however...Configuring Hibernate with all Annotated classes in a Packagetag:www.adamretter.org.uk,2011-06-24:/blog/entries/hibernate-configure-all-package-classes.xml2011-06-24T23:26:00.000+02:002011-06-24T23:26:00.000+02:00Adam RetterUsing the Maven Hibernate plugin, I am automatically generating all Hibernate ORM model classes from my existing database schema. The ORM model classes that are generated have Hibernate and JPA (Java Persistence API) Java Annotations in them.Sadly, Hibernate does not Scan for annotated classes at startup and so you have to configure Hibernate manually, either through an XML configuration file or programatically, so that it knows about your annotated classes. You have to tell it about each and every class, not only is this quite tedious, its also a pain to maintain as each time you add/remove an entity from your database, you have to remember to add/remove the ORM class to/from the Hibernate config.Considering that our classes are already annotated, having to configure them manually seems unnecessary to me. It...Moving to Frankfurttag:www.adamretter.org.uk,2011-01-16:/blog/entries/moving-to-frankfurt.xml2011-01-16T16:55:00.000+01:002011-01-16T16:46:00.000+01:00Adam RetterRecently myself and some other core developers of eXist-db, an Open Source project which I have been involved in for over five years now, decided to start a commercial venture offering Support and Consultancy around the Open Source project: the new venture is called eXist Solutions.Whilst it is still early days for our company, things have been going well. We are very much International in our approach and philosophy; in fact, at present no two shareholders of the company are even from the same country! I am one of two Directors of the company, and my counterpart Wolfgang Meier is based in Rüsselsheim, Germany.Along with my partner Liz, we recently decided to move to Frankfurt for about six months (if all goes well). The reasons for this are two-fold: 1) to support the rapid...Open Indiana Web Hostingtag:www.adamretter.org.uk,2010-11-22:/blog/entries/open-indiana-web-hosting.xml2010-11-22T22:16:39.000+01:002010-11-22T16:39:00.000+01:00Adam RetterI have been hosting my own websites for a couple of years now with a company called Entic.net. Entic.net offer Solaris hosting, by providing full VPS's (Virtual Private Server's) via Solaris Zones technology, they are a great little company with excellent personal support. I am so happy with their service and assistance over the last couple of years, that I really feel I have to sing their praises in public!I originally started out with Entic.net in mid 2008, when I was looking for affordable Solaris 10 hosting after doing some benchmarking with an eXist-db application and discovering that the best performance was achieved when running atop Solaris 10. Entic.net were at that time able to provide me with a Sun Solaris 10 VPS (curd.entic.net) for just $20 USD/month. Whilst it was located in their US San Jose data center and I am in the UK, I decided that the geographical location did not really matter to me, after all we are both connected to the web!In June 2009 they assisted me (at no charge!) in migrating to an Open Solaris VPS (well.entic.net) again still at $20 USD/month, for someone who also spends a lot of time in Linux, the move to Open Solaris made server admin much easier - due to the integration of more GNU tools when compared to its predecessor.As I am an incurable technology junkie, and had been wondering about where to go from Open Solaris now that Oracle have taken over, I contacted Entic.net and enquired about their plans. To my joy I found out that they were already...NetBeans Platform Application - Memory Settingstag:www.adamretter.org.uk,2010-10-02:/blog/entries/netbeans-platform-application-memory.xml2010-10-02T22:00:00.000+01:002010-10-02T22:00:00.000+01:00Adam RetterI have been working on an application for annotating TEI texts on behalf of Oxford University Computing Services. The application embeds the oXygen XML Author v12 into the NetBeans Platform v6.9, whilst severely restricting the functionality of oXygen. The purpose of restricting oXygen is to simplify the UI and options available to the end user; The user may not have a high level of computer literacy.I had a problem whereby opening a large TEI document in the application failed to work. The problem turned out to be a lack of available memory for the application.NetBeans allows you...jQuery XHTML Checkbox problemstag:www.adamretter.org.uk,2010-09-14:/blog/entries/jquery-xhtml-checkbox.xml2010-09-24T05:56:10.002-07:002010-09-14T13:04:00.000+01:00Adam Retter
Whilst working on some jQuery (1.4.2) script in combination with the eXist-db bibliographic demo app, I had a situation whereby I was trying to switch XHTML form input checkboxes on and off when the user took certain actions.
I was using code similar to the following -
Which is very similar to what you will find on the web if you look for solutions to check and uncheck checkboxes with jQuery. Unfortunately this for me just would not work, whenever the user checked a check box I was completely unable to check it. Examining it with the debugger in Chrome I could see something like the following after removeAttr(...) is called -
Now what drove me nuts is the last line from the debugger, was...The Not So Mobile Phonetag:www.adamretter.org.uk,2009-09-14:/blog/entries/samsung-galaxy-battery-fail.xml2009-09-14T18:56:00.000+01:002009-09-14T18:56:00.000+01:00Adam RetterSince the beginning of this year I have been looking out for a new phone to replace my ageing Nokia N95. My main requirement was that it must be suitable for Web and email use - a large colour screen, integration with Web 2.0 services (such as Twitter and Facebook), 3G and WiFi radios and available on an unlimited data tariff. Secondly the phone must have a decent camera, the 5 Mega-pixel camera and flash built into the N95 is excellent.Initially I was waiting for the release of the Nokia N97 in June, but due to some unfavourable early reviews, its bulky design and the fact that it looked that if I was to drop it, I might end up with two phones, I decided to search for something else.After hearing much news of Google's Android over the previous months I decided to look into which phones might be available with Android. As a Software Developer and Open Source advocate, Android really appeals to me due to its non-proprietary software and application store - as opposed to Apple's offerings! It turned out that there were not a great deal of Android phones available at that time. I did find some vague rumours and information on the upcoming HTC Hero and decided to wait a little longer for its release.At the beginning of August I was able to play with a real HTC Hero in my local Orange shop. Whilst I was very impressed, I was also very disappointed that the built in Camera lacked a flash. I often take photos when we are out with friends in the evenings and this would not be possible without a flash. So I...Data 1, Disk 0tag:www.adamretter.org.uk,2009-07-12:/blog/entries/nas-disk-failure.xml2009-07-12T17:50:00.000+01:002009-07-12T17:50:00.000+01:00Adam RetterAfter having finally built my NAS and had it happily working away in the background for a couple of weeks, it would seem that failure has struck; one of the disks forming the ZFS RAIDZ2 storage pool has failed! Whilst I am sure this seems a little ironic or sounds like a commissioned advert for ZFS by Sun, I can only try to reassure you that this is not the case.Recently I experienced an unexpected crash with the NAS (no network response whatsoever), I am still unsure of the cause but have not had the time to investigate further. However, after powering the NAS off (ouch!) and back on again, I did take a quick look to make sure my data was intact by checking the zpool status. Unfortunately the bad news was that the pool status was reported as "degraded" with details of a failed disk, the good news however (and the whole point behind this setup) was that my data was fine :-)I am fairly new...Choosing Software and Hardware for my DIY NAStag:www.adamretter.org.uk,2009-06-02:/blog/entries/diy-nas-software_and_hardware.xml2009-07-07T17:59:00.000+01:002009-06-02T23:00:00.000+01:00Adam RetterIn deciding to build my own NAS, after having identified my requirements in Part 1, I set about searching for the perfect hardware and software combination...There are plenty of open source operating systems available that offer multiple options for reliable storage, including both hardware and software supported RAID. To avoid getting into the situation of outdated/unsupported hardware again, I have decided not to use any sort of hardware assisted RAID, instead I will use the software RAID support provided by the operating system itself.Many of these operating systems support a vast array of system hardware, however I did not want to just reuse a standard PC/Server because of its...Building my DIY NAStag:www.adamretter.org.uk,2009-07-05:/blog/entries/diy-nas-build.xml2009-07-05T20:10:00.000+01:002009-07-05T20:10:00.000+01:00Adam RetterAfter previously deciding to build my own NAS, having defined my requirements in Part 1 and identified suitable hardware and software in Part 2, I will now discuss the build first in terms of the physical hardware build and then the software installation and configuration.I will not detail the exact build process for the Chenbro chassis as that information is available in the manual, instead I will try and capture my own experience, which will hopefully complement the available information.Once all the parts had arrived, the first think to do was un-box everything before starting to put the system together. My immediate impression of the Chenbro ES34069 NAS chassis was that it was robustly built and manufactured to a high standard.The first step in building the NAS with the Chenbro chassis, is to open up the chassis and then install the Motherboard. To...In need of Open Storagetag:www.adamretter.org.uk,2009-05-31:/blog/entries/diy-nas-requirements.xml2009-06-02T23:00:00.000+01:002009-05-31T22:35:00.000+01:00Adam RetterA few years ago I came to the conclusion that I needed reliable storage for some of my more important work related files; should I lose such files, work opportunities and/or money could be at risk. I purchased a HighPoint TechnologiesRocketRAID 1640 PCI SATA card along with three 250GB Seagate SATA Hard Disks, and added to my home main desktop computer this gave me a reasonable RAID 5 setup.At the time I was running FreeBSD 6.x and Windows XP and both were well supported by HighPoint. Whilst I have upgraded the desktop computer several times since its original build, the RocketRAID card and disks have always remained a reliable constant. More recently, after some failures with Windows Vista 64, I have opted to use Ubuntu as my primary operating system at home. Unfortunately when I upgraded to the latest release of Ubuntu (9.04), I found that my RocketRAID card no longer functioned. I contacted HighPoint but they reported that they are no longer supporting the RocketRaid 1640 with newer Linux Kernels.So without installing an older operating system supported by the RocketRAID drivers I can no longer access my files! Whilst I admit I cannot expect HighPoint to support old hardware forever, this eventuality was unexpected and I was a little shocked! I needed to resolve this problem and fast, so that I...A blast from the pasttag:www.adamretter.org.uk,2009-04-22:/blog/entries/my-first-serious-code.xml2009-04-22T12:30:00.000+01:002009-04-22T12:30:00.000+01:00Adam RetterRecently I had been unpacking some boxes of older and more obscure belongings that I never felt the need to unpack, I have moved house twice since 2004 and these boxes have only just been unsealed! Whilst looking through the contents, I found some old 3.5” floppy disks and low density ones at that – wow! One of those disks turned out to contain the code for something called “SM~ART”, which made me feel very nostalgic; although for the life of me I cant remember what the acronym stands for!SM~ART was quite possibly the first serious project that...XML Prague 2009tag:www.adamretter.org.uk,2009-03-30:/blog/entries/xml-prague-2009.xml2009-04-01T20:16:00.000+01:002009-03-30T22:51:00.000+01:00Adam RetterI attended the XML Prague conference again this year; it was great to go back again after it took a break last year. Personally, I think this was probably the best one yet, with excellent content all round.This is the third time I have attended, but it was the first time that I have had any input into the conference outside of my involvement in eXist.I presented a poster on EXQuery at the conference, a project I have had in mind for some time for creating standards for XQuery Application Development. I registered for this just one month before the conference! This meant an immense rush to get the EXQuery website content up to scratch as well as designing my poster, slide and handouts. However my efforts came to fruition, as whilst the poster itself received little attention, my known attendance regarding EXQuery facilitated many useful conversations with great members of the XML community; I was even able to recruit Priscilla and Florent to participate in the EXQuery core team! All of the feedback I received from everyone I spoke to was overwhelmingly positive and encouraging :-)Other highlights from the conference for me included -At last we can now do all the things with XML Schema that we need to without having to resort to a two step validation approach with XML Schema as the first step and some other constraint processing mechanism as the second step; personally I have been using XQuery here, but...