xmld:collection-available() error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

xmld:collection-available() error

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 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

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xmld:collection-available() error

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

On Thu, Jul 13, 2017 at 9:54 AM, Jeffrey C. Witt <[hidden email]> wrote:
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

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xmld:collection-available() error

Jeffrey C. Witt
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

On Thu, Jul 13, 2017 at 10:45 AM, Joe Wicentowski <[hidden email]> wrote:
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

On Thu, Jul 13, 2017 at 9:54 AM, Jeffrey C. Witt <[hidden email]> wrote:
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

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open





--
Dr. Jeffrey C. Witt
Philosophy Department
Loyola University Maryland
4501 N. Charles St.
Baltimore, MD 21210

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...