Project

General

Profile

« Previous | Next » 

Revision 48505

Properly handle dates with xslt 2

View differences:

sfi_2_db.xsl
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 3
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
                exclude-result-prefixes="xs" version="1.0">
4
                exclude-result-prefixes="xs" version="2.0">
5 5

  
6 6
	<xsl:param name="parentDatasourceId"/>
7 7
	<xsl:param name="namespacePrefix"/>
......
43 43
								<xsl:value-of select="$parentDatasourceId"/>
44 44
							</FIELD>
45 45
							<FIELD name="provenanceactionclass">sysimport:crosswalk:entityregistry</FIELD>
46
							<!-- oa_mandate_for_publications is true for projects started after 2005 -->
47
							<xsl:choose>
48
								<!-- Invalid date: we need at least YYYY -->
49
								<xsl:when test="string-length($startDate) &lt; 4">
50
									<FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
51
								</xsl:when>
52
								<xsl:when test="xs:date($startDate) >= xs:date('2009-01-01')">
53
									<FIELD name="oa_mandate_for_publications" type="boolean">true</FIELD>
54
								</xsl:when>
55
								<xsl:otherwise><FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD></xsl:otherwise>
56
							</xsl:choose>
46
							<!-- 30/06/2016 must be converted into 2016-06-30-->
47
							<xsl:variable name="date" select="xs:date(concat(
48
							            substring($startDate,7,4),'-',
49
							            substring($startDate,4,2),'-',
50
							            substring($startDate,1,2)))"/>
51
							<FIELD name="oa_mandate_for_publications" type="boolean"><xsl:value-of select="$date &gt;= xs:date('2009-01-01')"/> </FIELD>
57 52
						</ROW>
58 53

  
59 54
						<xsl:if test="normalize-space(.//column[@name='Programme Name'])">

Also available in: Unified diff