RE: date calculations
> > StartTime + Duration > > This feels a bit wrong to me, along the lines of augmenting > the xml with defaulted attributes - by doing this aren't you > then relying on the input being validating every time the > transform runs, even if the xml hasn't changed? Yes, you're relying on the input being typed, and it would certainly be my recommendation to make that assumption explicit in your code, for example by writing: <xsl:template match="document-node(schema-element(invoice))"> ... process an invoice ... </xsl:template> <xsl:template match="/"> <xsl:message terminate="yes">Input document is not a validated invoice!</xsl:message> </xsl:template> That's a better way of doing it than writing a cast, I think. > > You don't seem to be gaining much over being explicit with > the types in the stylesheet... In this example, that's possibly true. When you're calling a lot of functions, I think the benefits become clearer. I have to admit I wasn't a great enthusiast for doing date-time-duration arithmetic by overloading the arithmetic operators rather than by using custom functions. Two reasons: (a) it means I can't infer that the result of an addition will always be numeric, which means I have to insert extra run-time type checking, and (b) with a custom function like fn:add-duration-to-dateTime(xs:dateTime, xs:dayTimeDuration) you would get implicit casting of untyped values to the expected types of the operands, which you don't get with the overloaded + operator. But that's water under the bridge. Michael Kay http://www.saxonica.com/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format