Jump to content

XQuery search for particular tag, then returning contents of two tags


Recommended Posts

This seems like it may be quite a straightforward query for experienced XQuery people - so forgive me if so. However, I am very much a novice when it comes to XQuery and am having trouble pulling out the information I need.

Basically, I have a large repository of XML files, each of which contains information about a particular book. Each file has an ISBN tag (<isbn>), and some, but not all, files also have a <copyright> tag, giving info about its copyright status.

I want to run an XQuery that searches for all files that include a copyright tag, and then for these files return both the ISBN and also the text contained within the copyright tags.

Secondarily, I'd also like to be able to then search by date (eg all files with a date earlier than Jan 2014, and all files from Jan 2014 onwards etc)

Can anyone help with this? It would be hugely appreciated if so. If more information is required just let me know. Thanks in advance!

Link to comment
Share on other sites

(Continuing to shout into the void...)


I have tried the following query:


for $isbn in //article
where exists ("<copyright")
return (
However, that gives me the following error (red text, bold etc all replicated in original message):

query evaluated in Documents at file::Docs/ as 1.0-ml (cq v4.1-1)

[1.0-ml] SVC-EXTIME: for $isbn in fn:collection()/descendant::article where fn:exists("<copyright") return (fn:string($isbn/isbn/fn:string(.)), fn:string($isbn/copyright/fn:string(.))) -- Time limit exceeded


Stack trace:


line 3:
1: xquery version "1.0-ml";2:3: for $isbn in //article4: where exists ("<copyright")5: return (
xdmp:eval("xquery version "1.0-ml"; for $isbn i...", (), <options xmlns="xdmp:eval"><default-xquery-version>0.9-ml</default-xquery-version><isolatio...</options
Can anyone shed any light on this?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...