Discussion:
[Exist-open] xmld:collection-available() error
Jeffrey C. Witt
2017-07-13 13:54:29 UTC
Permalink
I'm trying to us xmld:collection-available() to check if collection exists.

If the collection doesn't exist I hope to then create the collection before
saving the new file.

But when running xmld:collection for a non-existent collection I get the
following error:

ERROR Could not locate collection:
/db/apps/scta-data/lombardsententia/pl-l2d17c4/

I don't quite understand this error, since my expectation was that this
function would be checking to see if the collections exists. If it doesn't
exists, it should return false rather than return an error.

Any help is much appreciated. Below is the relevant block of code.

if (xmldb:collection-available($new-save-path)) then(
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
)
else(
<div>
<p>{xmldb:create-collection("/db/apps/scta-data/" ||
$top_level_collection, $new-save-path)}</p>
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
</div>
)
--
Dr. Jeffrey C. Witt
Philosophy Department
Loyola University Maryland
4501 N. Charles St.
Baltimore, MD 21210
www.jeffreycwitt.com
Joe Wicentowski
2017-07-13 14:45:28 UTC
Permalink
Hey Jeff,

It looks like the xmldb:create-collection() function is triggering the
error, rather than the xmldb:collection-available() function. I'd suggest
walking through the variables here to ensure they contain the correct
values. For example, you check whether the collection $new-save-path
exists; if not, you create a collection $new-save-path inside
"/db/apps/scta-data/" || $top_level_collection. This looks to me like
you're checking whether collection /db/A, and if it doesn't, you're
creating /db/X/A instead of /db/A.

Also, does $new-save-path contain slashes? If so, you'll need to create
each of its constituent subcollections one at a time. For example code,
see the local:mkcol() and local:mkcol-recursive() functions at
https://github.com/wolfgangmm/eXide/blob/develop/pre-install.xql#L14-L28.

Joe
Post by Jeffrey C. Witt
I'm trying to us xmld:collection-available() to check if collection exists.
If the collection doesn't exist I hope to then create the collection
before saving the new file.
But when running xmld:collection for a non-existent collection I get the
ERROR Could not locate collection: /db/apps/scta-data/
lombardsententia/pl-l2d17c4/
I don't quite understand this error, since my expectation was that this
function would be checking to see if the collections exists. If it doesn't
exists, it should return false rather than return an error.
Any help is much appreciated. Below is the relevant block of code.
if (xmldb:collection-available($new-save-path)) then(
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
)
else(
<div>
<p>{xmldb:create-collection("/db/apps/scta-data/" ||
$top_level_collection, $new-save-path)}</p>
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
</div>
)
--
Dr. Jeffrey C. Witt
Philosophy Department
Loyola University Maryland
4501 N. Charles St.
Baltimore, MD 21210
www.jeffreycwitt.com
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
https://lists.sourceforge.net/lists/listinfo/exist-open
Jeffrey C. Witt
2017-07-13 15:10:00 UTC
Permalink
Hi Joe,

I don't know about that because if I replace the command in the else
statement a simple print out like
else(
<p>Collection not available: {$new-save-path} {$new-file-name}</p>
)

I get the same error.

But i'll definitely do as you suggest and work back through these variable
and adopt the local:mkcol functions suggested above.

Thanks.
jw

jw
Post by Joe Wicentowski
Hey Jeff,
It looks like the xmldb:create-collection() function is triggering the
error, rather than the xmldb:collection-available() function. I'd suggest
walking through the variables here to ensure they contain the correct
values. For example, you check whether the collection $new-save-path
exists; if not, you create a collection $new-save-path inside
"/db/apps/scta-data/" || $top_level_collection. This looks to me like
you're checking whether collection /db/A, and if it doesn't, you're
creating /db/X/A instead of /db/A.
Also, does $new-save-path contain slashes? If so, you'll need to create
each of its constituent subcollections one at a time. For example code,
see the local:mkcol() and local:mkcol-recursive() functions at
https://github.com/wolfgangmm/eXide/blob/develop/pre-install.xql#L14-L28.
Joe
Post by Jeffrey C. Witt
I'm trying to us xmld:collection-available() to check if collection exists.
If the collection doesn't exist I hope to then create the collection
before saving the new file.
But when running xmld:collection for a non-existent collection I get the
ERROR Could not locate collection: /db/apps/scta-data/lombardsent
entia/pl-l2d17c4/
I don't quite understand this error, since my expectation was that this
function would be checking to see if the collections exists. If it doesn't
exists, it should return false rather than return an error.
Any help is much appreciated. Below is the relevant block of code.
if (xmldb:collection-available($new-save-path)) then(
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
)
else(
<div>
<p>{xmldb:create-collection("/db/apps/scta-data/" ||
$top_level_collection, $new-save-path)}</p>
<p>{$file?status}: {xmldb:store($new-save-path, $new-file-name,
$new-content)}</p>
</div>
)
--
Dr. Jeffrey C. Witt
Philosophy Department
Loyola University Maryland
4501 N. Charles St.
Baltimore, MD 21210
www.jeffreycwitt.com
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
https://lists.sourceforge.net/lists/listinfo/exist-open
--
Dr. Jeffrey C. Witt
Philosophy Department
Loyola University Maryland
4501 N. Charles St.
Baltimore, MD 21210
www.jeffreycwitt.com
Loading...