Re: [xsl] Attribute order recommendations

Subject: Re: [xsl] Attribute order recommendations
From: "Norman Tovey-Walsh ndw@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Aug 2020 08:23:57 -0000
Michael MC<ller-Hillebrand mmh@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> writes:
> Folks,
[b&]
> Have I missed some insightful source/post, or can we discuss the
> benefits of attribute order conventions?

Readability is an important aspect of coding, but Ibve never really
considered having a rigid set of conventions for attribute order.

For things that have names, I always put the name first. Ibd find it
disconcerting, I think, if I had to look past a few attributes to find
the name.

For things that have types (and yes, you should put the types on things
that have types!), I probably put the as="b&" attribute last, unless the
select expression is very long.

This:

  <xsl:variable name="my-name" select="f:f($x)" as="xs:integer"/>

Or this:

  <xsl:variable name="my-other-name" as="xs:integer"
                select="if ($some-condition)
                        then f:f($x)
                        else f:g($x)"/>

(Maybe the rule Ibm following is bput the basb attribute on the end
of
the line that has the bnameb attributeb.)

Ibd probably put other attributes between name and as, but I donbt feel
like the order is critically important. I probably go with an aesthetic
feel for whatbs most readable in the more complicated cases.

Just trying it out, I can imagine writing:

  <xsl:param name="my-name" select="0" required="yes" tunnel="yes"
as="xs:integer"/>

But that line is getting awfully long. Maybe this:

  <xsl:param name="my-other-name" as="xs:integer"
             required="yes" tunnel="yes"
             select="if ($some-condition)
                     then f:f($x)
                     else f:g($x)"/>

But I might at that point start to wonder if btunnelb was getting a
little lost, so maybe:

<xsl:param name="my-other-name" as="xs:integer"
           required="yes"
           tunnel="yes"
           select="if ($some-condition)
                   then f:f($x)
                   else f:g($x)"/>

I guess I do have a strong (subconscious) preference for putting the
name and the type on the same line!

                                        Be seeing you,
                                          norm

--
Norman Tovey-Walsh <ndw@xxxxxxxxxx>
https://nwalsh.com/

> At a certain point, ignorance becomes villainy.

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

Current Thread