The string data type is used for values that can contain strings. String data types can contain characters, line feeds, carriage returns, and tabs. Here is an example of a string declaration in a scheme: The elements in the document should look like this: Or something like this: 注意: If you use a string data type, the XML processor does not change the value in it. Normalized string data types are derived from string data types. Normalized string data types can also contain characters, but the XML processor removes line breaks, carriage returns, and tabs. Here is an example of normalizing string data types in a schema: The elements in the document should look like this: Or something like this: 注意: In the above example, the XML processor replaces all tabs with spaces. The Token data type is also derived from the string data type. The Token data type can also contain characters, but the XML processor removes newline characters, carriage returns, tabs, beginning and ending spaces, and (consecutive) spaces. Here is an example of an token declaration in schema: The elements in the document should look like this: Or something like this: 注意: In the above example, the XML parser removes tabs. 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 Submit a string for the ID attribute in XML (used only with the schema attribute) IDREF Submit a string for the IDREF attribute in XML (used only with the schema attribute) IDREFS language A string containing the legal language id Name A string containing a legal XML name NCName NMTOKEN Submit a string for the NMTOKEN attribute in XML (used only with the schema attribute) NMTOKENS NormalizedString A string that does not contain newline characters, carriage returns, or tabs QName String String Token A string that does not contain newline characters, carriage returns or tabs, beginning or ending spaces, or multiple consecutive spaces Restrictions that can be used with string data types: Enumeration Length MaxLength MinLength Pattern (this constraint cannot be used by NMTOKENS, IDREFS, and ENTITIES) WhiteSpaceString data type (String Data Type) ¶
<xs:element name="customer" type="xs:string"/>
<customer>John Smith</customer>
<customer> John Smith </customer>
Normalize string data types (NormalizedString Data Type) ¶
<xs:element name="customer" type="xs:normalizedString"/>
<customer>John Smith</customer>
<customer> John Smith </customer>
Token data type (Token Data Type) ¶
<xs:element name="customer" type="xs:token"/>
<customer>John Smith</customer>
<customer> John Smith </customer>
String data type ¶
Qualification of string data types (Restriction) ¶