XML technologies / XML Schema / XML Schema element reference / xs:length

(Excerpt from “XML Schema” by Eric van der Vlist)

Facet specifying a value’s length.

<xs:length
    fixed = xs:boolean : "false"
    id = xs:ID
    value = xs:nonNegativeInteger
    {beliebige Attribute mit einem Nicht-Schema-Namensraum}
    >
    Content: (xs:annotation?)
</xs:length>

May occur within: xs:restriction (simple type), xs:restriction (simple content)

May be used as a facet for: xs:anyURI, xs:base64Binary, xs:ENTITIES, xs:ENTITY, xs:hexBinary, xs:ID, xs:IDREF, xs:IDREFS, xs:language, xs:Name, xs:NCName, xs:NMTOKEN, xs:NMTOKENS, xs:normalizedString, xs:NOTATION, xs:QName, xs:string, xs:token

Description

xs:length specifies length in a unit dependent on the data type. For most data types, the unit is the character defined in XML 1.0, namely Unicode characters defined by ISO/IEC 10646, possibly represented with more than eight bits. Exceptions are binary data types (xs:hexBinary and xs:base64Binary), whose lengths count binary-data bytes of eight bits, and list types, whose lengths count list items.

xs:length restricts value space. In practice, it is checked after whitespace replacement and collapsing as defined by facet xs:whitespace.

Restrictions

This is a logical length, often unrelated to the storage space a value needs.

This facet’s value cannot be modified in further restrictions, so attribute fixed is meaningless: behavior is always as if the facet were fixed.

Although unstated in the recommendation, an interaction exists between xs:length and xs:minLength as well as xs:maxLength. Length should not be set outside the base type’s range from xs:minLength to xs:maxLength.

Fixing facet xs:length does not fix facets xs:maxLength and xs:minLength . Use two restriction steps to fix all three, since applying them in the same step is forbidden.

Example

<xs:simpleType name="standardNotations">
    <xs:restriction base="xs:NOTATION">
        <xs:length value="8"/>
    </xs:restriction>
</xs:simpleType>

Attributes

fixed
If the value is true, the length cannot change in further restrictions; irrelevant here, since this facet’s value can never change in further restrictions anyway.

id
Element ID according to W3C XML Schema.

value
Facet value.

   

 

 

 

back to top