Thank you, Mike. That explanation is perfectly reasonable; this handling certainly meets the stated intention.
Joe On Sat, Apr 14, 2018 at 2:58 PM Michael Kay <m...@saxonica.com> wrote: > As always with "why?" questions, it's difficult to know what kind of > answer you want, between > > (a) Where does the spec say this should happen? > > (b) Why does the the spec say this should happen? > > and (b) breaks down to either > > (b1) Why would this be a reasonable choice for the spec-writers to make? > > (b2) As a matter of historical record, who proposed that it should be like > this and what justification did they put forward? > > Regarding (a), the spec says: > > <quote> > Each item in the supplied sequence is serialized individually as follows, > with an occurrence of the chosen item-separator between successive items. > </quote> > > I think it's a reasonable reading of that that adaptive(S) == > string-join(S!adaptive(.), item-separator), which leads to the conclusion > that the serialization of () is "". > > Regarding (b2), my main recollection of relevant discussions concerns > streamability: specifically, it should be possible to serialize each item > independently without knowing what follows. But if someone had proposed > serializing () as "()", I don't think that could really have been opposed > on streamability grounds. But I don't think anyone proposed it. > > Regarding (b1), the main clue about the WG's thinking is the sentence > > <quote> > The intention of this is to allow any valid XDM instance to be serialized > without raising a serialization error. > </quote> > > So you find that the adaptive method focuses on how to serialize cases > that otherwise would fail. Serializing the empty sequence wouldn't > otherwise fail, so I guess it didn't receive much attention. Whether a > proposal to serialize () as "()" would have been accepted is anyone's guess. > > Michael Kay > Saxonica > > > > On 14 Apr 2018, at 19:14, Joe Wicentowski <joe...@gmail.com> wrote: > > > > Hi all, > > > > Many thanks, as always, for the very helpful feedback here. > > > > I have noticed that Saxon, eXist, and BaseX all serialize the empty > sequence `()` not as `()` but instead as the empty string ``. Sample code: > > > > serialize((), map { "method": "adaptive" }) > > > > I was expecting to see `()` because when serializing a map entry, the > empty sequence is serialized as `()`: > > > > serialize(map { "test": () }, map { "method": "adaptive" }) > > > > This returns `map{"blah":()}`. > > > > Can anyone enlighten me on why the empty sequence is serialized as `()` > in the latter context and the empty string in the former? > > > > Thanks, > > Joe > > _______________________________________________ > > talk@x-query.com > > http://x-query.com/mailman/listinfo/talk > >
_______________________________________________ talk@x-query.com http://x-query.com/mailman/listinfo/talk