cancel
Showing results for 
Search instead for 
Did you mean: 

time/date

nicola_raglia
Champ in-the-making
Champ in-the-making
Hello,
I need to calculate, to get ,a current date/time in alfresco web form , with xsl.
Do you know if is there a xsl alfresco unction to get up the goal?

Thanks.
Nicola
1 REPLY 1

samuel_penn
Champ in-the-making
Champ in-the-making
I've done something similar by including dynamic content in the xsd definition in order to set a default date for some attributes, e.g.:

    <xs:include schemaLocation="/ASSETS/xsd/news-dates.jsp" />

The news-dates.jsp file then looked like this:


<?xml version="1.0"?>

<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:art="http://www.centrom.com/localgov/wcm/article"
    xmlns:alf="http://www.alfresco.org"
    targetNamespace="http://www.centrom.com/localgov/wcm/article"
    elementFormDefault="qualified">

    <xs:complexType name="currentDate">
        <xs:sequence>
<%
    java.util.Date                  now = new java.util.Date();
    java.util.Date                  expire = new java.util.Date();
    expire.setMonth(expire.getMonth()+6);
   
    java.text.SimpleDateFormat      format = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    // 10/16/08 9:15 AM
    out.println("<xs:element name=\"published\" type=\"xs:dateTime\" default=\""+format.format(now)+"\"/>");
   
    format = new java.text.SimpleDateFormat("yyyy-MM-dd");
    out.println("<xs:element name=\"expires\" type=\"xs:date\" default=\""+format.format(expire)+"\"/>");
%>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

This sets the default when the form is edited, rather than when the content is rendered. If you want to do this at rendition time, you can could do something similar with an include within the xslt, which fetches the date in a similar way. Call a webscript or jsp which outputs the current time.