Subject: Re: [xsl] How to count the distinct values where elements with missing child are counted as one of the distinct values? From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 26 May 2022 14:33:21 -0000 |
Use count(distinct-values(/test/row/string(transition))) string() applied to an empty sequence returns the zero-length string, whereas atomization applied to an empty sequence returns an empty sequence. Michael Kay Saxonica > On 26 May 2022, at 15:08, Roger L Costello costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Folks, > > The following XML document has two row elements with no transition element and two row elements with a transition element : > > <test> > <row> > </row> > <row> > </row> > <row> > <transition>ABC</transition> > </row> > <row> > <transition>DEF</transition> > </row> > </test> > > I want a count of the number of distinct transition values, where row elements with no transition element are counted as 1. > > So for the above XML document the count should return 3. > > This XPath seems to work: > > count(distinct-values(/test/row/transition)) + count(/test/row[not(transition)][1]) > > But I am wondering if there is a better (simpler, less kludgy) XPath expression? > > /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to count the distinct val, Roger L Costello cos | Thread | Re: [xsl] How to count the distinct, Dimitre Novatchev dn |
[xsl] How to count the distinct val, Roger L Costello cos | Date | [xsl] Not able to render XML in Chr, Joga Singh Rawat jra |
Month |