In SharePoint, what is the easiest way to create a custom list 'schema.xml' file?
Asked Answered
P

9

7

Like many other SharePoint users, 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?

Proclaim answered 13/1, 2009 at 23:10 Comment(0)
P
4

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.
Phosphorescent answered 14/1, 2009 at 7:43 Comment(0)
O
4

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

Oblige answered 14/1, 2009 at 1:17 Comment(0)
P
4

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.
Phosphorescent answered 14/1, 2009 at 7:43 Comment(0)
S
3

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.

Scandura answered 14/1, 2009 at 0:6 Comment(0)
P
3

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.

Phonetics answered 14/1, 2009 at 11:10 Comment(0)
C
3

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 in STSADM/PowerShell Commands.

Clovah answered 18/1, 2009 at 20:35 Comment(0)
W
1

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/">
       <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>
Wellborn answered 15/7, 2009 at 16:31 Comment(0)
M
1

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.

Mennonite answered 18/8, 2009 at 13:33 Comment(0)
O
0

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.

Openhanded answered 20/1, 2009 at 15:15 Comment(0)
P
0

Create the list that you want to develop on your local development environment using browser options. Save the site as a template. Download it to the local file system.

Now create a new Visual Studio project with template, import from a solution package. Locate the solution package that is stored on the file system. Now when you see the solution, you will find the list created by you. File schema.XML will be located in the List definition. Copy the Content Type, Fields and Views content and paste it to your schema.xml file.

Pathic answered 4/11, 2011 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.