Friday 28 May 2010

MarkLogic: XQuery - dateTime intervals for date ranges

It's a simple requirement, but if you want to calculate date ranges using XQuery, this is the general format:

The time and date seven days ago:

The time and date seven days ahead:

Thursday 27 May 2010

GIT: Rough notes on merge issues

I tried this:

And saw this:

So I did this:

And saw this:

Then I did this again:

And it updated (pulled) successfully.
Then I was able to do this:

Which showed something like this:

As I knew my last changes that were "stashed", this showed me a list of all the changed files currently stashed:

Then I was able to retrieve some changes from one of the stashed files by doing this:

Followed by:

Thursday 20 May 2010

MarkLogic: XQuery - Notes on Return Types

Here are some brief notes and examples of specific return types in XQuery:

local:gen-string returns an xs:string. Not that uncommon, although I include this example here to demonstrate another way to concatenate in XQuery; this is something I often use with xdmp:log statements:

Functions which write elements and attributes can be tasked to return those specific types, like so:

However, as elements and attributes are nodes, it's also possible to make a function which returns a node(). This example will return an element containing one attribute:

In the above example, you could also return the content as an element(), but there are definite places where returning an element can be very useful. This example demonstrates a function which returns an element with a given name (which I've rather unimaginatively named 'blah' for this example).

Such an example may be useful for situations where you really want to be specific about the kind of content a function can return:

Example usage:

Finally, here's an example of a function which returns another specific type of node: a document-node() representing a document which is stored in the database:

Example usage:

Friday 14 May 2010

RedHat: Unpacking an .rpm file

This is the syntax:

Thursday 6 May 2010

MarkLogic: Gathering information about a forest

Here's a very simple example of how you can get to specific information regarding a given forest in your database. Here we're interested in returning the document count (number of documents) in two forests and returning the results in some simple XML:

Which can also be expressed as: