다음을 통해 공유


Examples of Input and Result Node Trees in XSLT Transformations

Applies to: SharePoint Foundation 2010

This topic provides examples of three kinds of node trees that are used in list view rendering in Microsoft SharePoint Foundation.

  • The source node tree is View schema markup that defines the current view of a list. It is this tree that the XSLT processor is parsing and traversing as it builds the result tree. Hence, at any given time during the XSLT transformation, the context node of the XSLT processor is a node in this markup.

  • The thisNode parameter tree is passed to each XSLT field rendering template by the calling template. This markup contains the actual data from the list. When a field is rendered, the actual field value is obtained from this parameter. For the full reference of the markup in the thisNode parameter, see dsQueryResponse XML.

  • The result parameter tree is the outcome of the XSLT transformation as HTML markup.

Source Node Tree

The following is an example of a source node tree with white space added for readability. It defines the All Items view of a list called Books. Six of the fields (columns) of the list are made visible in this view. Each of them is represented by a FieldRef Element (List) whose Name attribute is the internal name of the field.

<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 Parameter Tree

The following is an excerpt from the content of a thisNode parameter that is passed to an XSLT field rendering template in an XSLT style sheet, with white space added for readability. It represents the results of a query to the content database for all the rows of the Books list, up to the maximum number of items per page, which in this case is 30. Each item is represented by a Row element. Each field in the item is represented by an attribute whose name is the internal name of the field. For example, Author is the internal name of the Created By field, and Retail_x0020_Price is the internal name of the Retail Price field. The values of these attributes are the values of the corresponding fields in the content database; for example, the value of the ISBN field in the first row is "0-262-61107-4". But note that the markup that is needed to render the value of the Author field as a link has already been wrapped around the field's value.

/
  <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>  

For the full reference of the markup in the thisNode parameter, see dsQueryResponse XML.

Result Tree

The following is an excerpt from the HTML that results from the rendering of the Books list by the built-in XSLT style sheets. The <tr> element for the first data row of the table is shown.

<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&amp;ListId={53BD7850-49CC-4747-ADED-E053659ACE79}
                                       &amp;ID=1&amp;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>

Figure 1 shows what the row looks like when it is rendered on the page.

Figure 1. A row of the Books list

A row in the Books list.

See Also

Concepts

Overview of XSLT List View Rendering System

View Schema