XPATH 2.0 collection() with “?select=” (in eXist-db / XQuery)










0















Using XPath 2.0 in eXist 4.4 and XQuery.



I have a series of documents in eXist-db directory /db/apps/deheresi/data which I want to retrieve with collection(), but using a wildcard or predicate to filter specifically-named documents.



For example, I'd like to get the documents that begin with ABC and end with .xml. I thought a wildcard like so ?select=ABC*.xml would work, but it's not returning the expected results.



collection("/db/apps/deheresi/data?select=ABC*.xml")


I also tried to apply a combination of starts-with and ends-with but to no success. I am no doubt overlooking something simple here.



Thanks in advance.










share|improve this question
























  • You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

    – Martin Honnen
    Nov 12 '18 at 15:11











  • Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

    – jbrehr
    Nov 12 '18 at 15:14











  • As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

    – Michael Kay
    Nov 12 '18 at 17:02











  • @MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

    – jbrehr
    Nov 12 '18 at 17:06











  • You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

    – Michael Kay
    Nov 12 '18 at 17:08















0















Using XPath 2.0 in eXist 4.4 and XQuery.



I have a series of documents in eXist-db directory /db/apps/deheresi/data which I want to retrieve with collection(), but using a wildcard or predicate to filter specifically-named documents.



For example, I'd like to get the documents that begin with ABC and end with .xml. I thought a wildcard like so ?select=ABC*.xml would work, but it's not returning the expected results.



collection("/db/apps/deheresi/data?select=ABC*.xml")


I also tried to apply a combination of starts-with and ends-with but to no success. I am no doubt overlooking something simple here.



Thanks in advance.










share|improve this question
























  • You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

    – Martin Honnen
    Nov 12 '18 at 15:11











  • Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

    – jbrehr
    Nov 12 '18 at 15:14











  • As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

    – Michael Kay
    Nov 12 '18 at 17:02











  • @MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

    – jbrehr
    Nov 12 '18 at 17:06











  • You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

    – Michael Kay
    Nov 12 '18 at 17:08













0












0








0








Using XPath 2.0 in eXist 4.4 and XQuery.



I have a series of documents in eXist-db directory /db/apps/deheresi/data which I want to retrieve with collection(), but using a wildcard or predicate to filter specifically-named documents.



For example, I'd like to get the documents that begin with ABC and end with .xml. I thought a wildcard like so ?select=ABC*.xml would work, but it's not returning the expected results.



collection("/db/apps/deheresi/data?select=ABC*.xml")


I also tried to apply a combination of starts-with and ends-with but to no success. I am no doubt overlooking something simple here.



Thanks in advance.










share|improve this question
















Using XPath 2.0 in eXist 4.4 and XQuery.



I have a series of documents in eXist-db directory /db/apps/deheresi/data which I want to retrieve with collection(), but using a wildcard or predicate to filter specifically-named documents.



For example, I'd like to get the documents that begin with ABC and end with .xml. I thought a wildcard like so ?select=ABC*.xml would work, but it's not returning the expected results.



collection("/db/apps/deheresi/data?select=ABC*.xml")


I also tried to apply a combination of starts-with and ends-with but to no success. I am no doubt overlooking something simple here.



Thanks in advance.







xpath exist-db xquery-3.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 15:16







jbrehr

















asked Nov 12 '18 at 14:47









jbrehrjbrehr

134212




134212












  • You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

    – Martin Honnen
    Nov 12 '18 at 15:11











  • Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

    – jbrehr
    Nov 12 '18 at 15:14











  • As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

    – Michael Kay
    Nov 12 '18 at 17:02











  • @MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

    – jbrehr
    Nov 12 '18 at 17:06











  • You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

    – Michael Kay
    Nov 12 '18 at 17:08

















  • You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

    – Martin Honnen
    Nov 12 '18 at 15:11











  • Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

    – jbrehr
    Nov 12 '18 at 15:14











  • As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

    – Michael Kay
    Nov 12 '18 at 17:02











  • @MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

    – jbrehr
    Nov 12 '18 at 17:06











  • You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

    – Michael Kay
    Nov 12 '18 at 17:08
















You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

– Martin Honnen
Nov 12 '18 at 15:11





You will need to tell us which environment you use XPath 2.0 with, the use of the collection function is not standardized, I am rather sure Saxon 9 for instance supports your attempt of collection("file:///db/apps/deheresi/data?select=ABC*.xml") if /db/apps/deheresi/data is the path to a directory but other processors or environments like XML data bases might have very different conventions to use the collection function.

– Martin Honnen
Nov 12 '18 at 15:11













Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

– jbrehr
Nov 12 '18 at 15:14





Ah, will this is in eXist-db 4.4 and XQuery 3.1. I will update the post accordingly.

– jbrehr
Nov 12 '18 at 15:14













As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

– Michael Kay
Nov 12 '18 at 17:02





As Martin says, the select=*.xml convention is peculiar to Saxon though I believe it has been copied by some other XQuery implementations. But it's not defined in the W3C specs so you can't expect every processor to support it.

– Michael Kay
Nov 12 '18 at 17:02













@MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

– jbrehr
Nov 12 '18 at 17:06





@MichaelKay Are there other XPATH functions or predicate tricks to filter collections on the document name that I might try?

– jbrehr
Nov 12 '18 at 17:06













You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

– Michael Kay
Nov 12 '18 at 17:08





You could try using uri-collection() which gives you a list of all the URIs, and then filter this yourself before retrieving the documents. But I've no idea if that works, or is the best solution, in the context of eXist-db.

– Michael Kay
Nov 12 '18 at 17:08












1 Answer
1






active

oldest

votes


















1














One way of doing this in exist



xquery version "3.1";
(: get document names :)
let $doc-names := for $n in collection('/db/apps/deheresi/data')
return
util:document-name($n)

(: apply filter :)
for $f in $doc-names[matches(., '^ABC.*.xml$')]
return
$f





share|improve this answer























  • Indeed, I did something similar...I was just hoping there was a way do to it without a for.

    – jbrehr
    Nov 12 '18 at 19:01






  • 1





    another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

    – duncdrum
    Nov 12 '18 at 19:05











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264588%2fxpath-2-0-collection-with-select-in-exist-db-xquery%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














One way of doing this in exist



xquery version "3.1";
(: get document names :)
let $doc-names := for $n in collection('/db/apps/deheresi/data')
return
util:document-name($n)

(: apply filter :)
for $f in $doc-names[matches(., '^ABC.*.xml$')]
return
$f





share|improve this answer























  • Indeed, I did something similar...I was just hoping there was a way do to it without a for.

    – jbrehr
    Nov 12 '18 at 19:01






  • 1





    another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

    – duncdrum
    Nov 12 '18 at 19:05
















1














One way of doing this in exist



xquery version "3.1";
(: get document names :)
let $doc-names := for $n in collection('/db/apps/deheresi/data')
return
util:document-name($n)

(: apply filter :)
for $f in $doc-names[matches(., '^ABC.*.xml$')]
return
$f





share|improve this answer























  • Indeed, I did something similar...I was just hoping there was a way do to it without a for.

    – jbrehr
    Nov 12 '18 at 19:01






  • 1





    another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

    – duncdrum
    Nov 12 '18 at 19:05














1












1








1







One way of doing this in exist



xquery version "3.1";
(: get document names :)
let $doc-names := for $n in collection('/db/apps/deheresi/data')
return
util:document-name($n)

(: apply filter :)
for $f in $doc-names[matches(., '^ABC.*.xml$')]
return
$f





share|improve this answer













One way of doing this in exist



xquery version "3.1";
(: get document names :)
let $doc-names := for $n in collection('/db/apps/deheresi/data')
return
util:document-name($n)

(: apply filter :)
for $f in $doc-names[matches(., '^ABC.*.xml$')]
return
$f






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 18:45









duncdrumduncdrum

548310




548310












  • Indeed, I did something similar...I was just hoping there was a way do to it without a for.

    – jbrehr
    Nov 12 '18 at 19:01






  • 1





    another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

    – duncdrum
    Nov 12 '18 at 19:05


















  • Indeed, I did something similar...I was just hoping there was a way do to it without a for.

    – jbrehr
    Nov 12 '18 at 19:01






  • 1





    another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

    – duncdrum
    Nov 12 '18 at 19:05

















Indeed, I did something similar...I was just hoping there was a way do to it without a for.

– jbrehr
Nov 12 '18 at 19:01





Indeed, I did something similar...I was just hoping there was a way do to it without a for.

– jbrehr
Nov 12 '18 at 19:01




1




1





another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

– duncdrum
Nov 12 '18 at 19:05






another way (without for) xmldb:get-child-resources('/db/apps/deheresi/data')[matches(., '^ABC.*.xml$')]

– duncdrum
Nov 12 '18 at 19:05


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264588%2fxpath-2-0-collection-with-select-in-exist-db-xquery%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20