【问题标题】:XmlDocuments Element ignored in Content Type?内容类型中忽略了 XmlDocuments 元素?
【发布时间】:2010-06-30 22:51:06
【问题描述】:

我在 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 检查了架构,似乎 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 应用程序和内容数据库,以确保没有任何陈旧/卡住的东西,但结果仍然相同。

XmlDocuments 在 SharePoint 2010 中是否贬值?有哪些替代方案?

【问题讨论】:

  • 对于其他对此感到恼火的人:Inherits="FALSE"“修复”此问题;否则,功能激活接收器黑客..

标签: sharepoint sharepoint-2010


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    • 2014-09-07
    • 1970-01-01
    • 2011-05-16
    相关资源
    最近更新 更多