Tuesday, July 26, 2011

XSL Date using ddwrt Namespace

The following comes from: http://msdn.microsoft.com/en-us/library/dd583143(v=office.11).aspx

XSL Date using ddwrt Namespace... NOTE: Ensure the xsl stylesheet includes a reference to ddwrt ... Eg:

<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:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">

Functions:

public string FormatDate(string szDate, long lcid, long formatFlag);
<xsl:value-of select="ddwrt:FormatDateTime(ddwrt:TodayIso(),2057,'dddd MMMM dd yyyy')" />

public string TodayIso();
<xsl:value-of select="ddwrt:TodayIso()"/>

public string Today();
<xsl:value-of select="ddwrt:Today()"/>

  • Date only as M/d/yyyy. Example: "08/17/2000".
  • Date only as dddd, MM dd, yyyy. Example: "Thursday, August 17, 2000".
  • Time only as h:mm. Example: "16:32".
  • DateTime as M/d/yyyy h:mm. Example: "08/17/2000 16:32".
  • DateTime as dddd, MM dd, yyyy h:mm. Example: "Thursday, August 17, 2000 16:32".
  • Time only as h:mm:ss. Example: "16:32:32".
  • DateTime as M/d/yyyy h:mm:ss. Example: "08/17/2000 16:32:32".
  • DateTime as dddd, MMMM dd, yyyy h:mm:ss. Example: "Thursday, August 17, 2000 16:32:32".

    Wednesday, July 06, 2011

    XLV Web Parts

    To display an XLV on another site update the Title, Description, ListId and WebId values in this code; save as a .webpart; upload the file to a web part page (more info on Glyn's blog):

    <?xml version="1.0" encoding="utf-8" ?>
    <webParts>
    <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
    <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
    <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
    </metaData>
    <data>
    <properties>
    <property name="Title" type="string">My List</property>
    <property name="Description" type="string">A view of My list from the root of the site</property>
    <property name="ListName" type="string">8480D028-A2ED-474B-8259-BEE394EE4C53</property>
    <property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">8480D028-A2ED-474B-8259-BEE394EE4C53</property>
    <property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">adea17f7-e661-4ff0-91e9-70f021c60647</property>
    <property name="ExportMode" type="exportmode">All</property>
    </properties>
    </data>
    </webPart>
    </webParts>