It can be fixed if add (bold) to UntypedValueCheck
private Item convert(Item item) throws XPathException {
if (atomize || item.getType() == Type.UNTYPED_ATOMIC ||
Type.subTypeOf(requiredType, Type.NUMBER) &&
Type.subTypeOf(item.getType(), Type.NUMBER)) {
try {
if (Type.subTypeOf(item.getType(), requiredType))
return item;
item = item.convertTo(requiredType);
} catch (XPathException e) {
error.addArgs(ExpressionDumper.dump(expression),
Type.getTypeName(requiredType),
Type.getTypeName(item.getType()));
throw new XPathException(expression, error.toString());
}
}
return item;
}
--
Cheers,
Dmitriy Shabanov
On Tue, 2010-07-06 at 09:51 +0000, SourceForge.net wrote:
> Patches item #3025768, was opened at 2010-07-06 18:51
> Message generated for change (Tracker Item Submitted) made by westbay
> You can respond by visiting:
> https://sourceforge.net/tracker/?func=detail&atid=317691&aid=3025768&group_id=17691
>
> Please note that this message will contain a full copy of the comment thread,
> including the initial issue submission, for this request,
> not just the latest update.
> Category: None
> Group: None
> Status: Open
> Resolution: None
> Priority: 5
> Private: No
> Submitted By: Michael Westbay (westbay)
> Assigned to: Nobody/Anonymous (nobody)
> Summary: Repair datetime:date-range
>
> Initial Comment:
> Problem:
>
> Trying out trunk build 11890, I found that the use of datetime:date-range no longer worked. I got an error stating that addition required either a xs:yearMonthDuration or xs:dayTimeDuration.
>
> --- being sample xquery ---
> xquery version "1.0";
> declare namespace datetime="http://exist-db.org/xquery/datetime";
> let $sdate := xs:date(datetime:format-date(current-date() - xs:dayTimeDuration('P1D'), 'yyyy-MM-dd'))
> let $step := xs:dayTimeDuration("-P1D")
> let $count := 5
> let $dates := datetime:date-range($sdate, $step, $count)
> return string-join($dates,'
')
> --- end sample xquery ---
>
> Please run the above query in the eXist Client on a recent trunk build to see the problem.
>
> As you can see, my XQuery was passing a xs:dayTimeDuration to the function, so what's the deal?
>
> Evaluation:
>
> Looking at the source code for DateRangeFunctions.java, the signature states that the second parameter is the abstract Type.DURATION. The code for this and AbstractDateTimeValue (where the addition takes place) have not changed. It appears that the value is not of type YearMonthDurationValue or DayTimeDurationValue, each derived from DurationValue, but rather a DurationValue itself. The ability to use the abstract Type.DURATION to handle either case is no longer possible.
>
> Solution:
>
> Included is a patch that modifies/adds signatures to datetime:datetime-range, datetime:date-range, and datetime:time-range specifying the second parameter to be either a xs:yearMonthDuration or xs:dayTimeDuration. There is also a check to make sure that the second parameter is one of the two allowed types. For processing, the base DurationValue type still works as it carries the specific duration type.
|