Not using exslt for quite a bit of time. If you have xslt2 processor available, like saxon, you can directly use fn:seconds-from-duration() xpath function directly (where its namespace is internally recognized, or you can explicitly declared it to http://www.w3.org/2005/xpath-functions with the prefix fn). It takes an argument of xs:duration. Prefix xs is the usual w3 schema namespace that you must declare it, though.
If you _must_work with exslt, I perhaps could take a look in the direction. In that case, tell more about your related namespace declarations and xsl:import ... structure you have in place.
posted 1 year ago
Hi g tsuji,
Thanks for your response.
The 'else if' part of the conditional statement returns milliseconds, rather than seconds.
I corrected it by dividing the result in that line by 1000: return oDate.Seconds()/1000.
posted 1 year ago
Excellent. Thank you for underlining that.
I have kept a copy of exslt download when exslt official site still provided itself a download link. The copy contains still so many bugs that I had to modify it to make it work for some functionality that I needed. It contains bugs even at the level some basic like inconsistent namespace declarations (like http://exslt.org/dates-and-times wrongly written as http://exslt.org/dates and times and http://exslt.org/Dates and Times etc...) and xsl:import line written after func:script lines etc.
I have taken a look at the latest kept available at github, many have been rectified and apparently the "bug" you observed is still there.
To keep the story short, the correction you proposed should work for the present case. But I would rather propose a modification of the original script at the function return of Duration() which takes on eight arguments, including the last argument fraction. To properly taking into account of more general case, modification should be made there... A preliminary modification could be like this at the return line (I break up the line for clarity reason).
Maybe you are in a position to make a fair opinion about it in comparison with yours. In this version, the fractional second will be preserved otherwise it would be lost affecting obviously the precision of the data.