xsl-list
[Top] [All Lists]

RE: [xsl] Testing if all child nodes match (based on the value of certain elements)

2007-04-23 14:12:31
     <xsl:when test="not( group/person/age != group/person/age ) and
                     not( group/person/sex != group/person/sex )">

That's likely to be quite expensive if it's a large dataset: a better
solution with XSLT 2.0 is

count(distinct-values(group/person/age))==1 and
count(distinct-values(group/person/sex))==1

Perhaps even better, given that you're dealing with siblings, is

not(group/person[age=preceding-sibling::person[1]/age and
sex=preceding-sibling::person[1]/sex])

which also works in 1.0.

But the performance of the different constructs depends on the optimizer, on
the size of the dataset, and also on the probability of the condition being
true.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--