扩展DataForm Web部件不显示节点值

时间:2011-06-27 07:57:13

标签: sharepoint sharepoint-2010 dataformwebpart

我正在尝试通过继承dataformwebpart来创建自定义Web部件。我面临的问题是在xsl中我无法显示xml节点的值,尽管我得到了节点的名称。

下面是我的示例代码,xsl,xml

 public override void DataBind()
    {

      XmlDocument doc = GetFeedsXML(); 
      XmlDataSource source = new XmlDataSource();
      source.ID = "wallXML";
      source.Data = doc.InnerXml;
      this.DataSource = source;
      base.Xsl = this.Xsl;
      base.DataBind();

    }

XSL

<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" version="1.0"

exclude-result-prefixes="xsl msxsl ddwrt"

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

xmlns:asp="http://schemas.microsoft.com/ASPNET/20"

xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"

xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">

<div>

<table>

<xsl:for-each select="/root/data/*">
        <tr><td>
        <xsl:value-of select="name()" />
abcd
<xsl:value-of select="." />
</td></tr>
        </xsl:for-each>


</table>
</div>

</xsl:template>


</xsl:stylesheet>

XML

<root>
 <data>
  <id>166358820071963_158352987564493</id>
  <from>
   <name>Sharepointworld By Ashutosh</name>
   <category>Personal blog</category>
   <id>166358820071963</id>
  </from>
  <message>http://www.sharepointworld.in/2011/06/filestream-with-sharepoint-2010.html</message>
  <picture>http://external.ak.fbcdn.net/safe_image.php?d=AQDBGCIsqUOyGsf0&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fsharepoint.microsoft.com%2Fblog%2FPublishingImages%2FBlog+images_Filestream%2Fblog_filestream_3.PNG</picture>
  <link>http://www.sharepointworld.in/2011/06/filestream-with-sharepoint-2010.html</link>
  <name>SharePoint World By Ashutosh: FILESTREAM with SharePoint 2010</name>
  <caption>www.sharepointworld.in</caption>
  <description>Ashutosh blog for sharepoint world</description>
  <icon>http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif</icon>
  <actions>
   <name>Comment</name>
   <link>http://www.facebook.com/166358820071963/posts/158352987564493</link>
  </actions>
  <actions>
   <name>Like</name>
   <link>http://www.facebook.com/166358820071963/posts/158352987564493</link>
  </actions>
  <privacy>
   <description>Everyone</description>
   <value>EVERYONE</value>
  </privacy>
  <type>link</type>
  <created_time>2011-06-01T08:03:00+0000</created_time>
  <updated_time>2011-06-01T08:03:00+0000</updated_time>
 </data>
</root>

请告诉我哪里出错了

1 个答案:

答案 0 :(得分:0)

我找到了相同的答案我不得不重写另一个方法

protected override XPathNavigator GetXPathNavigator(string viewPath)

        {

            return doc.CreateNavigator();

        }