TSQL- XQuery

  • Hugo Kornelis (7/29/2013)


    I share your antipathy (or should I say hatred?) of XML and XQuery.

    I think "dislike" is perhaps a better word than either of those. In the case of XML, I know that my dislike is irrational because it is based not on the XML definition but instead on all the horrible misuse of XML that has been caused by pundits who have hyped it beyond all reason as a panacea for everything.

    But matter of fact is, it is a part of the product I work with, and it's my professional responsibility to ensure I have at least sufficient working knowledge to handle things if they come up.

    When I was working full time, I shared that view; even now, I have enough knowledge that if I wanted to do a t-d d-f l-to-r data only scan of some XML in T-SQL I would know that @xml_thing.query('data(node)') was something that might do it, so I would know where to start looking.

    Tom

  • L' Eomot Inversé (7/29/2013)


    Hugo Kornelis (7/29/2013)


    I share your antipathy (or should I say hatred?) of XML and XQuery.

    I think "dislike" is perhaps a better word than either of those. In the case of XML, I know that my dislike is irrational because it is based not on the XML definition but instead on all the horrible misuse of XML that has been caused by pundits who have hyped it beyond all reason as a panacea for everything.

    I am a little foggy on this but thought I should throw it out there. I had thought that XML was first built as a dataform to transfer data in an agreed upon schema between two data sharing partners. As such the schema could be very complex and specialized. Some where along the way the idea came to store this probably as an audit train for online transactions. This was due to probably legal requirements to keep the original transactions as they came to the server/service.

    Originally stored as string of data, the parsing and query of the data within the schema was done by the application and simply stored as string data in databases. Then came a new age of enlightenment where data servers no longer saw this data only as strings but as data within data controlled by external knowledge and standardized schema proforma.

    What then was at one point orderly data parsed into the database, became numerous xml fields each acting as a data heap or unformatted data collection that may or may not conform to any published schema. Truly this added security to the use of XML because no one knew what was going on. It also added to the complexity of storing and retrieval of data, let alone the ability to query the data structures within the heap.

    So what once was and really is still today a very nice instrument for carrying data from point a to point b has now become a playfield for those who wish to define their own rules and order, but what does it do the maintainer of the process/database?

    M.

    Not all gray hairs are Dinosaurs!

  • I got it right, but probably only because a year ago I was writing XML parsers.

    A good way to start a week. Thanks, Pramod!

  • Hugo Kornelis (7/29/2013)


    I like the question. I don't think it's a trick question - many people here are so used to using case insensitive collations (stupid defaults!!!) that they can and will be caught by this XML feature. Probably numerous times. I know I have, it's probably the main reason I got it right.

    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 agree Hugo, however, the lack of case insensitivity caught me out. It has made me go and refresh my knowledge about XQuery... Not something I use in my normal day-to-day working life...

  • Great 🙂

  • The trick got better of me. 🙂

  • too much tricky for holidays back

Viewing 7 posts - 16 through 21 (of 21 total)

You must be logged in to reply to this topic. Login to reply