Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Hope an xslt guru can help me with this

From: "rote" <naijacoder@-------.--->
To: NULL
Date: 6/20/2008 5:10:00 PM

I have a xml below and its from a sharepoint list and i would like to format 
it using xslt.
What i want to achieve is Display the Title,Body,Modified and the Author


I have actually done that(but not done well) and this is my xslt below (but 
what i want to to also achieve is check for the node rows and if  0 show 
nothing and
display a meessage "There are no messages to show in this view".)

Thanks in Advance

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:lv="FlexListViewer.ListViewerObjectModel" 
exclude-result-prefixes="lv">

    <!-- URL to the current page (page containing the 
FlexListViewer-webpart) -->
 <xsl:param name="currentPage"></xsl:param>
 <!-- URL to the current site (site where the current page is hosted) -->
 <xsl:param name="currentSiteUrl">CURRENTSITEURL_X</xsl:param>
 <!-- Locale-id of the current site -->
 <xsl:param name="lcid">LCID</xsl:param>
 <!-- Whether AddNewItem-option must be displayed -->
 <xsl:param name="allowAddNewItem">False</xsl:param>
 <!-- Message to display for the AddNewItem-button/label -->
 <xsl:param name="msgAddNewItem">ADDNEWITEM</xsl:param>
 <!-- Text for "Yes" in the locale of current site -->
 <xsl:param name="msgYes">Ja</xsl:param>
 <!-- Text for "No" in the locale of current site -->
 <xsl:param name="msgNo">Nee</xsl:param>

    <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes"/>


 <xsl:template name="dvt_1" match="/lv:Rows">

  <xsl:variable name="Rows" select="/lv:Row"/>
  <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
  <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount=0"/>
  <xsl:choose>
   <xsl:when test="$dvt_IsEmpty">
    <xsl:call-template name="dvt_1.empty" />

   </xsl:when>
   <xsl:otherwise>

   <!--
   <table border="0" width="100%" cellpadding="2" cellspacing="0">
   <xsl:call-template name="dvt_1.body">
    <xsl:with-param name="Rows" select="$Rows"/>
   </xsl:call-template>
     </table>
     -->

     <!--
      <table border="0" width="100%" cellpadding="2" cellspacing="0">
   <xsl:call-template name="main">

    <xsl:with-param name="rowValues" select="."/>
   </xsl:call-template>
     </table>
     -->

     <xsl:text>sdsds</xsl:text>




  </xsl:otherwise>
  </xsl:choose>

 </xsl:template>




 <xsl:template match="/lv:ListView">


    <xsl:call-template name="dvt_1"/>


    <table rules="rows" border="1" cellspacing="2" cellpadding="2" 
class="ms-summarytable" width="100%" bordercolor="#D7E6F4" 
bgcolor="#FFFFCC">

  <tr align="left">
   <th bgcolor="#ffd6e7" 
style="font-style:normal;color:#a8104a">Subject</th>
      <th bgcolor="#ffd6e7" 
style="font-style:normal;color:#a8104a">Description</th>
      <th bgcolor="#ffd6e7" style="font-style:normal;color:#a8104a">Date 
Modified</th>
      <th bgcolor="#ffd6e7" style="font-style:normal;color:#a8104a">Created 
by</th>


        </tr>

  <!-- Header-row -->
  <tr>
        <!--
   <xsl:apply-templates select="lv:Fields/lv:ListViewField[@Hidden = 
'false']" mode="renderField" />
  -->
  </tr>

  <!-- Data rows -->

  <xsl:apply-templates select="lv:Rows/lv:ListViewRow/lv:RowValues">
   <xsl:with-param name="fields" select="lv:Fields"/>
  </xsl:apply-templates>

<!-- New row

  <xsl:apply-templates select="lv:Rows/lv:ListViewRow/@Id">

   <xsl:with-param name="id" select="."/>

  </xsl:apply-templates>
  -->

  </table>


  <!-- Add new Item -->
  <xsl:if test="$allowAddNewItem = 'True'">
   <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr height="1px"><td class="ms-partline" style="height:1px;"></td></tr>
    <tr><br/><td style="padding-bottom: 3px">
     &#160;&#160;<img src="/_layouts/images/rect.gif" alt="" />&#160;
     <a href="{@SiteUrl}{@NewFormUrl}?Source={$currentPage}" target="_self">
      <xsl:value-of select="$msgAddNewItem"/>
     </a>
    </td></tr>
   </table>
  </xsl:if>

 </xsl:template>


 <!-- MyRow -->
 <xsl:template match="lv:ListViewRow/lv:RowValues">


  <xsl:param name="id"/>

  <!-- -->
  <tr>
<!--
  <xsl:value-of select="$id"/>
-->
  </tr>
 </xsl:template>




 <!-- Row -->
 <xsl:template match="lv:ListViewRow/lv:RowValues">
  <xsl:param name="id"/>
  <xsl:param name="fields"/>
  <!-- -->
  <tr>
   <xsl:variable name="thisRowValues" select="." />


   <xsl:apply-templates select="$fields/lv:ListViewField[@Hidden = 'false']" 
mode="renderRow">
    <xsl:with-param name="rowValues" select="."/>
   </xsl:apply-templates>

   <xsl:value-of select="$id"/>

  </tr>

 </xsl:template>



 <!-- Row-item -->
 <xsl:template match="lv:ListViewField" mode="renderRow">


  <xsl:param name="rowValues"/>

  <!-- -->

  <xsl:variable name="currentFieldName" select="@Name"/>

   <xsl:variable name="fieldValueParts" 
select="$rowValues/lv:ListViewRowValue[@FieldName = 
$currentFieldName]/lv:Parts"/>

       <xsl:variable name="rowCount" select="count($rowValues)" />





  <xsl:choose>

    <xsl:when test="@FieldType = 'URL'">
     <td bgcolor="#C0C0C0">
      <xsl:choose>
       <xsl:when test="count($fieldValueParts/lv:ListViewRowValuePart) >= 
2">
        <a href="{$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text()}">
         <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 2]/text()"/>
        </a>
       </xsl:when>
       <xsl:otherwise>
        <a href="{$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text()}">
         <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>
        </a>
       </xsl:otherwise>
      </xsl:choose>
      &#160;
     </td>
    </xsl:when>


    <xsl:when test="@FieldType = 'User'">
     <td>
      <xsl:choose>
       <xsl:when test="count($fieldValueParts/lv:ListViewRowValuePart) >= 
2">
        <xsl:variable name="listSiteUrl" select="/lv:ListView/@SiteUrl" />
        <!--
        <a 
href="{$listSiteUrl}_layouts/{$lcid}/UserDisp.aspx?ID={$fieldValueParts/lv:ListViewRowValuePart[position() 
= 2]/text()}">
         <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>
        </a>
        -->

         <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>


       </xsl:when>
       <xsl:otherwise>

        <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>

       </xsl:otherwise>
      </xsl:choose>
      &#160;
     </td>
    </xsl:when>

    <xsl:when test="@FieldType = 'Boolean'">
     <td class="ms-vb2">
      <xsl:choose>
       <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = 'True'"><xsl:value-of select="$msgYes"/></xsl:when>
       <xsl:otherwise><xsl:value-of select="$msgNo"/></xsl:otherwise>
      </xsl:choose>
      &#160;
     </td>
    </xsl:when>

    <xsl:when test="@FieldType = 'Attachments'">
     <td class="ms-vb2">
      <xsl:choose>
       <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = '0'">&#160;</xsl:when>
       <xsl:otherwise><img border="0" 
src="/test/_layouts/images/attach.gif"/></xsl:otherwise>
      </xsl:choose>
      &#160;
     </td>
    </xsl:when>



   <xsl:when test="@FieldType = 'Computed'">
    <td class="ms-vb2">
     <xsl:choose>
     <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = 'True'">
                      <!--
      <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = 'True'">
      -->

      &#160;
      <!--
      <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>
                       -->

      </xsl:when>

      <xsl:otherwise>

      <xsl:value-of select="$fieldValueParts/lv:ListViewRowValuePart"/>
      <!--
      <xsl:if test="position() &lt; 0">
       <xsl:value-of select="$fieldValueParts/lv:ListViewRowValuePart"/>
          </xsl:if>
          -->

                    </xsl:otherwise>
     </xsl:choose>
     &#160;
    </td>
   </xsl:when>


   <xsl:when test="@FieldType = 'Note'">
    <td class="ms-vb2">
    <xsl:choose>
     <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = ' ' ">

     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>

     </xsl:otherwise>

     </xsl:choose>
     <!--
     <xsl:choose>
      <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = 'True'">&#160;</xsl:when>
      <xsl:otherwise>
       <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>

       <img border="0" src="/test/_layouts/images/attach.gif"/>

      </xsl:otherwise>
     </xsl:choose>
     &#160;
     -->
    </td>
   </xsl:when>


   <xsl:when test="@FieldType = 'DateTime'">
    <td class="ms-vb2">
     <xsl:choose>
      <xsl:when test="$fieldValueParts/lv:ListViewRowValuePart[position() = 
1]/text() = 'True'">&#160;</xsl:when>
      <xsl:otherwise>
       <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 1]/text()"/>
       <!--
       <img border="0" src="/test/_layouts/images/attach.gif"/>
       -->
      </xsl:otherwise>
     </xsl:choose>
     &#160;
    </td>
   </xsl:when>


   <!--
    <xsl:when test="@FieldType = 'EDIT'">
     <xsl:variable name="editUrl">
      <xsl:value-of select="/lv:ListView/@SiteUrl"/>
      <xsl:value-of select="/lv:ListView/@EditFormUrl"/>
     </xsl:variable>

     <td class="ms-vb2">
      <a 
href="{$editUrl}?ID={$fieldValueParts/lv:ListViewRowValuePart[1]}&amp;Source={$currentPage}">
       <img src="{$currentSiteUrl}_layouts/images/edititem.gif" border="0" 
/>
      </a>
      &#160;
     </td>

    </xsl:when>
    -->


    <xsl:when test="@FieldType = 'DOCICON'">
     <td class="ms-vb-icon">
      <img 
src="{$currentSiteUrl}_layouts/images/{$fieldValueParts/lv:ListViewRowValuePart[1]}" 
border="0" />
     </td>
    </xsl:when>

    <xsl:when test="@FieldType = 'FILE'">
     <xsl:variable name="listRootUrl" select="/lv:ListView/@RootUrl" />
     <td class="ms-vb2">
      <a href="{$listRootUrl}{$fieldValueParts/lv:ListViewRowValuePart[1]}" 
target="_blank">
       <xsl:value-of select="$fieldValueParts/lv:ListViewRowValuePart[1]"/>
      </a>
      &#160;
     </td>
    </xsl:when>

  <!-- variable for  fieldValueParts-
  <xsl:variable name="fieldValueParts" 
select="$rowValues/lv:ListViewRowValue[@FieldName = 
$currentFieldName]/lv:Parts"/>
  -->
    <xsl:otherwise>
     <td align="left">

     <!--
             <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[1]"/>
       -->
<!--
      <xsl:value-of 
select="$fieldValueParts/lv:ListViewRowValuePart[position() = 2]/text()"/>

      <xsl:value-of select="$fieldValueParts/lv:ListViewRowValuePart[3]"/>
-->
      &#160;
      <xsl:value-of select="$rowCount"/>

     </td>
    </xsl:otherwise>


   </xsl:choose>


 </xsl:template>

 <xsl:template name="dvt_1.empty">
  <xsl:variable name="dvt_ViewEmptyText">There are no store communications 
to show in this view.</xsl:variable>
  <table border="0" width="100%">
   <tr>
    <td class="ms-vb">
     <xsl:value-of select="$dvt_ViewEmptyText" />

    </td>
   </tr>
  </table>
 </xsl:template>


</xsl:stylesheet>







<?xml version="1.0" encoding="utf-16"?>

<ListView xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
ViewID="3f49dbaf-f7d6-48b1-bd50-0deb732eca0d" 
ListID="61bd347a-9e2e-49aa-bf82-4349ee5bb1f9" DisplayName="Notices" 
SiteUrl="" AbsoluteUrl="" RootUrl="" DisplayFormUrl="Lists/Important 
Info/DispForm.aspx" NewFormUrl="Lists/Important Info/NewForm.aspx" 
EditFormUrl="Lists/Important Info/EditForm.aspx" BaseType="GenericList" 
RowLimit="100" xmlns="FlexListViewer.ListViewerObjectModel">

<Fields>

<ListViewField Name="LinkTitleNoMenu" DisplayName="Title" 
FieldType="Computed" Hidden="false" LinkToItem="true" />

<ListViewField Name="Body" DisplayName="Body" FieldType="Note" 
Hidden="false" LinkToItem="false" />

<ListViewField Name="Modified" DisplayName="Modified" FieldType="DateTime" 
Hidden="false" LinkToItem="false" />

<ListViewField Name="Author" DisplayName="Created By" FieldType="User" 
Hidden="false" LinkToItem="false" />

<ListViewField Name="Edit" DisplayName="Edit" FieldType="EDIT" 
Hidden="false" LinkToItem="false" />

</Fields>

<Rows>

<ListViewRow Id="31">

<RowValues>

<ListViewRowValue FieldName="LinkTitleNoMenu">

<Parts>

<ListViewRowValuePart>fdsfs</ListViewRowValuePart>

</Parts>

</ListViewRowValue>

<ListViewRowValue FieldName="Body">

<Parts>

<ListViewRowValuePart>fsdfsdf</ListViewRowValuePart>

</Parts>

</ListViewRowValue>

<ListViewRowValue FieldName="Modified">

<Parts>

<ListViewRowValuePart>20/06/2008</ListViewRowValuePart>

</Parts>

</ListViewRowValue>

<ListViewRowValue FieldName="Author">

<Parts>

<ListViewRowValuePart>Patrick Ige</ListViewRowValuePart>

<ListViewRowValuePart>1073741823</ListViewRowValuePart>

</Parts>

</ListViewRowValue>

<ListViewRowValue FieldName="Edit">

<Parts />

</ListViewRowValue>

</RowValues>

</ListViewRow>

</Rows>

</ListView>




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent