XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (329 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.17Mb size Format: txt, pdf, ePub

The way that the variable acquires its value is up to the host language. In many languages there will not be a meaningful distinction between declaring a variable (in the static context) and giving it a value (in the dynamic context). In XSLT there is no distinction in the case of

, but there is in the case of

. In the example on page 559, we showed a stylesheet parameter declared as:


The value supplied to this parameter when the stylesheet is invoked becomes part of the dynamic context for every XPath expression in the stylesheet. If no value is supplied, the dynamic context contains the default value, which in this case is the empty sequence,
()
.

Function Implementations

For every function defined in the static context of the expression, there must be an implementation available so that the function can be called and can return a result.

I don't think this is saying anything very profound, so I will move on. It does make the point that although the signatures of the in-scope functions must be known when the XPath expression is compiled, there is scope for substituting different implementations of the function at runtime.

Current dateTime

The specification tries to ensure that all the information that an XPath expression can depend on is included formally as part of the context. An XPath expression that uses the functions
current-date()
,
current-time()
, or
current-dateTime()
depends on the current date and time, so this is modeled as part of the dynamic context.

XPath is designed on the basis that functions are always pure functions, and a characteristic feature of a pure function is that when you call it repeatedly, it returns the same result each time. The current date and time in the dynamic context are therefore defined not to change during the execution of an XPath expression. In fact, in XSLT, they are defined not to change during the execution of an entire stylesheet. This means that the functions are not useful for applications such as performance instrumentation; they are intended rather for recording the approximate time at which a stylesheet or query was executed, and for use in business logic calculations such as displaying a date three days from today.

Implicit Timezone

XML Schema allows values to be specified without a timezone, for example, as
2008-01-31 T22:00:00
. This can be interpreted as meaning that the timezone is unknown, but this interpretation makes life very complicated when dates and times are compared with each other: it means, for example, that
2008-01-31
is definitely earlier than
2008-02-05
, but it's uncertain whether
2008-01-31
is earlier than
2008-02-01
, because if the first date is used in a part of the world whose timezone is
-12:00
, it refers to the same period of 24 hours as the second date in a place whose timezone is
+12:00

Other books

The Bounty Hunter's Bride by Victoria Bylin
Protect Me by Jennifer Culbreth
Tanya Anne Crosby by The Impostor's Kiss
Blackmailed Merger by Kelly, Marie
The Bride Who Bailed by Carrera, Misty
Rescue Me by Farrah Rochon
Aurora 07 - Last Scene Alive by Charlaine Harris