[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: simple query regarding the count function
I think what you are looking for is: xsl:value-ofselect=" count(/header/policy/requirement[ldor_requirement_ifa='Y' and (ldor_requirement_code='A21C' or ldor_requirement_code='A50A' or ldor_requirement_code='OTHR')] )"/> You can't use "and" and "or" to combine node-sets, only to combine booleans. Michael Kay > > > > Apologies if this has been asked before, but I am struggling > a bit with what I think should be a fairly straight forward > piece of logic. > > In xsl speak I want to count a number of elements based on 2 > different children having conditions that must be met to take > part in the count. > > According to my actual business example what I want to do is > count the number of requirement elements that have a child > element of ldor_requirement_ifa set to Y and tanother child > element that has to have a requirement code of A21C, A50A or ? > OTHR. The result from the count can only ever be 0,1,2,3 > > I thought this would be quite simple to acheive but I keep > running into an issue when the query within the result set > returns a boolean result which then returns an error. If I > remove everything apart from one test, the count will > evaluate the condition as expected but obviously this is not > what I require. I've gotten close by adding count conditions > for each requirement code but I can't integrate the test on > the ifa node into this condition. > > If anyone is helpful enough to answer my query I would be > most grateful. Some things that you have to aware of, I'm not > using templates, apart from one match condition of root at > the beginning of the template. So any suggestion involving > templates is not going to work unless I drastically rewrite > the stylesheet which I don't want to do. I'm also not able to > change the structure of the xml. > > Thanks, Simon Demler > > > Code snippets below: > > > XSL query > > xsl:value-ofselect=" > count(/header/policy/requirement[ldor_requirement_ifa='Y'] and > > /header/policy/requirement[ldor_requirement_code='A21C'] or > > /header/policy/requirement[ldor_requirement_code='A50A'] or > > /header/policy/requirement[ldor_requirement_code='OTHR'] )"/> > > this works but doesn't include the ifa requirement condition I need. > > xsl:value-of > select="count(/header/policy/requirement[ldor_requirement_code > ='A21C']) + > > count(/header/policy/requirement[ldor_requirement_code='A50A']) + > > count(/header/policy/requirement[ldor_requirement_code='OTHR'])"/> > > > Snippet of xml below > > ? ? ? ? ? ? ? ? <requirement> > ? ? ? ? ? ? ? ? ? ? ? ? <row_id>400020090040001006</row_id> > ? ? ? ? ? ? ? ? ? ? ? ? <parent_id>400020090040001005</parent_id> > ? ? ? ? ? ? ? ? ? ? ? ? <row_type>LDOR</row_type> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_activity_policy_id>40001005</ > ldor_activity_policy_id> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_requirement_category>NB ?</ > ldor_requirement_category> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_requirement_ifa>Y</ldor_requirement_ifa> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_short_description>Med exam > & rest</ ldor_short_description> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_long_description>Please arrange > for the life insured to undergo a specialist medical > examination and resting E.C.G.</ ldor_long_description> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_overridden_long_desc>Please > arrange for the life insured to undergo a specialist medical > examination and resting E.C.G. ? ? ? ?</ldor_overridden_long_desc> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_status>OPEN</ldor_status> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_raised_date>2003-09-16 > 14:41:22.15</ ldor_raised_date> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_completed_date/> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_last_updated_by>PHainesTestUser</ > ldor_last_updated_by> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_carb_id/> > ? ? ? ? ? ? ? ? ? ? ? ? > <ldor_requirement_code>ADDI</ldor_requirement_code> > ? ? ? ? ? ? ? ? </requirement> > ? ? ? ? ? ? ? ? <requirement> > ? ? ? ? ? ? ? ? ? ? ? ? <row_id>400020090040001008</row_id> > ? ? ? ? ? ? ? ? ? ? ? ? <parent_id>400020090040001005</parent_id> > ? ? ? ? ? ? ? ? ? ? ? ? <row_type>LDOR</row_type> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_activity_policy_id>40001005</ > ldor_activity_policy_id> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_requirement_category>NB ?</ > ldor_requirement_category> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_requirement_ifa>N</ldor_requirement_ifa> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_short_description>36(k) - > Details</ ldor_short_description> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_long_description>Answer to > serious illness question 36k not supplied</ldor_long_description> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_overridden_long_desc>Answer to > serious illness question 36k not supplied</ldor_overridden_long_desc> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_status>OPEN</ldor_status> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_raised_date>2003-09-16 > 14:40:56.113</ ldor_raised_date> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_completed_date/> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_last_updated_by>PHainesTestUser</ > ldor_last_updated_by> > ? ? ? ? ? ? ? ? ? ? ? ? <ldor_carb_id/> > ? ? ? ? ? ? ? ? ? ? ? ? > <ldor_requirement_code>A21C</ldor_requirement_code> > ? ? ? ? ? ? ? ? </requirement> > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|