For the second time in as many weeks, I have the pleasure of announcing a new open source project. This time I've released Nxdb, a high-performance embedded XML database for .NET with full XQuery support. It is essentially a .NET binding for the excellent BaseX Java XML database. However, Nxdb goes well beyond a simple wrapper by providing a native .NET API suitable for embedding (the primary focus of BaseX is on client/server uses), providing additional functionality to interface directly with .NET classes and objects, and rethinking several aspects of the BaseX design for the embedded use case. The underlying BaseX code is cross-compiled to IL using IKVM making Nxdb 100% native .NET, usable on all .NET platforms including Mono.
Today's post is an XQuery function designed to get a count of the number of week (or work) days between two dates. It's designed to mimic the Excel
NETWORKDAYS function. I got the algorithm from Bernal Schooley in this thread and then adapted it to XQuery. It also makes use of the FunctX
day-of-week function, so if you have FunctX functions already referenced you can take that part out.