Я использую запрос списка в SharePoint 2010 для извлечения данных из списка SharePoint, а затем применяю xslt для получения нужного html.Я изучаю xslt и надеюсь получить помощь от экспертов.
Ниже мой код
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
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:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema">
<xsl:output method="html" indent="no"/>
<xsl:template match="//xml">
<span style="border:solid 1px black">
-<xsl:value-of select="@query"/>-
</span>
<xsl:for-each select="//z:row">
<div>
<xsl:value-of select="@ows_LinkTitle"/>
</div>
<div>
<xsl:value-of select="@ows_Body"/>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
, который производит o / p, как показано ниже:
Wellness Week
<div class="ExternalClassBC7BF6939A374D7BAA0D130248D18C60"><p>Enroll in wellness classes and get rewards.</p></div>
Benefit Enrollment Time
<div class="ExternalClass5A080F46822C42FB861B96EE2A8A065D"><p>Please make sure to enroll in 2012 benefit program.</p></div>
Flu Shots Coming Soon
<div class="ExternalClass237E06C33F994D6C96E297EA04755B2B"><p>Please look at the upcoming dates for Flu shots.</p> <br /></div>
1.) Мне нужно удалить ненужные теги и иметьжелаемое o / p как:
Wellness Week
Enroll in wellness classes and get rewards.
Benefit Enrollment Time
Please make sure to enroll in 2012 benefit program.
Flu Shots Coming Soon
Please look at the upcoming dates for Flu shots.
2.) Затем добавьте ссылку Read More >>, например:
Wellness Week
Enroll in wellness classes and get rewards.
Read More>>
Benefit Enrollment Time
Please make sure to enroll in 2012 benefit program.
Read More>>
Flu Shots Coming Soon
Please look at the upcoming dates for Flu shots.
Read More>>
Спасибо.
Ниже мой xmlчто я получил от SOAP-ответа.Я пытался держать это опрятным, но мои извинения, если его трудно читать.Мы обеспокоены атрибутом элемента, в частности ows_body, который удаляет ненужные теги и просто получает текст.
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" d="t">
<s:schema id="RowsetSchema">
</s:schema>
<rs:data itemcount="3">
<z:row ows_linktitle="Wellness Week" ows_modified="2012-03-22 13:21:26"
ows_body="<div class="ExternalClassBC7BF6939A374D7BAA0D130248D18C60"><p>?Enroll in wellness classes and get rewards.</p></div>"
ows_metainfo="4;#" ows__moderationstatus="0" ows__level="1" ows_id="4" ows_uniqueid="4;#{69709650-B5BE-4BC1-B88E-724846C3CCEB}" ows_owshiddenversion="1" ows_fsobjtype="4;#0" ows_created_x0020_date="4;#2012-03-22 13:21:26"
ows_created="2012-03-22 13:21:26" ows_title="Wellness Week" ows_fileleafref="4;#4_.000" ows_permmask="0x7fffffffffffffff" ows_fileref="4;#Lists/HR Announcement/4_.000">
<z:row ows_linktitle="Benefit Enrollment Time" ows_modified="2012-03-22 13:16:25"
ows_body="<div class="ExternalClass5A080F46822C42FB861B96EE2A8A065D"><p>Please make sure to enroll in 2012 benefit program.</p></div>"
ows_metainfo="1;#" ows__moderationstatus="0" ows__level="1" ows_id="1" ows_uniqueid="1;#{F973E9EF-08FD-466B-B17F-19C9B44B27F5}" ows_owshiddenversion="2" ows_fsobjtype="1;#0" ows_created_x0020_date="1;#2012-03-22 10:53:04"
ows_created="2012-03-22 10:53:04" ows_title="Benefit Enrollment Time" ows_fileleafref="1;#1_.000" ows_permmask="0x7fffffffffffffff" ows_fileref="1;#Lists/HR Announcement/1_.000">
<z:row ows_linktitle="Flu Shots Coming Soon" ows_modified="2012-03-22 13:15:51"
ows_body="<div class="ExternalClass237E06C33F994D6C96E297EA04755B2B"><p>Please look at the upcoming dates for Flu shots.</p>
<br /></div>"
ows_metainfo="2;#" ows__moderationstatus="0" ows__level="1" ows_id="2" ows_uniqueid="2;#{82230E4B-2A5E-4F71-A83D-329CD72D621F}" ows_owshiddenversion="2" ows_fsobjtype="2;#0" ows_created_x0020_date="2;#2012-03-22 10:53:37"
ows_created="2012-03-22 10:53:37" ows_title="Flu Shots Coming Soon" ows_fileleafref="2;#2_.000" ows_permmask="0x7fffffffffffffff" ows_fileref="2;#Lists/HR Announcement/2_.000">
</z:row>
</z:row>
</z:row>
</rs:data>
</xml>