I am trying to think of a XSL snippet that would check if a class has all the students with the same lastname. It yes, then (do anything like) print "all lastnames are same" else print "all lastnames are not same".
It really doesn't matter what to print. I am just trying to find the right logic for it.
Here is my sample XML:
<root>
<class name="Physics">
<student>
<firstname>John</firstname>
<lastname>Doe</lastname>
<age>21</age>
</student>
<student>
<firstname>Mary</firstname>
<lastname>Doe</lastname>
<age>21</age>
</student>
<student>
<firstname>Ralph</firstname>
<lastname>Doe</lastname>
<age>21</age>
</student>
</class>
<class name="Math">
<student>
<firstname>John</firstname>
<lastname>Doe</lastname>
<age>21</age>
</student>
<student>
<firstname>Mary</firstname>
<lastname>Doe</lastname>
<age>21</age>
</student>
<student>
<firstname>Tee</firstname>
<lastname>Rex</lastname>
<age>21</age>
</student>
</class>
</root>
Therefore, for Physics class it would print "all lastnames are same". And for math class, it would print "all lastnames are not same".
(This is not my real XML because it was irreducible to a smaller problem, so instead I custom made this XML to represent my issue)
Any help will be greatly appreciated.
regards, Shobhit