Hi Jonathan, hi Patrick,

The new serialization parameter 'indent-attributes' is already available [1]:

(: provided globally :)
declare option output:indent 'yes';
declare option output:indent-attributes 'yes';
<e a='a' b='b' c='c'/>

(: provided locally :)
serialize(
  <e a='a' b='b' c='c'/>,
  map {
    'indent-attributes': true(),
    'indent': true()
  }
)

Result:
<e a="a"
   b="b"
   c="c"/>

Thank you to Gunther Rademacher, who contributed the code solution!

A new stable snapshot is available [2]. The serialization parameter
may officially be supported with XQuery 4 [3].

Hope this helps,
Christian

[1] https://docs.basex.org/wiki/Serialization
[2] https://files.basex.org/releases/latest/
[3] https://github.com/qt4cg/qtspecs/issues/358#issuecomment-1436595401



On Wed, Feb 15, 2023 at 7:05 PM Jonathan Robie <jonathan.ro...@gmail.com> wrote:
>
> Hi Christian,
>
> I prefer to be able to require one attribute per line.  This is important for 
> Git diffs, which are the main reason we care.
>
> Jonathan
>
> On Wed, Feb 15, 2023 at 11:31 AM Christian Grün <christian.gr...@gmail.com> 
> wrote:
>>
>> Hi Jonathan,
>>
>> Thanks for sharing your tidy settings.
>>
>> With the given configuration, all attributes except for the first are
>> returned in a separate line…
>>
>> <wg class="cl"
>>     rule="S-IO"
>>     cltype="VerbElided">
>>
>> In Patrick’s example, some attributes were returned in a single line
>> (possibly depending on the expected string length). Maybe it was
>> generated via Saxon (just a guess):
>>
>> <wg class="cl" rule="S-IO" cltype="VerbElided">
>>
>> Do you have a preference which representation would be required, or do
>> you think the details are not that relevant?
>>
>> We could possibly add a custom serialization parameter similar to
>> tidy’s 'indent-attributes' option, and it would probably be easier to
>> ignore the expected string length.
>>
>> All the best,
>> Christian

Reply via email to