XSD String Data Type

The string data type is used for values that can contain strings.

String Data Type

The string data type can include characters, line breaks, carriage returns, and tab characters.

Here is an example of a string declaration in a certain scheme:

<xs:element name="customer" type="xs:string"/>

The elements in the document should look something like this:

<customer>John Smith</customer>

Or something similar:

<customer>	John Smith	</customer>

Note:If you use the string data type, the XML processor will not change the value in it.

NormalizedString Data Type

The normalized string data type originates from the string data type.

The normalized string data type can also contain characters, but the XML processor will remove line breaks, carriage returns, and tab characters.

Here is an example of a normalized string data type specification in a schema:

<xs:element name="customer" type="xs:normalizedString"/>

The elements in the document should look something like this:

<customer>John Smith</customer>

Or something similar:

<customer>	John Smith	</customer>

Note:In this example, the XML processor will replace all tab characters with spaces.

Token Data Type

The Token data type also originates from the string data type.

The Token data type can also contain characters, but the XML processor will remove line breaks, carriage returns, tab characters, leading and trailing spaces, and (consecutive) spaces.

Here is an example of a token declaration in a schema:

<xs:element name="customer" type="xs:token"/>

The elements in the document should look something like this:

<customer>John Smith</customer>

Or something similar:

<customer>	John Smith	</customer>

Note:In this example, the XML parser will remove tab characters.

String data type

Please note that all of the following data types are derived from the string data type (except for the string data type itself)!

Name Description
ENTITIES  
ENTITY  
ID A string that submits ID attributes in XML (used only with schema attributes)
IDREF A string that submits IDREF attributes in XML (used only with schema attributes)
IDREFS language A string that contains a valid language id
Name A string that contains a valid XML name
NCName  
NMTOKEN A string that submits NMTOKEN attributes in XML (used only with schema attributes)
NMTOKENS  
normalizedString A string that does not contain line breaks, carriage returns, or tab characters
QName  
string string
token A string that does not contain line breaks, carriage returns, tab characters, leading or trailing spaces, or multiple consecutive spaces

Restrictions on string data types (Restriction)}

Constraints that can be used with string data types:

  • enumeration
  • length
  • maxLength
  • minLength
  • pattern (NMTOKENS, IDREFS, and ENTITIES cannot be used with this constraint)
  • whiteSpace