Click to See Complete Forum and Search --> : xsd:string


Jaco de Villiers
06-20-2001, 05:00 AM
Does anyone know if you can asign a maxlength for an type="xsd:string" element
in a XML schema? I need to limit the length of the value for a particular
element in my document

Regards

Jaco de Villiers

Jaco de Villiers
06-20-2001, 06:24 AM
The new W3C XSD definition supports it

"Jaco de Villiers" <jacodv_32@hotmail.com> wrote:
>
>Does anyone know if you can asign a maxlength for an type="xsd:string" element
>in a XML schema? I need to limit the length of the value for a particular
>element in my document
>
>Regards
>
>Jaco de Villiers

rdbms
06-20-2001, 09:04 AM
"Jaco de Villiers" <jacodv_32@hotmail.com> wrote:
>
>The new W3C XSD definition supports it
>
>"Jaco de Villiers" <jacodv_32@hotmail.com> wrote:
>>
>>Does anyone know if you can asign a maxlength for an type="xsd:string"
element
>>in a XML schema? I need to limit the length of the value for a particular
>>element in my document
>>
>>Regards
>>
>>Jaco de Villiers
>

Both XML Schema (W3C) and XML Data Reduced (xdr) support constraining "facets"
for the string data type (and both techniques are very similar).

In the case of XML Schemas "xsd:string", the most common facets are:
1) <xsd:length = ""> where the length facet value is a bounded constraint
(representing both minium and maximum)
2) <xsd:minLength = ""> where the minLength facet value is the minimum
length (fairly obvious from the facet name).
3) <xsd:maxLength = ""> where the maxLength facet value is the maximum
length (again, fairly obvious from the facet name).

In the case of XML Data Reduced "dt:type="string", the most common facets
are:
1) dt:minLength = "" (declared as an attribute of the ElementType)
2) dt:maxLength = "" (declared as an attribute of the ElementType)

There are also other facets available for "xsd:string". Best advice...
take a look at the current W3C recommendation for XML Schemas.

As you might expect, parser support for xdr data typing and facets varies.