XSD StringData 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.
Below 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 change 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 breaks, carriage returns, and tabs.
Below is an example of the normalizedString data type 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 (consecutive) spaces.
Below 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 tabs.
String Data Type
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 | A string that represents an ID attribute in XML (used only with schema attributes) |
| IDREF | A string that represents an IDREF attribute 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 represents an NMTOKEN attribute in XML (used only with schema attributes) |
| NMTOKENS | |
| normalizedString | A string that does not contain line feeds, carriage returns, or tabs |
| QName | |
| string | String |
| token | A string that does not contain line feeds, carriage returns, tabs, leading or trailing spaces, or multiple consecutive spaces |
Restrictions on the String Data Type
Restrictions that can be used with the string data type:
- enumeration
- length
- maxLength
- minLength
- pattern (This constraint cannot be used with NMTOKENS, IDREFS, and ENTITIES)
- whiteSpace