Hi folks,
I'm a student working on my bachelor thesis. I use BaseX to read large XML files and forward them to a PostgreSQL database. Additionally I want to fetch images via URI and add them to the database-records.
While fetching these images, I have to test three different file extensions for each image, as my source does not use one single image format (but jpg, png and gif).
First I tried checking with fn:doc-available($uri) weather that certain URI is available, but this obviously only works for XML-documents. Then I wanted to catch the err:BXFE0001 that is thrown by fetch:binary($uri), but this does not work, either; the error-message is displayed and the script stops.
declare variable $itemid := 'sw008';
try {
fetch:binary($baseuri || $itemid || '.png')
}
catch err:BXFE0001 {
try {
fetch:binary($baseuri || $itemid || '.gif')
}
catch err:BXFE0001 {
try {
fetch:binary($baseuri || $itemid || '.jpg')
}
catch err:BXFE0001 {
0
}
}
}
In this example, only the .jpg-image exists. But all I get is
Information:
<HTML><HEAD><TITLE>The page cannot be found</TITLE> … and so on
I would be very glad if you could help me with this, either by pointing out my coding-error or by showing me another, better solution for doing this.
Thank you and have a nice day,
Alex
--
| Alexander von Bernuth