上次修改时间: 2010年12月20日
适用范围: SharePoint Foundation 2010
本文内容
源节点树
thisNode 参数树
结果树
本主题提供了用于在 Microsoft SharePoint Foundation 中呈现列表视图的三种节点树的示例。
源节点树是定义列表的当前视图的视图架构标记。XSLT 处理器在生成结果树时会分析和遍历此树。因此,在 XSLT 转换过程中的任何指定时间,XSLT 处理器的上下文节点 都是此标记中的一个节点。
调用模板会将 thisNode 参数树传递给每个 XSLT 字段呈现模板。此标记包含列表中的实际数据。呈现字段时,会从此参数中获取实际字段值。有关 thisNode 参数中标记的完整参考,请参阅 dsQueryResponse XML。
结果参数树是将 XSLT 转换为 HTML 标记的结果。
源节点树
下面是一个源节点树示例,为了提高可读性,向其中添加了空格。该示例定义了名为"Books"的列表的"All Items"视图。此视图中显示了该列表中的六个字段(列)。每个字段由一个 FieldRef 元素(列表) 来表示,该元素的 Name 属性是此字段的内部名称。
<View Name="{BE704296-1D55-4F88-AD11-190FAEC79BD7}" DefaultView="TRUE" MobileView="TRUE"
MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items"
Url="/sites/Contoso/Lists/Books/AllItems.aspx" Level="1" BaseViewID="1"
ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png">
<Query>
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Attachments" Type="Attachments" FieldType="Attachments"
DisplayName="Attachments" ID="67df98f4-9dec-48ff-a553-29bece9c5bf4" />
<FieldRef Name="LinkTitle" Type="Computed" FieldType="Computed"
DisplayName="Title" ID="82642ec8-ef9b-478f-acf9-31f7d45fbc31"
ClassInfo="Menu" ListItemMenu="TRUE" ListItemMenuAllowed="Required"
LinkToItemAllowed="Prohibited" />
<FieldRef Name="ISBN" Type="Text" FieldType="ISBN"
DisplayName="ISBN" ID="47934bd9-553c-4409-9243-d6f8140ff0c2" />
<FieldRef Name="ContentType" Type="Computed" FieldType="Computed"
DisplayName="Content Type" ID="c042a256-787d-4a6f-8a8a-cf6ab767f12d"
Sortable="FALSE" />
<FieldRef Name="Author" ImnHeader="TRUE" Type="User" FieldType="User"
DisplayName="Created By" ID="1df5e554-ec7e-46a6-901d-d85a3881cb18"
LinkToItemAllowed="Prohibited" />
<FieldRef Name="Retail_x0020_Price" Type="Currency" FieldType="Currency"
DisplayName="Retail Price" ID="ad5b9777-ee46-4a9f-85d0-d64dd5592b00" />
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Aggregations Value="Off" />
<Toolbar Type="Standard" />
<List Direction="" TemplateType="100" Title="Books" Description="" BaseType="0"
RootFolder="" Version="4" Name="{53BD7850-49CC-4747-ADED-E053659ACE79}"
Moderatedlist="0" SendToLocationName="" SendToLocationUrl="" WriteSecurity="1"
EnableMinorVersions="0" VersioningEnabled="0" ForceCheckout="0"
WorkflowsAssociated="0" DefaultItemOpen="1" RecycleBinEnabled="1"
ExternalDataList="0" OfficialFileNames="" EnableSyndication="1"
EnableContentTypes="0"/>
</View>
thisNode 参数树
以下内容摘自 XSLT 样式表中传递给 XSLT 字段呈现模板的 thisNode 参数的内容,为了提高可读性,向其中添加了空格。它表示在内容数据库中查询 Books 列表的所有行的结果,最多结果数为每页中的最大项数,在此示例中为 30。每项由一个 Row 元素表示。项中的每个字段由一个名称为字段内部名称的属性来表示。例如,Author 是"Created By"字段的内部名称,Retail_x0020_Price 是"Retail Price"字段的内部名称。这些属性的值是内容数据库中对应字段的值;例如,第一行中 ISBN 字段的值是"0-262-61107-4"。但请注意,将 Author 字段的值呈现为链接所需要的标记已对字段值进行包装。
/
<dsQueryResponse ViewStyleID="" BaseViewID="1" TemplateType="100" RowLimit="30">
<Rows>
<Row ID="1"
PermMask="0x7fffffffffffffff"
Attachments="0"
Title="Theories of Truth"
FileLeafRef="1_.000"
FileLeafRef.Name="1_"
FileLeafRef.Suffix="000"
FSObjType="0"
Created_x0020_Date="0;#2010-03-01 13:16:03"
Created_x0020_Date.ifnew attribute value:
FileRef="/sites/Contoso/Lists/Books/1_.000"
FileRef.urlencode="%2Fsites%2FContoso%2FLists%2FBooks%2F1%5F%2E000"
FileRef.urlencodeasurl="/sites/Contoso/Lists/Books/1_.000"
File_x0020_Type=""
HTML_x0020_File_x0020_Type.File_x0020_Type.mapall="icgen.gif||"
HTML_x0020_File_x0020_Type.File_x0020_Type.mapico="icgen.gif"
ContentTypeId="0x0100CFB65A47C9E37B4A818F75CB08CF4062"
ISBN="0-262-61107-4"
ContentType="Item"
Author='<span class="ms-imnSpan">
<a href='javascript:;' onclick='IMNImageOnClick(event);return false;' class='ms-imnlink'>
<img name='imnmark' class='ms-imnImg' title='' border='0' height='12' width='12'
src='/_layouts/images/blank.gif' alt='No presence information'
sip='MichiyoS@Contoso.com' id='imn_1,type=smtp'/></a>
<a onclick="GoToLink(this);return false;" href="/sites/Contoso/_layouts/userdisp.aspx?ID=1">
Michiyo Sato</a></span>'
Author.id="1"
Author.title="Michiyo Sato"
Author.span='<nobr><span>
<a onclick="GoToLink(this);return false;"
href="/sites/Contoso/_layouts/userdisp.aspx?ID=1">Michiyo Sato</a>
<img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/>
<a href='javascript:;' onclick='IMNImageOnClick(event);return false;' class='ms-imnlink'>
<img name='imnmark' class='ms-imnImg' title='' border='0' height='12' width='12'
src='/_layouts/images/blank.gif' alt='No presence information'
sip='MichiyoS@Contoso.com' id='imn_2,type=smtp'/>
</a>
</span></nobr>'
Retail_x0020_Price="$37.99"
Retail_x0020_Price.="37.9900000000000" />
<Row ... attributes omitted ... />
<Row ... attributes omitted ... />
<!-- Up to 30 Row elements total per page. -->
<Row ... attributes omitted ... />
</Rows>
</dsQueryResponse>
有关 thisNode 参数中标记的完整参考,请参阅 dsQueryResponse XML。
结果树
以下内容摘自内置 XSLT 样式表呈现 Books 列表所产生的 HTML。此处显示了该表第一个数据行的 <tr> 元素。
<tr class="ms-itmhover" iid="0,1,0">
<td class="ms-vb-itmcbx ms-vb-firstCell"><input type="checkbox" class="s4-itm-cbx" /></td>
<td class="ms-vb2"></td>
<td height="100%" onmouseover="OnChildItem(this)" class="ms-vb-title">
<div class="ms-vb itx" onmouseover="OnItem(this)" CTXName="ctx0" id="1"
Field="LinkTitle" Perm="0x7fffffffffffffff" EventType="">
<a onfocus="OnLink(this)" href="https://contoso.com/sites/Contoso/_layouts/listform.aspx
?PageType=4&ListId={53BD7850-49CC-4747-ADED-E053659ACE79}
&ID=1&ContentTypeID=0x0100CFB65A47C9E37B4A818F75CB08CF4062"
onclick="EditLink2(this,0);return false;" target="_self">
Theories of Truth
</a>
</div>
<div class="s4-ctx" onmouseover="OnChildItem(this.parentNode); return false;">
<span> </span>
<a onfocus="OnChildItem(this.parentNode.parentNode); return false;"
onclick="PopMenuFromChevron(event); return false;" href="javascript:;" title="Open Menu"></a>
<span> </span>
</div>
</td>
<td class="ms-vb2">0-262-61107-4</td>
<td class="ms-vb2">Item</td>
<td class="ms-vb2"><div align="right">$37.99</div></td>
<td class="ms-vb-user">
<span class="ms-imnSpan">
<a href='javascript:;' onclick='IMNImageOnClick(event);return false;' class='ms-imnlink'>
<img name='imnmark' class='ms-imnImg' title='' border='0' height='12' width='12'
src='/_layouts/images/blank.gif' alt='No presence information'
sip='MichiyoS@Contoso.com' id='imn_1,type=smtp'/>
</a>
<a onclick="GoToLink(this);return false;" href="/sites/Contoso/_layouts/userdisp.aspx?ID=1">
Michiyo Sato
</a>
</span>
</td>
</tr>
图 1 显示该行在页面中呈现时的外观。
图 1. Books 列表中的一行
.jpg)