[xsl] Re: Select with multiple conditions?

Subject: [xsl] Re: Select with multiple conditions?
From: "Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Dec 2021 15:21:36 -0000
Your 2nd and third constructions are not correct, in that they are not going
to do what you intend.

The second option uses | (set union) where you mean OR (logical OR), so you
are effectively creating a sequence of Booleans (although I think that isnt
really a thing in XPath 1, but Id have to review).

For the 3rd youre creating a sequence of one Boolean and three strings, which
will always evaluate to true, and again, may not even be meaningful in XPath
1.

My guess would be that your first option is the most efficient (besides being
the only correct one as written) because it presumably takes advantage of the
selection optimizations an XSLT engine uses for doing basic selection of
elements based on simple predicates like attribute value checks.

Cheers,

E.

_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> |
Twitter<https://twitter.com/servicenow> |
YouTube<https://www.youtube.com/user/servicenowinc> |
Facebook<https://www.facebook.com/servicenow>

From: Michele R Combs mrrothen@xxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wednesday, December 8, 2021 at 8:53 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] Select with multiple conditions?
[External Email]

All three of these constructions appear to be valid (this is xsl 1.0, sorry
for being antiquated!).  Will there be differences in the output?  If not, is
one option better than the others, and if so why?  Im guessing that there
are no differences in output, and that option 3 is better because more
concise.  Am I right?


or statements in the select condition:

<xsl:for-each select="child::*[@level = 'collection']  | child::*[@level =
'recordgrp']  | child::*[@level = 'series'] | child::*[@level =
'subseries']">

or statements inside the node description [ ]

<xsl:for-each select="child::*[@level = 'collection' | @level = 'recordgrp' |
@level = 'series' | @level = 'subseries']">

or statements inside the attribute match

<xsl:for-each select="child::*[@level = 'collection' | 'recordgrp' | 'series'
| 'subseries']">


Michele
+++++++++
Michele Combs | Lead Archivist
Special Collections Research Center
Visit our blog!
library-blog.syr.edu/scrc/<https://urldefense.com/v3/__http:/library-blog.syr
.edu/scrc/__;!!N4vogdjhuJM!TB8ih82beNedEJQgxfbOA-hva7r7LEqncbg1Vfre7mfXUpvH8Q
MibW-rSpcM51kwIVuyRw$>
Syracuse University Libraries
222 Waverly Ave
Syracuse, New York 13244
t 315.443-2081 | e mrrothen@xxxxxxx<mailto:mrrothen@xxxxxxx> | w scrc.syr.edu
SYRACUSE UNIVERSITY
syr.edu

XSL-List info and
archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__
;!!N4vogdjhuJM!TB8ih82beNedEJQgxfbOA-hva7r7LEqncbg1Vfre7mfXUpvH8QMibW-rSpcM51
lkPU8LIA$>
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu
b/xsl-list/3453418__;!!N4vogdjhuJM!TB8ih82beNedEJQgxfbOA-hva7r7LEqncbg1Vfre7m
fXUpvH8QMibW-rSpcM51kMJbPOKQ$> (by email<>)

Current Thread