Mapping Content Type schema, SPContenttype object and MOSS GUI

April 24th, 2008 by weerda

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

April 15th, 2008 by weerda

 

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 12TemplateFeatures 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

April 14th, 2008 by weerda

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

April 7th, 2008 by weerda

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 FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEXML";

 

        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

April 6th, 2008 by weerda

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.commossfeaturegenerator

Alfred 

 

 

 

 

 

 

Sneak preview MOSS Feature Generator 0.7

March 27th, 2008 by weerda

The next version of the MFG will contain a Treeview of the features you generate, with their properties. The features will be linked automatically when you drop them into the treeview. In this way, I hope to enable you to create a set of related features (ContentTypes based on Fields, ListInstances based on ListTemplates etcetera) with ease. 

 

Since I have not been posting new updates, it seemed good to give you a preview what is to come soon. Other updates will be the support of ListInstances and the seperation of Logical elements from their features, which give a greater deal of control on how the feature.xml, elements.xml and schema.xml-files are generated.

 For the current version of the MFG, see CodePlex.

Alfred

 

 

 

Combining the MOSS Feature Generator with WSPBuilder

March 16th, 2008 by weerda

The  MOSS Feaure Generator is very well suited to be used with the WSPBuilder. One using both in a combination, you can get from zero to solution packaged feature in minutes. All you need to do is generate the features in the directorystructure required bij WSPBuilder. You can find both at CodePlex:

 http://www.codeplex.com/wspbuilder

http://www.codeplex.com/mossfeaturegenerator

Alfred

 

 

MOSS Feature Generator to codeplex

March 8th, 2008 by weerda

Hi,

 I moved application and the Visual Studio solution to CodePlex, here: 

MOSS Feature Generator

Alfred 

 

Professionalizing the work of Power Users: another use case for the MOSS Feature Generator

March 2nd, 2008 by weerda

One of the problems you face when setting up a MOSS 2007 product line concerns the MOSS Power User. In a traditional environment, software comes from the development team, or is unsupported. In a MOSS environment however, it is not allways possible to be as rigid as this, since Power Users have been explicitly given the possibility to create list, content types etcetera. From a business perspective, this is a great virtue.

For developers however, the artifacts of Power Users may prove to be an issue of concern, for instance because they lack structure (columns that should be the same are re-created for each lists, preferably each of them slightly different, things like this). One strategy is to let the artifacts of Power Users be unsupported, until there is some formal business demand to support it. From this point on, the development team will create its own version of the artifacts, which have the required quality, and which can from then on be deployed like features (or site definitions, if need be).

The MOSS Feature Generator can be used in this scenario as well, because it grabs the List instances, and makes a ListTemplate and List Instance Feature of it, which can tailored if necessary. The same goes for Content Types and columns. So it is not only suited for creating Features in a structured manner, but it can also be used to make features out of the work of Power Users. In this way, the business knowledge of the Power Users is combined with the quality software engeneering of developers. Offcourse, when tried in a real world scenario, it will not be as easy as this. I think it will have to go this way, however.

Alfred 

 

 

 

 

 

 

 

Visual Studio Solution for MOSS Feature Generator

February 29th, 2008 by weerda

As I promised in my previous post, I added the Visual Studio solution of the MOSS Feature Generator. This contains the code for the list template generator as well as the code that was previously contained in the CTFC (Content Type Feature Creator). In my next post, I will add Feature Creation for List Instances. I then plan to do a little reengeneering, so that you can yourself decide if you wish to create Columns, ContentTypes, ListTemplates and ListInstances in one, or in several features. I'll also be extending the customization of the feature. The attachment shows up only if you select the post itself.

Alfred