• I answered this question yesterday (as often happens Monday's question was available on Sunday) and didn't see anything in it that needed comment, Then today here piles of comments calling it a trick question. And one sensible comment:

    Hugo Kornelis (7/29/2013)


    I like the question. I don't think it's a trick question

    I agree, it's not. There are things which are case sensitive, and this is one of them so there's no trick here.

    many people here are so used to using case insensitive collations (stupid defaults!!!) that they can and will be caught by this XML feature.

    Some of us expect case insensitivity as the norm, but know that we have to be aware when something is case sensitive. So we don't get caught - at least not after the first time. And when its associated with something else pretty awful - two pretty awful things here: XQuery and XML - and especially when the case sensitivity is itself awful because it's utterly pointless, so that we have three pretty awful things in conjunction, it is memorable because of it's sheer awfulness.

    Probably numerous times.

    No, just once.

    And the second good thing about the question is that it also makes you think about what would have been returned if the case had been correct. I know I was not really sure of that (I'm far from an XML expert!), so I was happy that the lower-/uppercase thing gave me a guaranteed point, and the rest of the question gave me the opportunity to play with the code and see what happens if I change the case - so this has also taught me something about the XQuery data function. (And if I just happen to stumble on it again within a week or so, it might even stick this time).

    I have some vague recollection that "data" means do a top-start depth-first left-to-right traverse of the subtree consisting of the designated node and all its descendants, starting with no data and at each node concatenating the data of that node (if any) to the data accumulated so far (concatenating it to an empty string of data if none has yet been accumulated) and returning the accumulated data with no indication of where the boundaries between the data of one node and another node might be (i.e. totally devoid of structural information). That might actually be wrong, but I don't care because if I need to know I can either play (if I have a SQL Server instance I can play with handy) or look it up (if I have internet access handy) and it's pretty unlikely that I would need to know in any situation where either of those facilities was absent, let alone both. But it's probably about right as it means that if "data" had been spelt right the two XQuerys would have produced the result given as the first wrong answer option, which would make that option a good distractor - another reason not to dislike the question despite its horrible subject matter.

    Tom