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

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

Facet specifying whitespace behavior.

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

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

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

Description

This facet specifies how whitespace, namely #x20 (space), #x9 (tab), #xA (line feed) and #xD (carriage return), is treated during transformation from lexical to value space.

Possible values are preserve (whitespace is retained unchanged), replace (all whitespace occurrences are replaced by a space) and collapse (leading and trailing whitespace is removed, and every remaining sequence is replaced by one space).

Restrictions

This is the only facet, or part of W3C XML Schema, affecting the canonicalization transformation.

Whitespace behavior cannot be relaxed during restriction: if a data type’s whitespace value is preserve , its derived data types can have any whitespace behavior; if it is replace, they can only have whitespace values replace or collapse. If the value is collapse, all derived types must have the same behavior.

This limit is slightly paradoxical, since it actually permits extending a data type’s lexical space during derivation by restriction.

Example

<xs:simpleType name="CapitalizedNameWS">
   <xs:restriction base="xs:string">
      <xs:whitespace value="collapse"/>
      <xs:pattern value="([A-Z]([a-z]*) ?)+"/>
   </xs:restriction>
</xs:simpleType>

Attributes

fixed
If the value is true, this facet’s value cannot be changed in further restrictions.

id
Element ID according to W3C XML Schema.

value
Facet value.

   

 

 

 

back to top