This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* AXEL Plugin | |
* | |
* Sample input element transformed into an AXEL plugin (called "date" in this example) but this is a plain vanilla plugin | |
* | |
* The purpose is to have an example to brainstorm on AXEL plugin API and keyboard manager API | |
* | |
* Synopsis : | |
* - <xt:use types="date">default value</xt:use> | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare function local:localize( $path as xs:string, $languages as xs:string, $deflang as xs:string ) as xs:string { | |
let $options := tokenize($languages," ") | |
let $code := if (matches($path,"^/\w\w/?$|^/\w\w/")) then substring($path, 2, 2) else () | |
return | |
if ($code = $options) then | |
(: valid 2-letters language code in URL path, return it :) | |
$code | |
else | |
if ($code) then | |
(: wrong code in URL path, pickup default language and most probably will trigger a 404 error :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: ====================================================================== | |
Returns a label (in French or English) to print $date as a month-day | |
("on March 15") or as a short label ("today", "yesterday", | |
"the day before yesterday") depending on current dateTime | |
====================================================================== | |
:) | |
declare function local:gen-display-date( $date as xs:string, $lang as xs:string ) as xs:string | |
{ | |
let $today := current-dateTime() | |
let $dur := $today - xs:dateTime($date) |