2005-05-01T08:00:00Z
Dave Pawson .
link
Home
Datatypes
Sun 1 May 2005
Mike Kay gave a brief answer on the XSLT list recently, which I attempted to convert into a question for the FAQ. The basic idea was that given a duration, you can convert it to seconds by dividing by the 'duration' of one second. Oh that it were so easy. The hierarchy of datatypes means I can't divide an xs:duration by an xs:dayTimeDuration, they must both be at the same level, indeed the same subtype. Reading the WD I found impossible due to its cross spec convolutions, so finished up hacking around as best I could. An email from Mike pointed out the obvious, that calculating the number of smaller units in any month is rather difficult... anything from 28 to 31 days? Another duh! moment. I then moved to subtracting two absolute dates which did convert to seconds readily.
Trying to find more in Mikes books on XSLT 2 made me realise he (or his publishers) were just a little premature in publication. The date time stuff is woefully dated by now. I can imagine the conversations between author and publisher!
<xsl:variable name="now"
select="current-dateTime()"/>
<xsl:variable name="then"
select="xs:dateTime('1970-01-01T00:00:00')"/>
<xsl:variable name="diff"
select="xdt:dayTimeDuration($now - $then)"/>
<xsl:variable name="sec"
select="xdt:dayTimeDuration('P0DT1S')"/>
<xsl:variable name="dur"
select="$diff div $sec" as="xs:double"/>
<xsl:message>
[<xsl:value-of select="$dur "/>] secs per month
</xsl:message>
Let's see if a bit of code gets correctly transported into the weird world of bloggerdom. Nope. Usual ideas of lets keep n columns in play, so anything with whitespece which needs respect is doomed to be about 40 characters wide. No preview either! Try it, delete it and correct it. Glad I'm editing off line. At least emacs doesn't do that to me. Mmmmm. Funny. Try to edit it, and it switches into HTML mode, and my embedded markup drives it crazy. Only resolution was to delete the post, then start again.
Barbeque this afternoon, hoping the weather remains friendly. Not too bad at the moment. My wife came up with some home made burgers to take, which I'm quite looking forward to.
Sun 1 May 2005
I commented earlier about having hassle embedding a pre element in the blog. Now SAGE, the Firefox plug-in I use for reading blogs, is telling me that my blog has an XML parse error. Nothing more. Blogger.com reports nothing, just takes any old content, and tries to publish. I do wish I could find a more reliable tool, or perhaps even a more comprehensible one? Doesn't really say much for Googles choice does it.
Keywords: xslt
Comments (View)Return to main index