Creating the Form Library
Each time a project manager submits a Technical Manual Creation InfoPath form, a new Document Workspace site is created within the Technical Manual SharePoint site. The library takes its name from the InfoPath form's my:ProductName element.
Figure 1. A Document Workspace site
The function CreateTechManualSite handles the creation of the form library. Within this function the SharePoint site URL is retrieved, and a new list template document library is added to that site. The my:productName and my:Synopsis element values are used as the title and description, respectively. A folder is created within the document library as a means to store the result of the WordML transform.
// Save the Url for the site.
siteUrl = siteUrl;
// Get the document element for the info
XmlNode siteInfo = siteDoc.DocumentElement;
// Create the site/workspace
site = new SPSite(siteUrl);
XPathNavigator nav = siteDoc.CreateNavigator();
XmlNamespaceManager nsm = new XmlNamespaceManager(nav.NameTable);
nsm.AddNamespace("my","http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-02-27T21-50-17");
nsm.AddNamespace("dfs","http://schemas.microsoft.com/office/infopath/2003/dataFormSolution");
// Get the title and the description
newTitle = siteInfo.SelectSingleNode("/dfs:IPDocument/my:TechnicalManual/my:ProductName", nsm).InnerText;
newDescription = siteInfo.SelectSingleNode("/dfs:IPDocument/my:TechnicalManual/my:Synopsis", nsm).InnerText;
// Create the web and list
try
{
web = site.AllWebs[newTitle];
}
catch(Exception webEx)
{
string err = webEx.Message;
}
web = site.AllWebs.Add(newTitle, newTitle, newDescription, (uint)System.Globalization.CultureInfo.CurrentCulture.LCID, "STS#2", true, false);
listTemplate = web.ListTemplates["Document Library"];
// Make sure the list is created with a folder to put the
// doc in
web.Lists.IncludeRootFolder = true;
// Create the list
listGuid = web.Lists.Add(newTitle, newDescription, listTemplate);
// Get the list object reference so we can add the doc
list = web.Lists[listGuid];