[ Pobierz całość w formacie PDF ]
.XQuery knows that these are equivalent.This is not true for thenumeric constructors and other constructors.For instance, the fol-lowing code shows a few of the constructors.xs:decimal(string $srcval) => decimalxs:integer(string $srcval) => integerxs:Name(string $srcval) => Namexs:QName(string $srcval) => QNamexs:boolean(string $srcval) => booleanxs:duration(string $srcval) => durationxs:dateTime(string $srcval) => dateTimeEach of these requires the xs namespace preamble to be recog-nized correctly by XQuery.For instance, xs:decimal( 183.28 ) takesthe string 183.28 as an input and returns an xs:decimal value.User-defined FunctionsXQuery could have been a quaint and ineffectual competitor to SQLif the XQuery Working Group did not add user-defined functions tothe language specification.User-defined functions appear in the pro-log section of an XQuery.The parameters and results may be primi-tive values, nodes, and sequences.For instance, the following code implements a simple functionthat takes two values and returns the lesser of the two values.7.4 A Tour of XQuery 179declare function local:lesser($a as xs:decimal?, $b as xs:decimal? ) as xs:decimal?{if ( $a
[ Pobierz całość w formacie PDF ]