XSD String Data Type
- Previous Page XSD Example
- Next Page XSD Date
The data type string is used for values that can contain strings.
String Data Type
The string data type can contain characters, line breaks, carriage returns, and tabs.
Here is an example of a string declaration in a schema:
<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 within it.
NormalizedString Data Type
The normalized string data type is also derived 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 tabs.
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 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 breaks, carriage returns, tabs, 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 tabs.
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 | The string submitted as the ID attribute in XML (used only with the schema attribute) |
IDREF | The string submitted as the IDREF attribute in XML (used only with the schema attribute) |
IDREFS language | A string containing a valid language id |
Name | A string containing a valid XML name |
NCName | |
NMTOKEN | The string submitted as the NMTOKEN attribute in XML (used only with the schema attribute) |
NMTOKENS | |
normalizedString | A string that does not contain newlines, carriage returns, or tabs |
QName | |
string | String |
token | A string that does not contain newlines, carriage returns, tabs, leading or trailing spaces, or multiple consecutive spaces |
Restrictions on string data types
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
- Previous Page XSD Example
- Next Page XSD Date