<ws>type

NAME
SYNOPSIS
SYNTAX
DESCRIPTION
NOTES
KEYWORDS

______________________________________________________________________________

NAME

wstype − commands

SYNOPSIS

TWiST is a front-end toolkit for rapidly deploy Tcl procedures as a web service. The simplified API of TWiST consists of only three operational procedures: <ws>namespace, <ws>proc and <ws>return. The names reflect the underlying Tcl commands. Type definition procedures include <ws>type and <ws>element.

<ws>type commands allow derivation of simpleTypes from the built in XML-Schema types. The typeName parameter is a combination of the type namespace prefix and the type name, for instance stock::Symbol or stock:Symbol (the number of colons does not affect the result). The subcommand can be abbreviated, with optional characters shown in square brackets, as in enum[eration].

SYNTAX

<ws>type exists typeName

<ws>type sim[ple] typeName ?base?

<ws>type enum[eration] typeName enumList ?base?

<ws>type pat[tern] typeName pattern ?base?

<ws>type decimalRest[riction] typeName restrictionList ?base?

<ws>type q[uery] typeName

<ws>type valid[ate] typeName value

_________________________________________________________________

DESCRIPTION

TWiST provides several APIs for defining types. All types are based upon built in types as described in XML-Schema Standards. The broad categories are simpleTypes such as integer, float, string, byte, etc. and complexTypes which are array and list type structures which are built up from simpleTypes.

SimpleTypes are defined and derived via the <ws>type API. The derivations are called restrictions. There are only a few methods of restriction available: renaming, enumeration and a regular expression or pattern. The current version of TWiST does not support uniuon types or list types.

<ws>type exists

If the type is already defined, returns 1, else returns 0.

<ws>type sim[ple]

Creates a new type with the new typeName, which is validated via the base type code. The effect is to provide an additional name for the simple type, or to import the type into the current namespace.

<ws>type enum[eration]

Creates a type which is restricted to be one of the enumerated values, each of which must be of the underlying base type.

<ws>type pat[tern]

Creates a type with a valuespace defined by a regular expression or pattern. The values must also be a valid in the base type valuespace.

<ws>type decimalRest[riction]

Creates a derived decimal type (a number) using a number of facets: The following facets are specified as a name-value list: {totalDigits 5 fractionDigits 2} minInclusive -- a decimal number defining the low end of the restricted range of values. minInclusive is included in the range. minExclusive -- a decimal number defining the low end of the restricted range of values. minExclusive is excluded from the range. maxExclusive -- a decimal number defining the high end of the restricted range of values. maxExclusive is excluded from the range. maxInclusive -- a decimal number defining the high end of the restricted range of values. maxExclusive is included in the range. totalDigits -- an integer limiting the total number of significant digits. Leading and trailing zeros are not included in the count. fractionDigits -- an integer limiting the total number of digits to the right of the decimal point. Trailing zeros are not included in the count.

At most only one of the min and one of the max facets can be included in the list. MinInclusive must be less than maxExclusive, and fractionDigits must be less than totalDigits. totalDigits and fractionDigits do not limit the lexical representation, which could have more or less digits than the canonical form. The canonical form disallows an optional leading positive sign (+), and must have at least one digit before and after the required decimal point, unless the restriction includes zero fractionDigits.

The default base type is xsd::decimal. If a range of integers is required, the base type should be xsd::integer. Any other numeric type can be used as a base as long as the new range is a subset of the base type, otherwise only the the base type will trim the range of the derived type, with potentially unexpected results.

<ws>type q[uery]

Returns a name value list of information about an existing type, or the empty string if the type doesn’t exist.

<ws>type valid[ate]

Checks if supplied value is a valid member of the type. (unimplimented)

NOTES

Type Definition and Use Example

<ws>namespace schema "urn:com:example:stock"

<ws>type simple stock::verbose xsd::boolean

<ws>type simple stock::quote xsd::float

<ws>type enum stock::symbol {MSFT WMT XOM GM F GE}

<ws>type enum stock::trend {-1 0 1} xsd::integer

<ws>type pattern stock::Code {[0-9]{4}} xsd::integer

<ws>element sequence stock::StockResponse {
    {Symbol:stock::symbol}
    {Quote:stock::quote}
    {DateOfChange:stock::dateOfChange {minOccurs 0}}
    {Name:stock::name                 {minOccurs 0 nillable no}}
    {Trend:stock::trend               {minOccurs 0}}
    {DailyMove:stock::dailyMove       {minOccurs 0}}
    {LastMove:stock::lastMove         {minOccurs 0}}
}

<ws>element sequence stock::StockRequest {
    {Symbol:stock::symbol}
    {Verbose:stock::verbose {minOccurs 0 default "1"}}
}

<ws>element sequence stock::StocksRequest {
    {StockRequest:elements::stock::StockRequest {maxOccurs 4}}
}

KEYWORDS

typeName