I am using SharePoint 2013. I am using the XML Viewer WebPart. In this webpart I have some xml and a write xsl in the xsl editor. Everything is working fine. I would like to filter te data on the start and enddate. How can I get the currentdate in the xsl?
XML:
<?xml version="1.0" encoding="utf-8"?> <sitegegevens> <vacatures> <vacature id="27223" > <titel>TitelA</titel> <startdate>16-05-2014</startdate> <enddate>11-08-2014</enddate> </vacature> <vacature id="27224" > <titel>TitelB</titel> <startdate>16-05-2014</startdate> <enddate>11-06-2014</enddate> </vacature> <vacature id="27225" > <titel>TitelC</titel> <startdate>16-09-2014</startdate> <enddate>11-10-2014</enddate> </vacature> </vacatures> </sitegegevens> XSL:
<xsl:stylesheet version="1.0" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:template match="vacature"> <h1><xsl:value-of select="titel"/></h1> <br/> Start date: <xsl:value-of select="startdate"/><br/> End date: <xsl:value-of select="enddate"/><br/> <br/> </xsl:template> </xsl:stylesheet> I have try this, but give me the error "Failed to apply XSLT to the content":
<xsl:stylesheet version="1.0" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:template match="vacature"> <h1><xsl:value-of select="titel"/></h1> <br/> Start date: <xsl:value-of select="startdate"/><br/> End date: <xsl:value-of select="enddate"/><br/> Current date: <xsl:variable name="current-date" select="translate(substring-before(date:date-time(), 'T'), '-', '')"/> <br/> </xsl:template> </xsl:stylesheet> UPDATE:
I have added a data view webpart and connect it to some list "FAQ". I have added inside this DVWP the today binding with the current date:
<WebPartPages:XsltListViewWebPart runat="server" ViewFlag="" ViewSelectorFetchAsync="False" InplaceSearchEnabled="False" ServerRender="False" ClientRender="True" InitialAsyncDataFetch="False" WebId="00000000-0000-0000-0000-000000000000" IsClientRender="False" GhostedXslLink="main.xsl" NoDefaultStyle="TRUE" ViewGuid="{B90A96CD-EEA6-45BD-9E12-136D71C72878}" EnableOriginalValue="False" DisplayName="FAQ3" ViewContentTypeId="0x" Default="FALSE" ListName="{72AB33F7-A53E-4F33-B5ED-146350A153E9}" ListId="72ab33f7-a53e-4f33-b5ed-146350a153e9" PageSize="-1" UseSQLDataSourcePaging="True" DataSourceID="" ShowWithSampleData="False" AsyncRefresh="False" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" Title="FAQ" FrameType="Default" SuppressWebPartChrome="False" Description="" IsIncluded="True" ZoneID="wpz" PartOrder="3" FrameState="Normal" AllowRemove="True" AllowZoneChange="True" AllowMinimize="True" AllowConnect="True" AllowEdit="True" AllowHide="True" IsVisible="True" TitleUrl="/Lists/FAQ" DetailLink="/Lists/FAQ" HelpLink="" HelpMode="Modeless" Dir="Default" PartImageSmall="" MissingAssembly="Kan dit webonderdeel niet importeren." ImportErrorMessage="Kan dit webonderdeel niet importeren." PartImageLarge="" IsIncludedFilter="" ExportControlledProperties="False" ConnectionID="00000000-0000-0000-0000-000000000000" ID="g_b90a96cd_eea6_45bd_9e12_136d71c72878" ExportMode="NonSensitiveData" __MarkupType="vsattributemarkup" __WebPartId="{B90A96CD-EEA6-45BD-9E12-136D71C72878}" __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_Ratings.xsl" WebPart="true" Height="" Width=""><ParameterBindings> <ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/> <ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/> <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/> <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/> <ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /> <ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /> <ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /> <ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /> <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /> <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)" /> <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" /> <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)" /> <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/> </ParameterBindings> <DataFields> </DataFields> <XmlDefinition> <View Name="{B90A96CD-EEA6-45BD-9E12-136D71C72878}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="FAQ3" Url="/SitePages/Vacatures.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=23" ><Query/><ViewFields><FieldRef Name="Title"/><FieldRef Name="Antwoord"/></ViewFields><RowLimit Paged="TRUE">30</RowLimit><Aggregations Value="Off"/><JSLink>clienttemplates.js</JSLink><XslLink Default="TRUE">main.xsl</XslLink><Toolbar Type="Standard"/></View></XmlDefinition> </WebPartPages:XsltListViewWebPart> After this I have added the variable today in my stylesheet:
<xsl:stylesheet version="1.0" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:param name="Today" /> <xsl:template match="vacature"> <h1><xsl:value-of select="titel"/></h1> <br/> Start date: <xsl:value-of select="startdate"/><br/> End date: <xsl:value-of select="enddate"/><br/> Current date: <xsl:value-of select="$Today"/><br/> <br/> </xsl:template> </xsl:stylesheet> No error, but I dont see a date. The variable looks empty.