扩展 DataForm Web 部件不显示节点值
我正在尝试通过继承 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&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>
请指出我哪里出错了
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了同样的答案,我必须重写另一种方法
I found the answer for the same i had to override one more method