Another point about this exercise that I'd like to have a greater understanding of is the following line which is used to select distinct values:
CODE
//dog[generate-id() = generate-id(key('dogs',breed)[1])]
An explanation is very simple English would be useful.
As far as I can understand it means:
//dog - selects all dog nodes
[] - the code in between these brackets specifies a condition, such as only use the first node
generate-id() - generates a unique id for the node, in this case the node is the current dog node that is being examined to see if it should be selected or not.
key('dogs', breed) - Uses the key names 'dogs' to select all dog nodes which have the same breed as the current node
[1] - in this case this selects the first of the values returned by the key statement
generate(key...) - generates a unique id for the first dog node returned by the key statement...
I'm still having a little trouble understanding this
- won't each dog node be matched with itself in the [generate id = ...] condition?
If anyone can add anything to help me understand then it would be greatly appreciated....
the more verbose the explanation the better!
Cheers!