Hi Christian,

I actually quite like the adaptive serialization method and have made it
the default in eXide.  From my perspective in teaching XQuery, showing an
xs:string item in quotes (and integers sans quotes) helps reinforce the
concept of data types.  It feels to me like a datatype-sensitive view of
results, rather than a debug method.  Besides string handling, though, are
there other aspects of "adaptive" that you dislike compared to the default
"basex" method?

Have you considered adding a preference or toggle for selecting the default
serialization method used in the GUI's results?  For
comparison/inspiration, you might see the screenshots of the serialization
method dropdown and indent checkbox I added to eXide:
https://github.com/wolfgangmm/eXide/pull/168#issuecomment-307592370 - which
in my mind makes eXide quite a powerful for quickly experimenting with
different serializations of results - a particularly time-saving feature
given how verbose the boilerplate is for specifying serialization methods.

Joe

On Thu, Aug 10, 2017 at 5:04 PM, Christian Grün <christian.gr...@gmail.com>
wrote:

> Hi Joe,
>
> Thanks for the link. So I noticed that you were quoting exactly the same
> phrase of the spec as I did. ;)
>
> I just checked what Saxon does: It seems to ignore the value of the indent
> parameter when serializing arrays with the adaptive method.
>
> So I guess that every implementation of XQuery 3.1 serializes arrays
> slightly differently, and the spec is probably too fuzzy to give a more
> precise answer.
>
> In general, I would have been happy if the adaptive method had been
> renamed to 'debug', and if another method had been added to the spec that
> is similar to our custom 'basex' method (which allows users to serialize
> all items – including maps, arrays and attributes – in a flavor that does
> not look like debugging output). In fact the initial version of the
> 'adaptive' method was more similar to ours (for example, strings were
> output without quotes). It changed a lot over the time, and we eventually
> decided to include a custom method.
>
> Well, it’s easy to ask for new features, and much more demanding to write
> specifications that satisfy everyone.
>
> Christian
>
>
>
>
> Am 10.08.2017 9:52 nachm. schrieb "Joe Wicentowski" <joe...@gmail.com>:
>
> Hi Christian,
>
> Thanks for your reply.  I agree that the spec is not entirely clear here,
> but my understanding of the spec was based on the interpretations advanced
> by Michael Kay and Liam Quin on this xquery-talk thread about the question
> of indentation under the adaptive method:
>
>   http://markmail.org/message/dixi7e7qq2ttde74
>
> Joe
>
> On Thu, Aug 10, 2017 at 1:37 PM, Christian Grün <christian.gr...@gmail.com
> > wrote:
>
>> Dear Joe,
>>
>> Thanks for the kind feedback. I am glad to hear BaseX was useful in
>> your DH 2017 workshops.
>>
>> > the serialization spec notes that the adaptive method delegates the
>> handling
>> > of the "indent" parameter to JSON.
>>
>> Could you possibly point me to this rule in the spec? I remember there
>> was a lot discussion about the adaptive serialization method in the W3
>> Working Group. As it was difficult to define rules that cover
>> requirements of all members, the initial version differs quite a lot
>> from the final proposal, and various details were left to the
>> implementation (because it was assumed that the method will mostly be
>> used for debugging). I looked up the final version serialization spec
>> [1], which states in 10.1.4 that:
>>
>>   “The indent and suppress-indentation parameters are
>>   not directly applicable to the Adaptive output method.”
>>
>> In BaseX, the parameter is considered indeed when serializing maps and
>> arrays (and other data types as well), but there are various
>> differences between the two serialization methods. Consider the
>> following example (which should also work with other XQuery
>> processors):
>>
>>   xquery version "3.1";
>>   for $method in ('adaptive', 'json')
>>   return (
>>     "METHOD: " || $method,
>>     "OUTPUT: " || (
>>       try {
>>         serialize(
>>           map { 'functions': [ false#0, true#0 ]},
>>           map { 'method': $method }
>>         )
>>       } catch * {
>>         $err:description
>>       }
>>     )
>>   )
>>
>> The adaptive can be used to serialize items of any type, whereas the
>> json method is restricted to types that can be represented in JSON.
>>
>> Does this help?
>> Christian
>>
>> [1] https://www.w3.org/TR/xslt-xquery-serialization-31/#ADAPTIVE_INDENT
>>
>>
>>
>> On Thu, Aug 10, 2017 at 4:35 PM, Joe Wicentowski <joe...@gmail.com>
>> wrote:
>> > Hi all,
>> >
>> > First, I'm just back from DH2017, where Clifford Anderson and I taught
>> two
>> > workshops on XQuery using BaseX, along with eXist and Saxon.  BaseX
>> > performed like a champ.  We were able to configure the GUI window to
>> show
>> > just the query and results windows—perfect when you're projecting the
>> screen
>> > in a large room and want everyone to see.  Many thanks for such a great
>> > teaching tool!  (Our materials are at
>> > https://github.com/CliffordAnderson/XQuery4Humanists.)
>> >
>> > Back to the topic of this post, though, I noticed a slight difference
>> > between BaseX's serialization of arrays when using JSON vs. adaptive
>> > methods: with JSON, the array's items are separated by newlines, whereas
>> > with adaptive, the items are separated by spaces.  This is interesting
>> since
>> > the serialization spec notes that the adaptive method delegates the
>> handling
>> > of the "indent" parameter to JSON.  Some code to reproduce this is
>> below.
>> >
>> > I'm curious to know - is there a particular reason for this difference?
>> >
>> > Thanks,
>> > Joe
>> >
>> >
>> > serialization-test.xq
>> > ```xquery
>> > xquery version "3.1";
>> >
>> > declare namespace output="http://www.w3.org/2010
>> /xslt-xquery-serialization";
>> > let $array := ["Cheapside","London","Dean Prior","Devon"]
>> > for $method in ("json", "adaptive")
>> > let $serialization-parameters :=
>> >   <output:serialization-parameters>
>> >     <output:method>{$method}</output:method>
>> >     <output:indent>yes</output:indent>
>> >   </output:serialization-parameters>
>> > return
>> >   fn:serialize($array, $serialization-parameters)
>> > ```
>> >
>> > serialization-test_results.txt
>> > ```txt
>> > [
>> >   "Cheapside",
>> >   "London",
>> >   "Dean Prior",
>> >   "Devon"
>> > ]
>> > ["Cheapside", "London", "Dean Prior", "Devon"]
>> > ```
>>
>
>
>
>

Reply via email to