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 post
Share on other sites

(Continuing to shout into the void...)

 

I have tried the following query:

 

for $isbn in //article
where exists ("<copyright")
return (
string($isbn/isbn/string()),
string($isbn/copyright/string())
)
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...