These are the steps I used in order to get the current XQDT milestone running with Eclipse Helios:
1. Install Helios (I tested this with the J2EE edition)
2. Install DLTK 1.0.2 Core Runtime (Locally):
http://www.eclipse.org/downloads/download.php?file=/technology/dltk/downloads/drops/R1.0/R-1.0.2-201002091326/dltk-core-R-1.0.2-201002091326.zip
3. Install the latest Milestone (Locally):
http://developer.marklogic.com/eclipse/xqdt/milestone/0.7.0M2-P2.zip
Thursday 24 June 2010
Wednesday 23 June 2010
MarkLogic: XQuery: performance with Maps
Fastest way to check membership of a specific key-pair within a map:
Monday 21 June 2010
Java: Using Jersey with JAXB to output XML or JSON.
A very brief (and simple) example of the principle behind harnessing Jersey's content negotiation ability whilst taking advantage of JAXB to marshall a bean from a Java Object to XML/JSON:
And the resource:
Testing the resource(s) using curl:
Which would yield:
or:
Which would yield:
And the resource:
Testing the resource(s) using curl:
Which would yield:
or:
Which would yield:
Friday 18 June 2010
MarkLogic: XQuery: hacking the position() - a basic example
I'd been wondering whether there was a way in a FLWOR statement to get the index position. I'd tried a few things that I'd hoped might work but I couldn't find a decent way to get back to the context whenever I got to the return portion of the statement.
It became apparent that in some (not all) contexts, I could rely on this example as a quick (and cheap) workaround:
Yields this:
Update - John Snelson advised me on the correct way to deal with position in XQuery - using for and at when starting the FLWOR statement:
Also worth considering:
And another useful positional trick, suggested by Jason Booth:
It became apparent that in some (not all) contexts, I could rely on this example as a quick (and cheap) workaround:
Yields this:
Update - John Snelson advised me on the correct way to deal with position in XQuery - using for and at when starting the FLWOR statement:
Also worth considering:
And another useful positional trick, suggested by Jason Booth:
Monday 14 June 2010
MarkLogic: XQuery: and / and-not query examples
Structure for a query where the a document is selected based on two attribute values (and):
And to match where they're not the same (and-not):
And to match where they're not the same (and-not):
MarkLogic: XQuery: UNIX Timestamp to xs:dateTime Conversion
A hopefully useful note for anyone in the situation where they need to convert from UNIX time to an XML dateTime()
First, to get a timestamp:
Which should return something like:
In cq/DQ, declare the following function:
Which can be run like so:
And should give you:
The XQuery code was taken (and updated for 1.0-ml) from this module: http://github.com/marklogic/cq/blob/master/lib-xquery.xqy.
First, to get a timestamp:
Which should return something like:
In cq/DQ, declare the following function:
Which can be run like so:
And should give you:
The XQuery code was taken (and updated for 1.0-ml) from this module: http://github.com/marklogic/cq/blob/master/lib-xquery.xqy.
Friday 11 June 2010
MarkLogic: XCC/J: Passing a node() into a Query as an external variable
I'd noticed that the MarkLogic XCC drivers don't appear (at first glance) to allow you to pass an Object as a node() into a query. From a bit of research and some testing, I'd found that it would allow you to pass a String (as an xs:string) as an external variable - and from there - this can be converted into a document-node() using xdmp:unquote()
So if you're using XCC/J with MarkLogic and you want to pass a node() into a Query, here's a brief example of how you could achieve such a thing:
Some example XML:
Some example XQuery:
And putting it all together, one Java class containing everything:
In your MarkLogic ErrorLog.txt, you should something like this:
So if you're using XCC/J with MarkLogic and you want to pass a node() into a Query, here's a brief example of how you could achieve such a thing:
Some example XML:
Some example XQuery:
And putting it all together, one Java class containing everything:
In your MarkLogic ErrorLog.txt, you should something like this:
Wednesday 2 June 2010
MarkLogic: XQuery: Typeswitching based on input "type"
In a previous post I'd created on Function Overloading in XQuery, there has been a brief discussion (so far) on whether you can overload functions based on type.
This was the given example:
Calling:
Throws this:
Which appears to be part of the spec:
http://www.w3.org/TR/xquery/#ERRXQST0034.
Is there a workaround? The only way around this issue that I know of right now is to use a typeswitch:
Calling:
Will give you the expected results - albeit at the cost of having to write (and manage) more code.
This was the given example:
Calling:
Throws this:
Which appears to be part of the spec:
http://www.w3.org/TR/xquery/#ERRXQST0034.
Is there a workaround? The only way around this issue that I know of right now is to use a typeswitch:
Calling:
Will give you the expected results - albeit at the cost of having to write (and manage) more code.
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2010
(43)
-
▼
June
(8)
- XQDT: Notes for installing the current Milestone o...
- MarkLogic: XQuery: performance with Maps
- Java: Using Jersey with JAXB to output XML or JSON.
- MarkLogic: XQuery: hacking the position() - a basi...
- MarkLogic: XQuery: and / and-not query examples
- MarkLogic: XQuery: UNIX Timestamp to xs:dateTime C...
- MarkLogic: XCC/J: Passing a node() into a Query as...
- MarkLogic: XQuery: Typeswitching based on input "t...
-
▼
June
(8)