Hi Markus, you wrote
"How would you determine where unexpected gaps occur?"
Gaps? First, to avoid a misunderstanding: whereas map keys must not be the 
empty sequence, map values may.
An elegant way to construct map entries safely - taking care that the key is 
not empty - is to use the map operator (!) or a path step, in both cases with 
the map:entry() on the right-hand side.
Example, map operator:.
$thingy/@name/normalize-space(.)[string()] ! map:entry(., $tingy/string())
Example, path step:
map:merge(doc('things.xml')//thingy/@name[normalize-space(.)]/map:entry(., 
../string()))

Kind regards,
Hans-Jürgen

    Am Freitag, 27. Mai 2022, 10:51:00 MESZ hat Markus Elfring 
<markus.elfr...@web.de> Folgendes geschrieben:  
 
 > although I do not quite understand your description

Which wording variant would you have found clearer for the mentioned use case?


> (why should I care for the representation of the map I construct?),

* Selection of a general data structure for the handling of key/value pairs

* I guess that you would like to put customised data into keys and associated 
values.


> it may be that one piece of information is useful to you,

Thanks for your constructive feedback.


> as it is not obvious from the spec: it's about how to construct a map 
> dynamically,

Can such a view trigger any further consequences?


> that is, 
>
> (1) when the keys are not known beforehand, 
> (2) and/or when the entry values are assigned in "iterations" of a FLWOR 
> expression
>
> (Especially (2) might be what puzzles you.)

I thought also about this data processing area in special ways for a moment.


> (1) and (2) can't be accomplished when using the map constructor expression, 
> like this: basex "map{'x':1, 'y': false()}" 

Will any information sources help to understand this technical detail better
(besides the XPath function library)?


> The trick consists of using a combination of the functions map:merge() [1] 
> and map:entry() [2].

I became curious how application considerations will evolve further.


> This code may for example be (most often is) a FLWOR expression.
> In this code, each entry is constructed by a call of function map:entry().

Now I stumble on the error message “[XPTY0004] Item expected, empty sequence 
found.”
from my software test according to a special data source.
How would you determine where unexpected gaps occur?

Regards,
Markus
  

Reply via email to