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

发布于 2024-11-17 10:38:50 字数 3308 浏览 1 评论 0原文

我正在尝试通过继承 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>

请指出我哪里出错了

I'm trying to create a custom web part by inheriting the dataformwebpart. the problem i'm facing is that in xsl i'm not able to display value of xml nodes although i'm getting the names of nodes.

below is my sample code, 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&w=90&h=90&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>

kindly suggest where i'm going wrong

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-11-24 10:38:50

我找到了同样的答案,我必须重写另一种方法

protected override XPathNavigator GetXPathNavigator(string viewPath)

        {

            return doc.CreateNavigator();

        }

I found the answer for the same i had to override one more method

protected override XPathNavigator GetXPathNavigator(string viewPath)

        {

            return doc.CreateNavigator();

        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文