| Author |
Impossible XPath???
|
Alan Wanwierd
Ranch Hand
Joined: Jun 30, 2004
Posts: 624
|
|
Hi guys - I'm having a compelte nightmare trying to remember XPath!! Im not sure if what I'm trying to do is possible or not... I'm using XPath in a bit of conditional XSL to try and determine whether or not to display a bit a text. Basically I want to establish if there are any other "Employee" nodes in my XML with the same "EmployeeCode" value, but in a different "Section" parent node. the XPath I have at the moment doesnt work: count(../../../Section/Employees/Employee[EmployeeCode=EmployeeCode])> 1 If I just do: count (EmployeeCode) - result is 1 (current node as expected) If I do: count(../../../Section/Employees/Employee/EmployeeCode) - result is 6 (all employees in my sample XML file) If I do: count(../../../Section/Employees/Employee[EmployeeCode=EmployeeCode]) - result in unforunately not 2 (the number of Employees with EmployeeCode same as current node) - but is 6 (presumabely the number of Employee whose EmployeeCode equals itself DOH!!) How do I get a count of all the nodes that match the current one? Obviously my crude attempt at a value match didnt work cos the 2nd "EmployeeCode" still matches ALL the EmployeeCode nodes in the system... thanks for your help!
|
 |
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
|
|
Something like this should work: <xsl:variable name="currentEmployeeCode" select="."/> count (//Employee[EmployeeCode = $currentEmployeeCode])
|
Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
|
 |
Alan Wanwierd
Ranch Hand
Joined: Jun 30, 2004
Posts: 624
|
|
Thanks Map - it worked a treat!
|
 |
 |
|
|
subject: Impossible XPath???
|
|
|