mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
Rendering lists in XML may produce unexpected results #151
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jsundin on GitHub (Apr 28, 2024).
This was discovered during evaluation, and is not a case we actually need supported. It does feel unexpected and just thought it was worth mentioning.
Given the following
example.pklfile:We can produce the following json file:
However, when we try to produce the XML representation of this we get:
This does seem unexpected and prone to mistakes, as it has a completely different meaning. There are tests expecting this behaviour, for example input and output.
The following XML could be the expected behaviour for me in this particular case. But honestly, lists and XML can be tricky. How would you deal with
adminIdList = nullin this case? And how would that solution compare to that of an empty list?The properties renderer just bails out for this case, which could also be reasonable.
The above has been tested using the following versions:
Pkl 0.25.3 (Linux 5.15.0-1053-aws, native)Pkl 0.26.0-dev+3a31188 (Linux 5.4.0-177-generic, native)@holzensp commented on GitHub (Apr 29, 2024):
The problem here is that the standard representation of a list of things in XML is to write out the elements consecutively. This is actually quite central in the XML spec.
Given
you get
It would be unexpected, at least, to get
It is admittedly awkward that
1,2, and3come out as123, which is "just" becauseIntis a primitive type. That said, if you need repetition of the element tag, or even just line breaks to separate elements of the list, the solution is to useconverters.