Re: [xsl] How to select elements containing ARPT but not elements containing APPC_ARPT or ARPT_RMK?

Subject: Re: [xsl] How to select elements containing ARPT but not elements containing APPC_ARPT or ARPT_RMK?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Oct 2022 23:04:35 -0000
On Mon, Oct 24, 2022 at 10:51:42PM -0000, Roger L Costello
costello@xxxxxxxxx scripsit:
> Okay, so this for-loop does the job:
> 
> <xsl:for-each select="//row[tokenize(affected_tables,'; ') = 'ARPT'
> ][normalize-space(column_header)]"> <column_header><xsl:value-of
> select="column_header"/></column_header> </xsl:for-each>
> 
> That for-loop solves a problem. Is the problem a specific instance of
> a general problem?

<xsl:sequence select="//row[tokenize(affected_tables,'; ') =
'ARPT'][normalize-space(column_header)]/column_header" />

presumably does the same thing as your for-each example without the
overhead of creating new element nodes.

If you need a different column header element than the one you have,

<xsl:apply-templates select="//row[tokenize(affected_tables,'; ') =
'ARPT'][normalize-space(column_header)]/column_header" />

<xsl:template match="column_header">
... do the thing
</xsl:template>

Will do so. (Possibly employing modes or parameters, if other things
need to happen to other column_header elements.)

for-each is there to handle two special cases; "I need to change the
context item to each of the members of the selected sequence" and
"conceptually, all of these things happen at the same time".  It's not a
loop. (xsl:iterate is closer to being a loop.)  Trying to comprehend
for-each as a loop is unlikely to be helpful.

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

Current Thread