![]() ![]() ![]() ![]() ![]() ![]() |
This chapter provides descriptions of the XQuery type conversion functions available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery functions. To learn more, see Invoking Functions or Operators in a Query.
In addition to the XQuery functions available in the mapper functionality of WebLogic Workshop, a larger set functions is provided. You can manually add invocations to these functions to queries in the Source View of the mapper functionality. For a list of these additional functions, see the XQuery 1.0 and XPath 2.0 Functions and Operators - W3C Working Draft 16 August 2002 available from the W3C Web site at the following URL:
http://www.w3.org/TR/2002/WD-xquery-operators-20020816
This section lists the type conversion functions available from the mapper functionality:
Converts the value of $item-var
to a string.
If $item-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:string
(item* $item-var
) —>xs:
string
Returns the representation of $item-var
as a string.
When you invoke the following query:
let $i := <book>The Toad</book>
return <author>{xs:string($i)}</author>
The following result is generated:
When you invoke the following query:
return (<integer>{xs:string($num)}</integer>)
The following result is generated:
When you invoke the following query:
return (<float>{xs:string($num)}</float>)
The following result is generated:
When you invoke the following query:
let $boolean-var := xs:boolean("true")
return (<boolean>{xs:string($boolean-var)}</boolean>)
The following result is generated:
W3C string function description
Converts $string-var
(a string) to a decimal value.
If $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:decimal
(xs:
string $string-var
) —> xs:
decimal
Returns the decimal value of $string-var
Invoking decimal("2.2")
returns the decimal value 2.2 as shown in the following example query:
<decimal>{xs:decimal("2.2")}</decimal>
The preceding query generates the following result:
Invoking decimal(())
returns an empty sequence. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
For example, the following example query:
<decimal>{xs:decimal(())}</decimal>
The preceding query generates the following result:
W3C decimal data type description
Converts $string-var
(a string) to an integer value.
If the value of $string-var
is greater than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808, the TransformException exception is raised with the SYS_LONG_OVERFLOW
fault code. The following error message is displayed in the mapper:
Error occurred while executing XQuery: BigDecimal -> Long overflow!
Note: | For performance reasons, the integer supported by this XQuery engine is equivalent to a Java long, which is smaller than the W3C XML Schema integer, which has an arbitrary length. To learn more, see the integer description. |
Note: | The value $string-var must be specified without commas as shown in the following example invocation: |
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:integer
(xs:
string $string-var
) —> xs: integer
Returns an integer value of $string-var
Invoking integer("10402")
returns the integer value 10402 as shown in the following example query:
<integer>{xs:integer("10402")}</integer>
The preceding query generates the following result:
Invoking integer("104.0")
outputs an error because the decimal point is not allowed in the argument.
For example, the following example query:
<integer>{xs:integer("104.0")}</integer>
Error occurred while executing XQuery: Could not cast "104.0" to type [integer@http://www.w3.org/2001/XMLSchema]
Invoking integer("foo")
outputs an error because "foo"
is not a number.
For example, the following example query:
<integer>{xs:decimal("foo")}</integer>
Error occurred while executing XQuery: Could not cast "foo" to type [integer@http://www.w3.org/2001/XMLSchema]
Invoking integer(())
returns an empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
<integer>{xs:integer(())}</integer>
The preceding query generates the following result:
An integer value in this XQuery engine has a maximum size of 9,223,372,036,854,775,807 and a minimum size of -9,223,372,036,854,775,808. For performance reasons, the integer supported by this XQuery engine is equivalent to a Java long, which is smaller then the W3C XML Schema integer, which has an arbitrary length.
integer data type description
Getting the TransformException Fault Code Programmatically
Converts $string-var
(a string) to a
long value.
If the value of $string-var
is greater than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808, the following error message is displayed:
Error occurred while executing XQuery: Could not cast "9223372036854775809" to type [long@http://www.w3.org/2001/XMLSchema]
Note: | The value $string-var must be specified without commas as shown in the following example invocation: |
If $string-var
is the empty sequence, the empty sequence is returned.
The empty sequence is a sequence containing zero items()
, which is similar to null in SQL.s
xs:long(xs:
string $string-var)
—> xs:
long
Returns the long value of $string-var
.
Invoking long("10403")
returns the integer value 10403
as shown in the following example query:
<long>{xs:long("10403")}</long>
The preceding query generates the following result:
Invoking long("104.0")
outputs an error because 104.0
is not a valid integer (decimal point is not allowed.)
For example, the following example query:
<long>{xs:long("104.0")}</long>
Error occurred while executing XQuery: Could not cast "104.0" to type [long@http://www.w3.org/2001/XMLSchema]
Invoking long("foo")
outputs an error because "foo"
is not a number.
For example, the following example query:
Error occurred while executing XQuery: Could not cast "foo" to type [long@http://www.w3.org/2001/XMLSchema]
Invoking long(())
returns an empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
The preceding query generates the following result:
W3C long data type description
Converts $string-var
(a string) to an
int value.
If the value of $string-var
is greater than 2,147,483,647 or less than -2,147,483,648, the following error is produced:
Error occurred while executing XQuery: Could not cast "2147483649" to type [int@http://www.w3.org/2001/XMLSchema]
Note: | The value $string-var must be specified without commas as shown in the following example invocation: |
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in sSQL.
xs:int(xs:
string $string-var) —>xs: int
Returns the int value of $string-var
.
Invoking int("10403")
returns the integer value 10403
as shown in the following example query:
The preceding query generates the following result:
Invoking int("104.0")
outputs an error because 104.0
not a valid integer (decimal point is not allowed.)
For example, the following example query:
Error occurred while executing XQuery: Could not cast "104.0" to type [int@http://www.w3.org/2001/XMLSchema]
Invoking int("foo")
outputs an error because "foo"
is not a number.
For example, the following example query:
Error occurred while executing XQuery: Could not cast "foo" to type [int@http://www.w3.org/2001/XMLSchema]
Invoking int(())
returns an empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
The preceding query generates the following result:
W3C int data type description
Converts $string-var
(a string) to a
short value.
If the value of $string-var
is greater than 32,767 or less than -32,768, the following error is produced:
Error occurred while executing XQuery: Could not cast "32769" to type [short@http://www.w3.org/2001/XMLSchema]
If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:short(xs:
string $string-var) —>xs: short
Returns the short value of $string-var
.
Invoking short("10403")
returns the integer value 10403
as shown in the following example query:
<short>{xs:short("10403")}</short>
The preceding query generates the following result:
Invoking short("104.0")
outputs the an error because 104.0
is not a valid integer (decimal point is not allowed.)
For example, the following example query:
<short>{xs:short("104.0")}</short>
Error occurred while executing XQuery: Could not cast "104.0" to type [short@http://www.w3.org/2001/XMLSchema]
Invoking short("foo")
outputs an error because "foo"
is not a number.
For example, the following example query:
<short>{xs:short("foo")}</short>
Error occurred while executing XQuery: Could not cast "foo" to type [short@http://www.w3.org/2001/XMLSchema]
Invoking short(())
returns an empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
The preceding query generates the following result:
W3C short data type description
Converts $string-var
(a string) to a
byte value.
If the value of $string-var
is greater than 127 or less than -128, the following error is produced:
Error occurred while executing XQuery: Could not cast "129" to type [byte@http://www.w3.org/2001/XMLSchema]
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:byte(xs:
string $string-var) —>xs:
byte
Returns the byte
value of $string-var
.
Invoking byte("104")
returns the integer value 104
as shown in the following example query:
The preceding query generates the following result:
Invoking byte("104.0")
outputs an error because 104.0
is not a valid integer (decimal point is not allowed.)
For example, the following example query:
<byte>{xs:byte("104.0")}</byte>
Error occurred while executing XQuery: Could not cast "104.0" to type [byte@http://www.w3.org/2001/XMLSchema]
Invoking byte("foo")
outputs an error because "foo"
is not a number.
For example, the following example query:
Error occurred while executing XQuery: Could not cast "foo" to type [byte@http://www.w3.org/2001/XMLSchema]
Invoking byte(())
returns an empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
The preceding query generates the following result:
W3C byte data type description.
Converts $string-var
(a string) to a 32 bit floating point value. The data type float corresponds to the IEEE single-precision 32-bit floating point type
(IEEE Std 754-1985).
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:float(xs:
string $string-var) —>xs:
float
Returns the floating point value of $string-var
.
Invoking float("1.1")
returns the floating point value of 1.1
as shown in the following example query:
<float>{xs:float("1.1")}</float>
The preceding query generates the following result:
Invoking float("-104.345e2")
returns the floating point value of -10434.5
as shown in the following example query:
<float>{xs:float("-104.345e2")}</float>
The preceding query generates the following error:
The string: NaN
(Not a Number) is a legal argument, as shown in the following example query:
<float>{xs:float("NaN")}</float>
The preceding query generates the following result:
The strings: INF
(positive infinity) and -INF
(negative infinity) are legal arguments as shown in the following example query:
<positive>{xs:float("INF")}</positive>
<negative>{xs:float("-INF")}</negative>
The preceding query generates the following result:
<negative>-Infinity</negative>
Invoking float("10.1e2.1")
outputs an error because 2.1
is not an integer. For example, the following example query:
<float>{xs:float("10.1e2.1")}</float>
Error occurred while executing XQuery: Could not cast "10.1e2.1" to type [float@http://www.w3.org/2001/XMLSchema]
Invoking float(())
returns the empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
For example, the following example query:
The preceding query generates the following result:
W3C float data type description
Converts $string-var
(a string) to a double precision (64 bit) floating point value.
The data type double corresponds to IEEE double-precision 64-bit floating point type ( IEEE 754-1985).
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:double(xs:
string $string-var) —> xs:
double
Returns the double precision floating point value of $string-var
.
Invoking double("1.1")
returns the double precision floating point value of 1.1
as shown in the following example query:
<double>{xs:double("1.1")}</double>
The preceding query generates the following result:
Invoking double("-104.345e2")
returns the double floating point value of -10434.5
as shown in the following example query:
<double>{xs:double("-104.345e2")}</double>
The preceding query generates the following result:
The string: NaN
(Not a Number) is a legal argument, as shown in the following example query:
<double>{xs:double("NaN")}</double>
The preceding query generates the following result:
The strings: INF
(positive infinity) and -INF
(negative infinity) are legal arguments as shown in the following example query:
<positive>{xs:double("INF")}</positive>
<negative>{xs:double("-INF")}</negative>
The preceding query generates the following result:
<negative>-Infinity</negative>
Invoking double("10.1e2.1")
outputs an error because 2.1
is not an integer. For example, the following example query:
<double>{xs:double("10.1e2.1")}</double>
Error occurred while executing XQuery: Could not cast "10.1e2.1" to type [double@http://www.w3.org/2001/XMLSchema]
Invoking double(())
returns the empty sequence. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL
For example, the following example query:
<double>{xs:double(())}</double>
The preceding query generates the following result:
W3C double data type description
Converts the value of $node-var
(XML element) to a double precision floating point value.
xf:
number(xf
: node $node-var) —> xs:
double
Returns the double precision floating point value of $node-var
.
When you invoke the following query:
let $numnode := <a><b>12.1</b></a>
return (<num>{xf:number($numnode/b)}</num>
)
The following result is generated:
W3C number function description
Converts a sequence of XML nodes into a sequence of integers. This function is usually used in conjunction with the xf: max and xf: min functions.
bea-xf:
: integer-sequence(
node*$node-var)
—> xs:integer*
Returns a sequence of integers converted from XML nodes.
Invoking the following query returns a sequence of integers, as shown in the following example query:
return <result>{bea-xf:integer-sequence(($x,$y,$z))}</result>
The preceding query generates the following result:
Converts a $string-var
(a string) to a boolean value.
xs:
boolean(xs:
string $string-var)—> xs:
boolean
Returns the boolean value of the passed in string.
Invoking xs:boolean
("false") returns the boolean value false
, as shown in the following example query:
<result>{xs:boolean("false")}</result>
The preceding query generates the following result:
Invoking xs:boolean
("1") returns the boolean value true
, as shown in the following example query:
<result>{xs:boolean("1")}</result>
The preceding query generates the following result:
W3C boolean function description
Converts $string-var
(a string in the dateTime format) to the
dateTime data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
If the value of $string-var
is not valid to the dateTime format the following error is reported:
Could not cast
"invalid_dateTime_string"
to type
[date@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_dateTime_string is the string not valid to the date format, for example: "2003-08-16T21:10"
.
xs: dateTime(xs:
string $string-var) —> xs:
dateTime
Returns the specified date and time in the dateTime data type.
Invoking dateTime
("2003-08-16T21:10:50") returns a date Time value corresponding to August 16th, 2003 at 9:10PM (21:10 in twenty four hour time) and 50 seconds in the current time zone, as shown in the following example query:
let $mydate := xs:dateTime("2003-08-16T21:10:50")
<year>{xf:get-year-from-dateTime($mydate)}</year>
<month>{xf:get-month-from-dateTime($mydate)}</month>
<day>{xf:get-day-from-dateTime($mydate)}</day>
<hour>{xf:get-hours-from-dateTime($mydate)}</hour>
<minute>{xf:get-minutes-from-dateTime($mydate)}</minute>
<second>{xf:get-seconds-from-dateTime($mydate)}</second>
The preceding query, generates the following XML result:
Invoking dateTime("2003-08-16T21:10:50.577")
returns a date Time value corresponding to August 16th, 2003 at 9:10 PM (21:10 in twenty four hour time) and 50.577 seconds in the current time zone, as shown in the following example query:
let $mydate := xs:dateTime("2003-08-16T21:10:50.557")
<year>{xf:get-year-from-dateTime($mydate)}</year>
<month>{xf:get-month-from-dateTime($mydate)}</month>
<day>{xf:get-day-from-dateTime($mydate)}</day>
<hour>{xf:get-hours-from-dateTime($mydate)}</hour>
<minute>{xf:get-minutes-from-dateTime($mydate)}</minute>
<second>{xf:get-seconds-from-dateTime($mydate)}</second>
The preceding query, generates the following XML result:
Invoking dateTime("2003-08-16T21:10:50Z")
returns a date Time value corresponding to August 16th, 2003 at 9:10 PM (21:10 in twenty four hour time) and 50 seconds, in the UTC time zone, as shown in the following example query:
let $mydate := xs:dateTime("2003-08-16T21:10:50Z")
<year>{xf:get-year-from-dateTime($mydate)}</year>
<month>{xf:get-month-from-dateTime($mydate)}</month>
<day>{xf:get-day-from-dateTime($mydate)}</day>
<hour>{xf:get-hours-from-dateTime($mydate)}</hour>
<minute>{xf:get-minutes-from-dateTime($mydate)}</minute>
<second>{xf:get-seconds-from-dateTime($mydate)}</second>
The preceding query, generates the following XML result:
Invoking dateTime("2003-08-16T13:10:50-07:00")
returns a date Time value corresponding to August 16th, 2003 at 1:10 PM (13:10 in twenty four hour time) and 50 seconds, in the Pacific Daylight Savings (PDT) time zone that is offset by -7 hours from UTC (Universal Time, Coordinated), as shown in the following example query:
let $mydate := xs:dateTime("2003-08-16T13:10:50-07:00")
<year>{xf:get-year-from-dateTime($mydate)}</year>
<month>{xf:get-month-from-dateTime($mydate)}</month>
<day>{xf:get-day-from-dateTime($mydate)}</day>
<hour>{xf:get-hours-from-dateTime($mydate)}</hour>
<minute>{xf:get-minutes-from-dateTime($mydate)}</minute>
<second>{xf:get-seconds-from-dateTime($mydate)}</second>
The preceding query, generates the following XML result:
The conversion of the date and time is shown in the following figure
Invoking dateTime("2003-08-16T21:10")
outputs an error because seconds are not specified.
For example, the following example query:
<result>{xs:dateTime("2003-08-16T21:10")}</result>
Error occurred while executing XQuery: Could not cast "2003-08-16T21:10" to type [dateTime@http://www.w3.org/2001/XMLSchema]
Invoking dateTime("2003-8-16T21:10:50")
outputs an error because the month is not specified using two digits.
For example, the following example query:
<result>{xs:dateTime("2003-8-16T21:10:50")}</result>
Error occurred while executing XQuery: Could not cast "2003-8-16T21:10:50" to type [dateTime@http://www.w3.org/2001/XMLSchema]
W3C dateTime data type description
Converts $string-var
(a string in the date format) to the
date data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned.The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
If the value of $string-var is not valid to the date format the following error is reported:
Could not cast
"invalid_date_string"
to type
[date@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_date_string is the string not valid to the date format, for example: "2003-04-31"
.
xs:date(xs:
string $string-var)—> xs:
date
Returns the specified date in the date data type.
Invoking date("2003-08-16")
returns a date value corresponding to August 16th, 2003 in the current time zone, as shown in the following example query:
let $mydate := xs:date("2003-08-16")
<year>{xf:get-year-from-date($mydate)}</year>
<month>{xf:get-month-from-date($mydate)}</month>
<day>{xf:get-day-from-date($mydate)}</day>
The preceding query, generates the following XML result:
Invoking date("2003-08-16Z")
returns a
date value corresponding to August 16th, 2003 in the UTC time zone, as shown in the following example query:
let $mydate := xs:date("2003-08-16Z")
<year>{xf:get-year-from-date($mydate)}</year>
<month>{xf:get-month-from-date($mydate)}</month>
<day>{xf:get-day-from-date($mydate)}</day>
Note: | The Z in the a date string, specifies that the date is specified in the UTC time zone. |
The preceding query, generates the following XML result:
Invoking date("2003-08-16-02:00")
returns a date value corresponding to August 16th, 2003 in a time zone that is offset by -2 hours from UTC, as shown in the following example query:
let $mydate := xs:date("2003-08-16-02:00")
<year>{xf:get-year-from-date($mydate)}</year>
<month>{xf:get-month-from-date($mydate)}</month>
<day>{xf:get-day-from-date($mydate)}</day>
The preceding query, generates the following XML result:
Invoking date("2003-04-31")
outputs an error because April 31, 2003 is not a valid date. (There is no 31 day in April.)
For example, the following example query:
<result>{xs:date("2003-04-31")}</result>
Error occurred while executing XQuery: Could not cast "2003-04-31" to type [date@http://www.w3.org/2001/XMLSchema]
Invoking date("2003-8-16")
outputs an error because the month is not specified using two digits.
For example, the following example query:
<result>{xs:date("2003-8-16")}</result>
Error occurred while executing XQuery: Could not cast "2003-8-16" to type [date@http://www.w3.org/2001/XMLSchema]
W3C date data type description
Converts $string-var
(a string in the time format) to the
time data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
If the value of $string-var
is not valid to the time format the following error is reported:
Could not cast
"invalid_time_string"
to type
[time@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_time_string is the string not valid to the time format, for example: "23:5:44"
.
xs:
time(xs:
string $string-var)—>xs: time
Returns the specified time in the time data type.
Invoking time("23:15:45")
returns a time value corresponding to 11:15
PM and 45
seconds in the current time zone, as shown in the following example query:
let $mytime := xs:time("23:15:45")
<hours>{xf:get-hours-from-time($mytime)}</hours>
<minutes>{xf:get-minutes-from-time($mytime)}</minutes>
<seconds>{xf:get-seconds-from-time($mytime)}</seconds>
The preceding query, generates the following XML result:
Invoking time("23:15:45Z")
returns a time value corresponding to 11:15
PM and 45
seconds in the UTC time zone, as shown in the following example query:
let $mytime := xs:time("23:15:45Z")
<hours>{xf:get-hours-from-time($mytime)}</hours>
<minutes>{xf:get-minutes-from-time($mytime)}</minutes>
<seconds>{xf:get-seconds-from-time($mytime)}</seconds>
The preceding query, generates the following XML result:
Invoking time("23:5:44")
outputs an error because the minutes is not specified using two digits.
For example, the following example query:
<result>{xs:time("23:5:44")}</result>
Error occurred while executing XQuery: Could not cast "23:5:44" to type [time@http://www.w3.org/2001/XMLSchema
]
W3C time data type description
Converts $string-var
(a string in the gYearMonth format) to the
gYearMonth data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned.The empty sequence is a sequence containing zero items()
, which is similar to null in SQL.
If the value of $string-var
is not valid to the gYearMonth format, the following error is reported:
Could not cast
"invalid_gYearMonth_string"
to type
[gYearMonth@http://www.w3.org/2001/XMLSchema]
is displayed.
Where invalid_gYearMonth_string is the string not valid to the time format, for example: "2003-8"
.
xs:
gYearMonth(xs:
string $string-var)—> xs: gYearMonth
Represents a string with the month and year specified with one of the following formats: |
|||
Returns the specified month and year in the gYearMonth data type.
Invoking gYearMonth("2003-08")
returns a gYearMonth
value corresponding to August 2003, as shown in the following example query:
<result>{xs:gYearMonth("2003-08")}</result>
The preceding query, generates the following XML result:
Invoking gYearMonth("2003-08Z")
returns a gYearMonth value corresponding to August 2003 in the UTC time zone, as shown in the following example query:
<result>{xs:gYearMonth("2003-08Z")}</result>
The preceding query, generates the following XML result:
Invoking gYearMonth("2003-8")
outputs an error because the month is not specified using two digits.
For example, the following example query:
<result>{xs:gYearMonth("2003-8")}</result>
Error occurred while executing XQuery: Could not cast "2003-8" to type [gYearMonth@http://www.w3.org/2001/XMLSchema]
W3C gYearMonth data type description
Converts $string-var
(a string in the gYear format) to the
gYear data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
If the value of $string-var
is not valid to the gYear format, the following error is reported:
Could not cast
"invalid_gYear_string"
to type [gYear@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_gYear_string is the string not valid to the time format, for example: "20-2003"
.
xs:
gYear(xs:
string $string-var)—> xs:
gYear
Returns the specified year in the gYear data type.
Invoking gYear("2003")
returns a gYearvalue corresponding to the year 2003, as shown in the following example query:
<result>{xs:gYear("2003")}</result>
The preceding query, generates the following XML result:
Invoking gYear("2003Z")
returns a gYear value corresponding to the year 2003
in the UTC time zone, as shown in the following example query:
<result>{xs:gYear("2003Z")}</result>
The preceding query, generates the following XML result:
W3C gYear data type description
Converts $string-var
(a string in the gMonthDay format) to the
gMonthDay data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
If the value of $string-var
is not valid to the gMonthDay format, the following error is reported:
Could not cast
"invalid_gMonthDay_string"
to type [gMonthDay@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_gMonthDay_string is the string not valid to the time format, for example: "08-15".
xs:
gMonthDay(xs:
string $string-var)—> xs:gMonthDay
Represents a string with the month and day specified with one of the following formats: |
|||
Returns the specified month and day in the gMonthDay data type.
Invoking gMonthDay("--08-15")
returns a gMonthDay value corresponding to August 15, as shown in the following example query:
<result>{xs:gMonthDay("--08-15")}</result>
The preceding query, generates the following XML result:
Invoking gMonthDay("--08-15Z")
returns a gMonthDay value corresponding to August 15 in the UTC time zone, as shown in the following example query:
<result>{xs:gMonthDay("--08-15Z")}</result>
The preceding query, generates the following XML result:
Invoking gMonthDay("08-15")
outputs an error because the --
prefix is missing.
For example, the following example query:
<result>{xs:gMonthDay("08-15")}</result>
Error occurred while executing XQuery: Could not cast "08-15" to type [gMonthDay@http://www.w3.org/2001/XMLSchema]
W3C gMonthDay data type description
Converts $string-var
(a string in the gMonth format) to the
gMonth data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned.The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
If the value of $string-var
is not valid to the gMonth format, the following error is reported:
Could not cast
"invalid_gMonth_string"
to type [gMonth@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_gMonth_string is the string not valid to the time format, for example: "08".
xs:
gMonth(xs:
string $string-var)—> xs:gMonth
Returns the specified month in the gMonth data type.
Invoking gMonth("--08--")
returns a gMonth value corresponding to the month of August, as shown in the following example query:
<result>{xs:gMonth("--08--")}</result>
The preceding query, generates the following XML result:
Invoking gMonth("--08--Z")
returns a gMonth value corresponding to the month of August in the UTC time zone, as shown in the following example query:
<result>{xs:gMonth("--08--Z")}</result>
The preceding query, generates the following XML result:
Invoking gMonth("08")
outputs an error because the --
prefix is missing.
For example, the following example query:
<result>{xs:gMonth("08")}</result>
Error occurred while executing XQuery: Could not cast "08" to type [gMonth@http://www.w3.org/2001/XMLSchema]
W3C gMonth data type description
Converts $string-var
(a string in the gDay format) to the
gDay data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
If the value of $string-var
is not valid to the gDay format, the following error is reported:
Could not cast
"invalid_gDay_string"
to type [gDay@http://www.w3.org/2001/XMLSchema] is displayed.
Where invalid_gDay_string is the string not valid to the time format, for example: "15".
xs:
gDay(xs:
string $string-var)—>xs:gDay
Returns the specified day in the gDay data type.
Invoking gDay("---15")
returns a gDay value corresponding to the15th of the month, as shown in the following example query:
<result>{xs:gDay("---15")}</result>
The preceding query, generates the following XML result:
Invoking gDay("---15Z")
returns a gDay value corresponding to the 15th of the month in the UTC time zone, as shown in the following example query:
<result>{xs:gDay("---15Z")}</result>
The preceding query, generates the following XML result:
Invoking gDay("15")
outputs an error because the ---
prefix is missing.
For example, the following example query:
<result>{xs:gDay("15")}</result>
Error occurred while executing XQuery: Could not cast "15" to type [gDay@http://www.w3.org/2001/XMLSchema]
W3C gDay data type description
Converts $string-var
(a string in the duration format) to the
duration data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:
duration(xs:
string $string-var)—> xs:duration
Represents a string with the duration specified with one of the following formats: |
|||||
|
|||||
Returns a duration of time as a duration value.
Invoking duration("P1Y2M4DT9H8M20S")
returns a duration value corresponding to 1 year, 2 months, 4 days, 9 hours, 8 minutes, and 20 seconds, as shown in the following example query:
<result>{xs:duration("P1Y2M4DT9H8M20S")}</result>
The preceding query, generates the following XML result:
<result>P1Y2M4DT9H8M20S</result>
Invoking duration("P9Y")
returns a duration value corresponding to 9 years, as shown in the following example query:
<result>{xs:duration("P9Y")}</result
>
The preceding query, generates the following XML result:
Invoking duration("-P10M")
returns a duration value corresponding to negative 10 months as shown in the following example query:
<result>{xs:duration("-P10M")}</result>
The preceding query, generates the following XML result:
Invoking duration("P4DT20S")
returns a
duration value corresponding to 4 days and 20 seconds, as shown in the following example query:
<result>{xs:duration("P4DT20S")}</result>
The preceding query, generates the following XML result:
W3C duration data type description
Converts $string-var
that contains a URI (Uniform Resource Identifier Reference) to the
anyURI data type.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:
anyURI(xs:
string $string-var)—>xs: anyURI
Returns the $string-var
converted to anyURI data type.
When you invoke the following query:
<result>{xs:anyURI("http://www.acme.org/")}</result>
The preceding query generates the following result:
<result>http://www.acme.org/</result>
W3C anyURI data type description
Converts $string-var
to the
Name data type.
If the value of $string-var
is the empty sequence the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:
Name(xs:
string $string-var)—> xs: Name
Returns the $string-var
converted to the Name data type.
W3C Name data type description
Creates a new
QName with a local name specified $string-var
and no namespace.
If the value of $string-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xs:
QName(xs:
string $string-var)—> xs: QName
Returns the $string-var
converted to the
QName data type.
W3C QName data type description
![]() ![]() ![]() |