XSD String Data Types
The string data type is used for values that can contain strings.
String Data Type
The string data type can contain characters, line feeds, carriage returns, and tabs.
The following is an example of a string declaration in a schema:
The element in the document should look like this:
or like this:
**Note:** If you use the string data type, the XML processor will not alter the value.
NormalizedString Data Type
The normalizedString data type is derived from the string data type.
The normalizedString data type can also contain characters, but the XML processor will remove line feeds, carriage returns, and tabs.
The following is an example of a normalizedString data type declaration in a schema:
The element in the document should look like this:
or like this:
**Note:** In the example above, the XML processor will replace all tabs with spaces.
Token Data Type
The token data type is also derived from the string data type.
The token data type can also contain characters, but the XML processor will remove line feeds, carriage returns, tabs, leading and trailing spaces, and (multiple) consecutive spaces.
The following is an example of a token declaration in a schema:
The element in the document should look like this:
or like this:
Note:>In the example above, the XML parser will remove the tabs.
String Data Types
Please note that all of the following data types are derived from the string data type (except the string data type itself)!
| Name | Description |
|---|---|
| ENTITIES | |
| ENTITY | |
| ID | Strings representing ID attributes in XML (used only with schema attributes) |
| IDREF | Strings representing IDREF attributes in XML (used only with schema attributes) |
| IDREFS language | Strings containing a legal language id |
| Name | Strings containing a legal XML name |
| NCName | |
| NMTOKEN | Strings representing NMTOKEN attributes in XML (used only with schema attributes) |
| NMTOKENS | |
| normalizedString | Strings that do not contain line feeds, carriage returns, or tabs |
| QName | |
| string | String |
| token | Strings that do not contain line feeds, carriage returns, or tabs, leading or trailing spaces, or multiple consecutive spaces |
Restriction on String Data Types
Restrictions that can be used with string data types:
- enumeration
- length
- maxLength
- minLength
- pattern (this constraint cannot be used with NMTOKENS, IDREFS, and ENTITIES)
- whiteSpace