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 isn’t
really a thing in XPath 1, but I’d have to review).
For the 3rd you’re 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(_at_)syr(_dot_)edu
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Date: Wednesday, December 8, 2021 at 8:53 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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? I’m 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-hva7r7LEqncbg1Vfre7mfXUpvH8QMibW-rSpcM51kwIVuyRw$>
Syracuse University Libraries
222 Waverly Ave
Syracuse, New York 13244
t 315.443-2081 | e
mrrothen(_at_)syr(_dot_)edu<mailto:mrrothen(_at_)syr(_dot_)edu> | 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-rSpcM51lkPU8LIA$>
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsub/xsl-list/3453418__;!!N4vogdjhuJM!TB8ih82beNedEJQgxfbOA-hva7r7LEqncbg1Vfre7mfXUpvH8QMibW-rSpcM51kMJbPOKQ$>
(by email<>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--