[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: different evaluations on sibling elements ...

Subject: Re: different evaluations on sibling elements ...
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 27 Aug 2013 18:33:04 +0100
Re:  different evaluations on sibling elements ...
On 27 Aug 2013, at 18:18, Raimund Kammering wrote:

> okay I tried this but mixed up the relative path expressions and the
location step 
>
> But still puzzling:
> The change brought me to:
> "XPTY0004: A sequence of more than one item is not allowed as the first
argument of"
>
> So I changed the lines to be:
>
>>>> <xsl:variable name="next"
select="dateTime($entry/following-sibling::entry/isodate,
$entryfollowing-sibling::entry/time)"/>
> <xsl:variable name="next"
select="dateTime($entry/following-sibling::entry[1]/isodate,
$entry/following-sibling::entry[1]/time)"/>

Again, sorry for making this all-too-common mistake!

> to only get the first following-sibling. Which brought me the following
error:
> "XPTY0004: Cannot divide two durations of different type"
>
> pointing to the line
>>>> <xsl:sequence select="($next - $this) div xs:duration('PT1H')"/>

It should have been xs:dayTimeDuration('PT1H') rather than xs:duration.
>
> Here I have a hard time understanding the formats - especially since I did
not use the XSLT 2.0 dataTime so far. Is't $this, $next simply in ISO8601 date
format of the form YYYY-MM-DDTHH:mm:ss - if so the subtraction already should
already not be okay?

If I've got it right, isodate contains a date of the form 2013-02-09, and time
contains a time of the form 23:00:00. So in fact there are two ways to
construct a dateTime instance, and I gave you a mixture of the two.

(a) use string concatenation followed by a cast:

xs:dateTime(concat(isodate, 'T', time))

(b) convert both components separately and then use the fn:dateTime() function
to combine them:

dateTime(xs:date(isodate), xs:time(time))

Sorry for making a bit of a pig's ear of it!

Michael Kay
Saxonica


>
> Raimund Kammering
>
> On 27.08.2013, at 18:37, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
>> Yes, sorry, a mistake I often make: within the function, all the relative
path expressions should start with $entry. So
>>
>>>> <xsl:variable name="this" select="dateTime($entry/isodate,
$entry/time)"/>
>>>> <xsl:variable name="next"
select="dateTime($entry/following-sibling::entry/isodate,
$entryfollowing-sibling::entry/time)"/>
>>
>> Michael Kay
>> Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.