The demo I did at Tech Ed 2005, Creating an Outlook Task Add-in Solution with VSTO 2005, went off very well (I ended up receiving the Roku SoundBridge 2000 because of the good evals, so thanks to those who took the time to fill them out!!). Since then, I have been improving the solution, fixing bugs. The tester here, Pallavi, is tough on me in a very nice way! She wants the solution to be pretty sound, and so do I. To that end, I needed to make two key alterations:
1) Make the XPath query for searching my customers.xml case-insensitive
2) Make the XPath query in one of my XSLT's search sub-nodes in a specific way.
Today, I'll mention the first technique. One of the things I love about XML is that it is adaptive yet rigid. You can do amazing things with data and formatting, but the rules are kind of strict. One wrong move in your XPath, and you get bupkis. XML is case-sensitive. Searching XML can be challenging because the source XML may have elements with strings that have upper and lower case. But, the string you are looking for may or may not be cased when it is handed over to you.
In my solution, I solve this by doing two things. First, I convert the string I am looking for to lower case. Then, I use the translate() function to convert any upper-case in the string I will search to lower case. Using the translate() function to convert the element "name" contents to lower-case allows, in effect, a case-insensitive search:
mypath= "/contacts/contact[contains(translate(name, 'ABCDEFGHIJKLMNOPSQRTUVWXYZ', " _
& " 'abcdefghijklmnopsqrtuvwxyz'),'" & customerName.ToLower & "]/."
Tomorrow, I'll show how I use the contains() function to search for a string in all sub-nodes of a given node.
Rock Thought for the Day: I must say, the thought for the day is my Roku freakin' SoundBridge once again. I now can dial up music from my computer...while working in my garage! I am sure to do more projects there now. And, as my patient wife knows: every garage-project is an excuse to buy more tools.
Rock On