xsl-list
[Top] [All Lists]

Re: [xsl] Subtle (or not?) Map Processing Bug in XQuery

2022-01-07 12:22:47
Good point about as—I’m OCD about it in XSLT but haven’t gotten there in my 
XQuery yet.

 

But I’m not sure how it would have caught the error in this case as in the bug 
case I’m still providing maps to map:merge(), just the wrong ones.

 

Cheers,

 

E.

 

--

Eliot Kimber

http://contrext.com

 

 

 

From: "Michael Kay mike(_at_)saxonica(_dot_)com" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Reply-To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Date: Friday, January 7, 2022 at 12:11 PM
To: xsl-list <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: Re: [xsl] Subtle (or not?) Map Processing Bug in XQuery

 

 

In my XQuery script I’m building a map from all the image files in a directory 
tree (using BaseX’s file extensions):

 

let $files := file:list($rootDir, true(), ‘*.png’)

let $imageMap := map:merge(
for $file in $files

map:entry(local:getFilename($file), map{‘path’ : $file, ‘keyname’, 
local:getKeyName($file))

)

 

At this point $imageMap is a map where each entry’s value is also a map.

 

Then declare it as such: don't forget the "as" clause. Declaring the types of 
your variables would have caught the bug for you. It would also have made the 
code more readable.

 

Michael Kay

Saxonica

XSL-List info and archive 

EasyUnsubscribe (by email) 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>