Tuesday, June 24, 2008

Today I was working on a class that was returning an XPathDocument representation of an XML document and I needed to save it to a file. I switched the class to return an XmlDocument ... and the reason for that should be obvious from the two code samples below.

Monday, June 23, 2008

I'm building an internal application that needs to load an XML file from the file system into a specific repository path in Textml Server. Here's the method I used within a ContentServer class I created.

The references to various this properties are set in the same class where I get the values from a configuration file for the staging and production servers.

// If there is more than one item, and that first item is // not null or empty, return false. if (err.Length > 1 && !String.IsNullOrEmpty(err[0].ToString())) { // TODO: Log each in the EventViewer return false; } else return true; } catch (Exception ex) { // TODO: Log in the EventViewer return false; }}

I need to do the same into MarkLogic so I'll post that snippet here as soon as it's done.

Sunday, June 15, 2008

Another tidbit I can never remember when I need it. You're working on an ASP.NET website and you have a class that needs to access the Request or Response information, for example. Use HttpContext.Current as in the sample below.

Wednesday, June 11, 2008

MarkLogic doesn't offer a way to do stop words (a/k/a suppression lists a/k/a noise words) by default for various reasons -- and I didn't want to block them from being used in searches -- but I was asked to remove them from consideration when using hit highlighting. Here's the code I used to remove a fixed set of noise words from a user's search string.

let $source-string1 := "The Tragedy of King Lear"let $source-string2 := "The Tragedy OF King Lear These an"let $source-string3 := "The Tragedy of the an of King Lear These of"let $source-string4 := "The of an of"(: Need to handle empty result if all noise words, as in #4 above. :)let $final := remove-noise-words($source-string1, $NOISE_WORDS)return $final