views:

5978

answers:

8

Like many other a SharePoint User, I've had to create a custom list definition, after much trouble, I've managed to create one (I Think, let me get through all the errors first), but is there a "basic" schema out there I can start with, or a purpose built editor for Schema.xml generation?

+1  A: 

you could use sharepoint manager to select the list you want the schema for and use that as a template.

Any schema generation would rely on context as the GUIDs for any custom fields will be specific to that SharePoint site collection unless they are installed as part of a previously specified feature (relying on an xml schema having been created already).

SharePoint manager is a good tool for this not because it is specific to this problem, but because it is a very useful way of getting all sorts of information (like schema) out of a SharePoint instance.

Nat
+1  A: 

Hello,

My recommendation, and what will bring you the closest to a final version, is to use the SharePoint web interface, set up your list as you want it, including views, custom columns, etc. Then, save the list as a template.

The .stp file you get is basically just a .cab file with a funny name. Rename to cab and extract the manifest, which will include a nearly ready-to-use schema.xml file for you to use.

What you need to change is the path or setuppath of the list forms. You will find these at the bottom of the manifest.xml file. These forms, if you use the default SharePoint lists, can be set to SetupPath="pages/form.aspx". Here is an example from the custom list forms element:

    <Form Type="DisplayForm" Url="DispForm.aspx" 
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    <Form Type="EditForm" Url="EditForm.aspx" 
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    <Form Type="NewForm" Url="NewForm.aspx" 
SetupPath="pages\form.aspx" WebPartZoneID="Main" />

You also need to update the View path for every view, which should be SetupPath="pages/viewpage.aspx" if using the default forms in your original site.

Note that you need to modify other attributes as well, but if you make sure to follow the wss.xsd schema and that your custom list schema.xml validates to the wss.xsd schema you should be ok.

.b

Bjørn Furuknap
+2  A: 

To create custom list definition I always use some built in list definition as template.
Create new feature then copy schema.xml (maybe some other files also if present) from existing feature and modify schema.xml file directly with some text editor. I don’t have tried any custom editor for that and always get work done with copy-paste and changing attributes values.

Built in list definitions are located in 12 hive as features:

  • Custom List – Features/CustomList/CustList/schema.xml;
  • Document Library – Features/DocumentLibrary/DocLib/schema.xml;
  • Calendar – Feature/EventsList/Events/schema.xml;
  • Use search to find others.
EG
+3  A: 

With the Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions, Version 1.2 comes an application called "SharePoint Solution Generator 2008". This application has some restrictions (the worst is IMO that lookup columns disappear), but it creates the files you need to create i.e. a feature out of an existing SharePoint-List. This includes the schema.xml.

+2  A: 

I always use Gary Lapointes stsadm extensions for extracting that kind of stuff. That is, i create it first using the GUI and then extract lists, content types, site columns etc using the appropriate method.

Check out Garys list of extensions here: http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html

Anders

Anders Rask
A: 

Adding onto EG's answer, if you only want to change the fields attached to an existing list (but leave the views, etc. essentially the same), you'll have to change things in essentially two places: List/MetaData/Fields, and List/MetaData/Views/View/ViewFields.

The Fields section is relatively straight-forward, assuming you follow the documentation.

To get the columns to show up in a given view, you'll have to edit the ViewFields section for a given view. For example, if you have columns named Title, Author, and Publisher that you want to show up in the view, find that view's ViewFields section and edit it as follows:

<ViewFields>
  <FieldRef Name="Title" />
  <FieldRef Name="Author" />
  <FieldRef Name="Publisher" />
</ViewFields>

Those fields (and only those fields) should then display in that view.

Jonathan Schuster
A: 

The big problem with all the schema.xml files that you'd normally copy is that 90% of the code resides within the various view elements. There's an extremely simple solution for this - use one of the default ViewStyles.

Here is a straight-forward, readable minimalistic schema to start with. Read http://mo.notono.us/2009/02/moss-dreaded-schemaxml.html for details. Unless you really, really need to tweak the rendered html, don't bother messing with the view caml:

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Id="{AB426CDE-98F2-432A-B296-880C7931DEF3}"
     Title="Setting" Url="Lists/Setting" BaseType="0"
     FolderCreation="FALSE" DisableAttachments="TRUE" VersioningEnabled="FALSE"
     Direction="$Resources:Direction;"
     xmlns=http://schemas.microsoft.com/sharepoint/&gt;
       <MetaData>
              <Fields>
                     <Field Type="Text" Name="Title" DisplayName="Name" Required="TRUE" />
                     <Field Type="Text" Name="Value" DisplayName="Value" Required="TRUE" />
              </Fields>
              <Views>
                     <View BaseViewID="0" Type="HTML" WebPartZoneID="Main" DisplayName="All Items" DefaultView="TRUE"
                         MobileView="True" MobileDefaultView="False" SetupPath="pages\viewpage.aspx"
                         ImageUrl="/_layouts/images/issues.png" Url="AllItems.aspx">
                           <ViewStyle ID="17"/>
                           <RowLimit Paged="TRUE">100</RowLimit>
                           <Toolbar Type="Standard" />
                           <ViewFields>
                                  <FieldRef Name="Edit" />
                                  <FieldRef Name="Title"/>
                                  <FieldRef Name="Value"/>
                           </ViewFields>
                           <Query>
                                  <OrderBy>
                                         <FieldRef Name="Title"/>
                                  </OrderBy>
                           </Query>
                     </View>
              </Views>
              <Forms>
                     <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
                     <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
                     <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
              </Forms>
              <DefaultDescription>Settings used in the application.</DefaultDescription>
       </MetaData>
</List>
Oskar Austegard
+1  A: 

Myself and Rich Finn have written a tool called SPSource that reverse engineers Lists to List Templates, Content Types and Site Columns. Please check it out at http://spsource.codeplex.com/ there are detailed user guides and webcasts to show you how to use it.

Jeremy Thake