none
CQWP - ItemStyle.xsl - Data de Hoje RRS feed

  • Pergunta

  • Olá pessoal.

    Como posso retornar a data de hoje em XSL 1.0?

    Exemplo:

    <xsl:variable name="DataAtual">
        <xsl:value-of select="ddwrt:Today()">
    </xsl:variable>

    O exemplo acima não funciona.

    Obrigado!


    Paulo Junior

    segunda-feira, 21 de março de 2016 11:55

Todas as Respostas

  • XSLT 2

    Date functions are available natively, such as:

    <xsl:value-of  select="current-dateTime()"/>

    There is also current-date() and current-time().

    XSLT 1

    Use the EXSLT date and times extension package.

    1. Download the date and times package.
    2. Extract date.xsl to the location of your XSL files.
    3. Set the stylesheet header.
    4. Import date.xsl.

    For example:

    <xsl:stylesheet version="1.0" 
        xmlns:date="http://exslt.org/dates-and-times" 
        extension-element-prefixes="date"
        ...>
    
        <xsl:import href="date.xsl" />
    
        <xsl:template match="//root">
           <xsl:value-of select="date:date-time()"/>
        </xsl:template>
    </xsl:stylesheet>

    Fonte:

    Can an XSLT insert the current date?

    Att,


    Antero Marques

    segunda-feira, 21 de março de 2016 13:49
  • Antero, Thanks for your answer.

    I had tried to use the post that you recommended.

    But I can't find this file "date.xsl" (broken link to http://exslt.org/date/date.zip).

    So, I found the "date.xsl" in https://github.com/bzerangue/exslt.org/blob/master/date/date.xsl (I dont know if is the same)

    When I import this file to ItemStyle.xsl, all CQWP of the site display errors.

    Here my header of ItemStyle.xsl:

    <xsl:stylesheet 
      version="1.0" 
      exclude-result-prefixes="x d xsl msxsl cmswrt"
      xmlns:x="http://www.w3.org/2001/XMLSchema" 
      xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
      xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
      xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:date="http://exslt.org/dates-and-times"
      extension-element-prefixes="date"  
      xmlns:msxsl="urn:schemas-microsoft-com:xslt">
      
      <xsl:import href="date.xsl" />
    

    Have you a tip to do this work well?

    Thx!



    Paulo Junior

    segunda-feira, 21 de março de 2016 14:28