xsl-list
[Top] [All Lists]

Re: [xsl] Select with multiple conditions?

2021-12-08 09:28:53
You seem to be under the misapprehension that "|" is a boolean `or` operator. 
That's not the case: it forms the union of two node-sets.

Node-sets are often used in a context where they are implicitly converted to 
booleans (empty node-set => false, non-empty => true), and in this situation

`boolean( NS1 | NS2 )` means the same as `boolean(NS1) or boolean(NS2)`

which may be how you got confused.

But using "|" with operands that aren't node-sets (your second and third 
examples) is an error.

Michael Kay
Saxonica


On 8 Dec 2021, at 14:53, Michele R Combs mrrothen(_at_)syr(_dot_)edu 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

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/ <http://library-blog.syr.edu/scrc/>
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 <http://scrc.syr.edu/>
SYRACUSE UNIVERSITY
syr.edu <http://syr.edu/>
 
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (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
--~--
<Prev in Thread] Current Thread [Next in Thread>