RE: Validating a duration

[email protected] Mon, 28 Jul 2003 08:00:27 +0100
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
> I am having difficulty writing a Schematron validation for a 
> duration.

Hi Robert. 
 Would this be easier using Saxon 7, with the date time 
arithmetic of XSLT 2.0?

regards DaveP

 The 
> (simplified) XML is as follows:
> 
> <entry>
>      <start-date>20030726</start-date>
>       <start-time>13:00</start-time>
>       <end-time>15:30</end-time>
>       <duration>
>           <hours>2</hours>
>           <minutes>30</minutes>
>       </duration>
> </entry>
> 
> I need to validate that the duration hours and minutes are 
> correct and this 
> is relatively easily achieved (see below) for all but the 
> edge case where 
> the end-time is at midnight, i.e. 00:00
> 
> <sch:let name="currentStartTimeSecs" 
> value="number(substring(start-time, 
> 1,2))*60 + number(substring(start-time,4,2))"/>
> <sch:let name="currentEndTimeSecs" value="number(substring(end-time, 
> 1,2))*60 + number(substring(end-time,4,2))"/>
> <sch:let name="currentCalculatedDurationSecs" 
> value="$currentEndTimeSecs - 
> $currentStartTimeSecs"/>
> 
> <sch:assert test="$currentCalculatedDurationSecs =
>                                   
> (number(normalize-space(duration/hours))*60 
> + number(normalize-space(duration/minutes)))"/>
> 
> Is there any way to detect that the end-time is 00:00 and adjust the 
> currentEndTimeSecs accordingly ?
> 
> Robert
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet
_072303_01/01
_______________________________________________
Schematron-love-in mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/schematron-love-in

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01