INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to I add extra condition on my xslt count when statement?

How to I add extra condition on my xslt count when statement?

How to I add extra condition on my xslt count when statement?

(OP)
I have a when statement that I would like to add one more condition.
I would like to add CaseParty with an Op='A' to my existing count.
How do I do that?

Here is my xslt when test count statement

CODE --> xslt

<xsl:when test="(count(CaseParty[((ObservedRace/@Op='E') or (ObservedEthnicity/@Op='E')) and (Connection/@Word='RSP')] )>0)"> 

Here is my xml document

CODE --> xml

<Integration>
	<Case>
	     <CaseParty ID="7470">
			<ObservedRace Word="W" Op="E">White</ObservedRace>
			<ObservedEthnicity Word="NH">Non Hispanic</ObservedEthnicity>
			<Connection Word="RSP"/>
		</CaseParty>
		<CaseParty ID="111" Op="A">
			<Connection Op="A" Word="CHD">
				<Description>Child</Description>
			</Connection>
		</CaseParty>
	</Case>
</Integration> 

RE: How to I add extra condition on my xslt count when statement?

If I understand correctly that you would like to count both of the CaseParty nodes in the XML fragment, then use the union operator. The count() function is counting the number of nodes in a nodeset that is described by an XPath expression. If we increase the number of nodes in the nodeset by using the union operator, the count will increase. So, the following is simplified for clarity:

CODE --> XPath

count( CaseParty[condition-1] | CaseParty[condition-2] ) 
The condition you already have would be condition-1, and condition-2 could be simply @Op='A'.

If a node meets both conditions, it is only counted once (this is the nature of a union operation).

The union operator also provides a means to select nodes with different names. or even different types of nodes. You will see the union operator used prominently in identity transforms.

Tom Morrison
Hill Country Software

RE: How to I add extra condition on my xslt count when statement?

(OP)
Thanks for your help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close