in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

MOSS 2007 and Software Product Lines

Hi. My name is Alfred de Weerd. In this blog I will deal with MOSS 2007 and development professionalisation in general. I'm planning to write about subjects like a MOSS product line in general, reusable assets, software factories, processes and the like.

April 2008 - Posts

  • Mapping Content Type schema, SPContenttype object and MOSS GUI

    This post is the first of a small series about the mapping of the representation of the core entities of MOSS. I use this info to make a complete mapping in the MOSS Feature Generator, but I thought it could be useful on its own. This first article is about Content Types, as you might have guessed from the title. Since I strive for completeness, let me know if you think I missed anything (or I'm dead wrong). The actual content is an attached word-file (it is indeed a rather tiny link).

    Most of the property mappings are incorporated in the MOSS Feature Generator. In future versions, all mappings should be part of the MFG. I'm working now on a little restructuring of the code, so that it has become possible to better organize functionalities into features. Supporting this in the treeview has been a bit of a hassle, though. Next issue is keeping all Guids and ID's in sync. To date, this is still a manual operation.

    Note that in the table with the actual mapping, I used existing documentation as much as possible, with some humble annotations of me thrown in, marked with (Alfred).  

    Alfred

  • Creating Features by building a Virtual Site

     

    In this post I'll Show you take how to generate features by First creating a Virtual Site, consisting of all your selected functionality from the original MOSS site. If you have created the Virtual Site, you can create all the features at once, using default settings, or you can generate them one by one ,giving you more control.

    At this time, I have not included a great deal of logic into build process. It is planned for the next version of the MFG. So when you start editing Content Type ID's for example, you'll have to keep them in sync manually when you refer to them from List Templates. 

    Therefore, it is not practical to generate hundreds of features at once. Package them into groups of ten or so.

    If you want to have this information in a slightly more readable version, goto http://www.codeplex.com/mossfeaturegenerator and check out the MFG Quick guide.

     

    The steps to create features from the MOSS GUI:

     

     

    1 From the Main menu, choose Build à Site

     

     

    A form now opens in which to the left a MOSS site will be shown (only Site Columns, Content Types, List Templates and List Instances). To the right, the functionalities you selected for the creation of features is shown.

     

     

       2 Enter a site Url and click Go. Then select a site.

     

     

     

     

    The functionalities of the MOSS site will now be shown.

     

     

     

    3 Drag en drop the functonalities from the real MOSS site to the Virtual Site, consisting of all the features you select.

     

     

    You may now inspect the properties of the functionalities.

     

     

    4 If you want to change properties, dubbelclick an item, and an appropriate properties screen will open. This is the same screen as when you create a functionality directly from a MOSS site.

     

    5 If you wish to change the properties of the feature.xml, press, Specify Feature. A form will open, allowing you to specify properties for this specific feature.

     

    6 Create a single feaure by adjusting the path and pressing the Create Feature. If you create a 12\Template\Features directory structure, you can use

    WSPBuilder afterwards.

     

    7 When you wish to create all the features at once, specify the path and press Create Features on the main form.  Note that when you create features in this way, you will be prompted with a form allowing you to specify a feature file for the combined Site Columns. The program cannot deduce the properties for this file from the collection of site columns.

     

    8 If there are any XSD Validation Errors, the Show Schema Validation Errors button will be available.

     

    9 By pressing the Show Schema Validation Errors button, you may open a form containing info about the validation errors.

     

     10 You now have your generated Feature.xml, Elements.xml, Schema.xml and your Forms and Views on the ListTemplates.

     

    11 Your original functionality gets reproduced when you install and activate the features.

     

     

  • MOSS Feature Generator 0.7 released

    Today, the MFG, version 0.7 has been released. It allows you to generate MOSS 2007 Features quickly and accurately, according to the functionality you created by using the MOSS Gui. It generates XML files by reading the properties for the Site Columns, Content Types and List from the object model.

    New features include the creation of MOSS Features with drag & drop from your original MOSS 2007 Site, a better separation between Feature (feature.xml) and functionality (elements.xml, schema.xml, AllItems.aspx, other forms and views), and more control on the properties of features and functionality.

    You can find the MFG at http://www.codeplex.com/mossfeaturegenerator

     

     

     

    Above some figures, to give you an impression. I'll update you soon with a more elaborate description.

     Alfred 

     

     

  • Validating Features against wss.xsd

    When looking on the net for information about validating features against their XSD, I could not find information on how to do this. Now this might be so obvious that nobody takes the bother. Or the existence of the schema files for Sharepoint 2007 is just related to its use on intellisense in Visual Studio, because it is not perfect.

     

    Since I found validating the features not that obvious, and it proved very usefull in the MOSS Feature Generator , I'll show below how it is done.

     

    First, I tried the XmlValidatingReader, but this is obsolete (or at least the methods I used), and the XmlValidatingReader proved very very mild in its validation.

     

    Next, I used an example of Rajdeep Kwatra using XmlReaderSettings. (http://rajkwatra.blogspot.com/2007/06/validating-xml-in-net.html), which I adjusted for the use with Sharepoint. Rajdeep has explained all the Xml bits quite nicely, so I concentrate on some Sharepoint aspects. You need to add the CoreDefinitions.xsd file to the xmlSchema, before the wss.xsd, or you'll get complaints that one of the core definitions cannot be found. Doing so, you'll find that from the Schema.xml of SpFields, unlegal attributes are produced for the field nodes for Lookup types and Person/users. These attributes are WebId, UserSelectionMode, UserSelectionScope and Version. Also, quite a large number of validation errors resulted from the validation of the schema.xml files. I yet have to look into this.

     

    Below is the code I used. xmlPath is the path to the feature.xml, elements.xml or schema.xml file. xsdPath is the path to the folder containing the Sharepoint schema files, typically "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML";

     

            public static void ValidateXml(string xmlPath)

            {

                currentXmlFile = xmlPath;

     

                XmlSchema xmlSchema = XmlSchema.Read(new XmlTextReader(xsdPath+"CoreDefinitions.xsd"),

                    new ValidationEventHandler(validatingReader_ValidationEventHandler));

                XmlSchema xmlSchema2 = XmlSchema.Read(new XmlTextReader(xsdPath + "wss.xsd"),

                    new ValidationEventHandler(validatingReader_ValidationEventHandler));

     

                XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

                xmlReaderSettings.ValidationType = ValidationType.Schema;

                xmlReaderSettings.Schemas.Add(xmlSchema);

                xmlReaderSettings.Schemas.Add(xmlSchema2);

                xmlReaderSettings.ValidationEventHandler += new ValidationEventHandler(validatingReader_ValidationEventHandler);

                using (XmlReader xmlReader = XmlReader.Create(new XmlTextReader(xmlPath),

                        xmlReaderSettings))

                {

                    while (xmlReader.Read()) ;

                }

            }

     

            static void validatingReader_ValidationEventHandler(object sender, ValidationEventArgs e)

            {

                validationErrors.Add(new MFGValidationError(e,currentXmlFile));

            }

     

    I used this code in the MOSS Feature Generator, so that, when you generate features, you can inspect if there are Schema validation errors.  

    Alfred

     

     

  • Generating views for ListTemplates with the MOSS Feature Generator

    While in the testing  process for the upcoming release of the 0.7 version of the MFG, I was actually amazed to see how well rather complex views could be generated.

    I tried to make it as difficult as possible, by created lists with the MOSS Gui, and then creating complicated views. When I say complicated, I mean complicated to make, without the use of a generation tool. With the MOSS Gui, creating a Gant-view or conditional rendering is easy.

    Most notably, I generated the following views:

    • showing all columns(default view)
    • sorted on two columns
    • filtering based on two columns
    • group by two columns
    • showing totals of a column, paging and a different style
    • calendar
    • datasheet
    • gant

     

    showing all columns(default view)

     

    sorted on two columns

     

    filtering based on two columns

     

    group by two columns

     

    showing totals of a column, paging and a different style

     

    calendar

     

    datasheet

     

    gant

     

    Now, that all seemed to work quite well. On the downsite, I also tried to generate a KPI-List, but this didn't function. Lists created with the generated template missed the content types to generate KPI's from, and the option to enable content types was not available. I'll have to look into this.

    The above tests were run with an intermediate version of the 0.7 release, but since the code was not changed on this respect. I think it should work just the same with the 0.6 release. If you do find any problems, bugs, missing functionalitity, please notify me, at my mail adres, or post them at www.codeplex.com\mossfeaturegenerator

    Alfred 

     

     

     

     

     

     


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts