Archive

Archive for November, 2007

WSS 3.0 (MOSS/SharePoint), Site Collections, and Server.MapPath

November 15th, 2007

One of my current projects is a Commerce Server/MOSS 2007 integration project.  I had the need to know where to store the configuration of a sub-site within a site collection of the main web application.

For those of you familiar with ASP.NET 2.0, you know that if you want to find the root of the application, you use Server.MapPath.  Turns out the the root directory (~/) and the bin directory (~/bin — typically) are the same as the parent site.  This means that if your sub-site needs to read information from the web.config then you can store it in the web.config of the parent application.

There is one downside to this.  If you have multiple instances of the same site definition within the same web application, there is no way to separate values within the web.config.  As an example, assume you need to email an administrator when a site experiences a problem but the administrator is different for each subsite.  This information cannot be stored in the web.config as both subsites in the site collection will share the configuration.

This may not be news to some, but without years of SharePoint/WSS experience I found this important to share.

andy Commerce Server, Development, SharePoint

XML Validation

November 3rd, 2007

I just recently had to convert a DTD from UPS into an XSD as part of a Commerce Server integration project. Wanting to test my code (imagine that), I needed to validate both the XSD and sample XML against it. To create the schema I used dtd2xsd available on GotDotNet — looks like MS got stuck holding this open for a bit.

I then needed to create a couple small tools to test the output. Ok, I didn’t NEED to do it, but I love to write tools and they help me procrastinate. Anyway, after a couple of tweaks to the generated schema to solve a UPA problem I validated that the schema was valid and could be used to reliable validate the XML. The benefit of the schema is that I can generate the classes to handle this data using xsd.

If anyone is interested in the tools, they are simply two .NET 2.0 console applications that were based on samples available online. I’ve attached the binary versions to this post but if you want the code feel free to disassemble them.

Validate.zip

andy Uncategorized