This is a place to record my journey with SharePoint. I realized that I was learning a lot of stuff that other people would probably like to know about (and that I would like to refer back to... I'm getting kinda old and my memory is fading.)

Friday, May 2, 2008

Problems with XMLNS and SPWebConfigModification

Recently I posted an article that discussed the SPWebConfigModification.  I meant to add some information about problems with XML Namespaces and SPWebConfigModification.

One of the first problems my team encountered with SPWebConfigModification was failures when working with configuration settings that overrode the default xml namespace (xmlns).

The problem arose when we tried to apply the webconfig modifications needed to for the Enterprise Library.  Below is a sample entry from the configuration settings needed for Enterprise Library.  Notice how the default xmlns is being overridden.

<enterpriselibrary.configurationSettings applicationName="NewsApplication" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration" />



That one statement invalidates the XPath expressions in the SPWebConfigModification Name and Path properties.  This means that SPWebConfigModification cannot successfully find the entry when it scans the web.config file.  So every time the web.config file is modified by SPWebConfigModification the entry gets duplicated (which causes the web.config file to be invalid).



A little research into the way .Net Framework handles XML namespaces turned up the XmlNameSpaceManager class.  This class is used to define namespaces at runtime. 



Unfortunately SPWebConfigModification does not expose this class when defining the XPath expressions.  If it did it would be possible to work with XML namespaces.



By the way, the team was able to work around the enterprise library configuration problem by moving the EntLib configuration settings into separate files.



0 comments:

Subscribe to my Blog

Blog Archive

About Me

My Photo
Jeff Dalton
I have been in IT for the past 16 years working with many different technologies and in many different roles. Today my main focus is on moving a CMS 2002 / SharePoint 2003 solution to SharePoint 2007.
View my complete profile