XML Schema Tuto...login
XML Schema Tutorial
author:php.cn  update time:2022-04-20 14:13:02

XML Schema string data type


XSD String Data Type


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 tab characters.

The following is an example of string declaration in a scheme:

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

The elements in the document should look something like this:

<customer>John Smith</customer>

Or something like this:

<customer> John Smith will change the value.

Normalized String Data Type (NormalizedString Data Type) The normalized string data type is 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.

The following is an example of normalizing the string data type 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 like this:
<customer> John Smith </customer>

Note:
In the above example, the XML processor All tab characters will be replaced with spaces.

Token data type (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 removes newlines, carriage returns, tabs, leading and trailing spaces, and (consecutive) spaces.

The following is an example of token declaration in schema:

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

The elements in the document should look something like this:
<customer>John Smith</customer>

Or something like this:
<customer> John Smith </customer>

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


String data type

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

NameDescription
ENTITIES
ENTITY
IDSubmit the string of the ID attribute in XML (only used with the schema attribute)
IDREFSubmit the string of the IDREF attribute in XML (only used with the schema attribute)
IDREFS language String containing the legal language id
NameString containing the legal XML name
NCName
NMTOKENSubmit the string of the NMTOKEN attribute in XML (only used with the schema attribute)
NMTOKENS
normalizedStringA string that does not contain newlines, carriage returns, or tabs
QName
stringString
token A string that does not contain a newline character, a carriage return or a tab character, a leading or trailing space, or multiple consecutive spaces


pair of characters Restriction of the string data type (Restriction)

Restrictions that can be used with the string data type:

  • enumeration

  • length

  • maxLength

  • minLength

  • pattern (NMTOKENS, IDREFS, and ENTITIES cannot use this constraint )

  • whiteSpace

php.cn