内容类型中忽略了XmlDocuments元素?

时间:2010-06-30 22:51:06

标签: sharepoint sharepoint-2010

我有一个在Elements.xml中定义的内容类型,我想添加一个事件接收器。我的Elements.xml看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Announcement (0x0104) -->
  <ContentType ID="0x0104008a424de98660457481eb7d8ddb5161ee"
               Name="News Posting"
               Group="News"
               Description="$Resources:NewsCTypeDescription"
               Inherits="TRUE"
               Version="1"
               Sealed="TRUE"
               >
    <FieldRefs>
      <FieldRef ID="{7EBC5918-CB79-440A-8DF3-480C6951C4EB}" Name="NewsExcerpt"/>
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
        <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
          <Receiver>
            <Name>ItemAdded</Name>
            <Type>ItemAdded</Type>
            <Class>MyAssembly.NewsItemEventReceiver</Class>
            <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
            <SequenceNumber>10000</SequenceNumber>
            <Synchronization>Synchronous</Synchronization>
            <Data />
            <Filter />
          </Receiver>
        </spe:Receivers>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
</Elements>

奇怪的是事件接收器永远不会执行。我已经使用SharePoint Manager 2010检查了Schema,似乎完全忽略了XmlDocuments元素? 以下是根据SharePoint Manager的内容类型SchemaXml:

<?xml version="1.0" encoding="utf-16"?>
<ContentType ID="0x0104008A424DE98660457481EB7D8DDB5161EE" Name="News Posting" Group="News" Description="A News Posting" Sealed="TRUE" Version="1">
  <Folder TargetName="_cts/News Posting" />
  <Fields>
    <Field ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}" Name="ContentType" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentType" Group="_Hidden" Type="Computed" DisplayName="Content Type" Sealed="TRUE" Sortable="FALSE" RenderXMLUsingPattern="TRUE" PITarget="MicrosoftWindowsSharePointServices" PIAttribute="ContentTypeID" Customization="">
      <FieldRefs>
        <FieldRef ID="{03e45e84-1992-4d42-9116-26f756012634}" Name="ContentTypeId" />
      </FieldRefs>
      <DisplayPattern>
        <MapToContentType>
          <Column Name="ContentTypeId" />
        </MapToContentType>
      </DisplayPattern>
    </Field>
    <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" Group="_Hidden" Type="Text" DisplayName="Title" Required="TRUE" FromBaseType="TRUE" Customization="" ShowInNewForm="TRUE" ShowInEditForm="TRUE" />
    <Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Name="Body" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body" Group="_Hidden" Type="Note" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE" DisplayName="Body" Sortable="FALSE" NumLines="15" Customization="" />
    <Field ID="{6a09e75b-8d17-4698-94a8-371eda1af1ac}" Name="Expires" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Expires" Group="_Hidden" Type="DateTime" DisplayName="Expires" Format="DateOnly" Customization="" />
    <Field ID="{7EBC5918-CB79-440A-8DF3-480C6951C4EB}" Group="News" Name="NewsExcerpt" DisplayName="Excerpt of the Article" Description="165 Characters maximum" MaxLength="165" Type="Text" Customization="" />
    </Field>
  </Fields>
  <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
      <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
        <Display>ListForm</Display>
        <Edit>ListForm</Edit>
        <New>ListForm</New>
      </FormTemplates>
    </XmlDocument>
  </XmlDocuments>
</ContentType>

我也试过添加一个FormTemplates XmlDocument,只是为了看看是否有效,但即使忽略了这一点(我已将ListForm更改为ListForm2,但SchemaXml没有改变。

我删除了整个Web应用程序和内容数据库,以确保没有任何陈旧/卡住,但结果仍然相同。

SharePoint 2010中是否折旧XmlDocuments?有哪些替代方案?

1 个答案:

答案 0 :(得分:0)

您应该将事件接收器添加为功能,甚至可以作为安装内容类型的相同功能的一部分。我们总是这样做,而且效果很好