Re: [xsl] Does it make sense to collect elements with a certain value then assert that the elements I've collected have that certain value?

Subject: Re: [xsl] Does it make sense to collect elements with a certain value then assert that the elements I've collected have that certain value?
From: "Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Jul 2024 14:58:42 -0000
Hi Roger,

In case you process $nav-records-for-this-airport in another template or
function, then it might be helpful to verify that the provided data matches
the expectation.

But as shown directly following the original selection seems unnecessary.
Unless you consider someone tasked to change the value of that variable and
not looking elsewhere. They will be surprised.

Michael MH

-----Original Message-----
From: Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, July 31, 2024 3:58 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Does it make sense to collect elements with a certain value
then assert that the elements I've collected have that certain value?

Hi Folks,

$airport-id holds the identifier of an airport.

I use $airport-id to collect <row> elements in $airports-nav-records with a
matching ARPT_IDENT:

<xsl:variable name="nav-records-for-this-airport"
                       select="$airports-nav-records//row[ARPT_IDENT eq
$airport-id]"
                       as="element(row)*"/>

Does it make sense to verify that every <row> element in
$nav-records-for-this-airport has an ARPT_IDENT that matches $airport-id? Is
there a benefit to this assert:

<xsl:assert test="every $i in $nav-records-for-this-airport satisfies
$i/ARPT_IDENT eq $airport-id "/>

To my way of thinking, there is no benefit. I collected <row> elements with a
matching ARPT_IDENT, then the assert tests that the collected <row> elements
have a matching ARPT_IDENT. The assert seems
pointless/redundant/useless/wasteful. Am I missing something?

Here's the assert in context:

<xsl:for-each select="$airports/*/row">
        <xsl:variable name="airport-id"
                               select="ARPT_IDENT"
                               as="xs:string"/>
        <xsl:variable name="nav-records-for-this-airport"
                               select="$airports-nav-records//row[ARPT_IDENT
eq $airport-id]"
                               as="element(row)*"/>
        <xsl:assert test="every $i in $nav-records-for-this-airport satisfies
$i/ARPT_IDENT eq $airport-id "/>

Current Thread