From: Joe W. <jo...@gm...> - 2012-03-17 17:05:23
|
Hi Chris, > Thanks again for your help on this, and to Joe for setting up this list for newbies like me. I'm so happy to hear that you, together with Martin and Peter, have found a solution! Since I didn't participate in the discussion (work busy-ness + a bad cold), let me offer some reflections: First, Chris, you're graduating to a really exciting level of XQuery development sophistication. You're putting commonly used application logic into functions and moving those functions into library modules. This isolates the code, centralizes the functions, and makes the code more portable, more reusable, and much easier to test. Your function takes an entire TEI document as an argument, and thus it can be used on any TEI document in your database, now or as you add new documents. If your TEI document structure changes in the future, you only have to modify this one function to ensure your application runs as before. Second, namespaces were central to resolving the problem. My rule is that if I write a query and get nothing instead of the expected result, namespace problems are the cause of the problem 90% of the time. If I check the XPath and the assumptions in the logic, and everything still looks right, that 90% rises to 99%. This isn't to say that namespaces are evil; they're essential, but require annoyingly absolute precision. Third, default namespaces. Declaring a default element namespace can be very handy, particularly if all inputs and outputs are in the same namespace and no elements are in the empty namespace. But in my experience, I often find myself removing such declarations. Declaring TEI or HTML as the default makes it difficult to address empty namespaces ( *:foo is a kludge and not good for performance), and in my applications I almost always mix TEI, HTML, and empty namespaced nodes. But absolutely, do try it out and keep this technique in your arsenal, but I personally find it of use in marginal circumstances. Finally, this list will have its first anniversary in a few months! It'll be an opportunity for us to reflect on what we've learned this year, and on what we can do looking ahead. Thanks and best wishes to you all, Joe |