Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT: How to check if certain nodes are all equal in one parent
    text
    copied!<p>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". </p> <p>It really doesn't matter what to print. I am just trying to find the right logic for it.</p> <p>Here is my sample XML:</p> <pre><code>&lt;root&gt; &lt;class name="Physics"&gt; &lt;student&gt; &lt;firstname&gt;John&lt;/firstname&gt; &lt;lastname&gt;Doe&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;student&gt; &lt;firstname&gt;Mary&lt;/firstname&gt; &lt;lastname&gt;Doe&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;student&gt; &lt;firstname&gt;Ralph&lt;/firstname&gt; &lt;lastname&gt;Doe&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;/class&gt; &lt;class name="Math"&gt; &lt;student&gt; &lt;firstname&gt;John&lt;/firstname&gt; &lt;lastname&gt;Doe&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;student&gt; &lt;firstname&gt;Mary&lt;/firstname&gt; &lt;lastname&gt;Doe&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;student&gt; &lt;firstname&gt;Tee&lt;/firstname&gt; &lt;lastname&gt;Rex&lt;/lastname&gt; &lt;age&gt;21&lt;/age&gt; &lt;/student&gt; &lt;/class&gt; &lt;/root&gt; </code></pre> <p>Therefore, for Physics class it would print "all lastnames are same". And for math class, it would print "all lastnames are not same".</p> <p>(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)</p> <p>Any help will be greatly appreciated.</p> <p>regards, Shobhit</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload