XSD Tutorial covers topics on XSD Data Types, XSD Date, XSD Empty, XSD Text , XSD Mixed, XSD Indicators, XSD Substitution ,XSD Examples, XSD Numeric, XSD Elements .
Lets discuss the XSD String Data Types in detail
XSD String <xs:string> Data Type
The Data Types are required in the XML Document to represent the data in different formats like Text, Number etc. XSD String Data Type is provided to represent the characters in the XML Document. XSD String Data Type contains or supports
- Characters,
- Line Feed,
- Tab characters &
- Carriage Return
Lets see if we need to represent the User FirstName and LastName then element can be described as given below
<xs:element name=”firstName” type=“xs:string”/>
<xs:element name=”firstName” type=“xs:string”/>
Output:
<firstName>Mohit </firstName>
<lastName> Sharma </lastName>
or
<firstName> Mohit </firstName>
<lastName> Sharma </lastName>
XML Processor executes the received String Data Type element as it is
Normalized String Data Type
Normalized String Data Type also represent String data but it does not supports Line Feed, Carriage Returns and Tab Characters.
<xs:element name=”firstName” type=“xs:normalizedString”/>
<firstName>Mohit </firstName>
or
<firstName> Mohit </firstName>
XML Process executes the above String Data Type by replacing tabs with spaces.
XSD Token <xs:token> Data Type
The token data type has also derived from data type supporting characters, but while processing, the XML processor eliminates the line feeds, carriage returns, tabs, multiple spaces and leading and trailing spaces.
<xs:element name=”firstName” type=“xs:token”/>
<firstName>Mohit </firstName>
or
<firstName> Mohit </firstName>
Derived String <xs:string> Data Type
S. No | Name | Description |
1 | ID | used in Schema for depicting the ID attribute in XML Document |
2 | IDREF | used in Schema for depicting the IDREF attribute in XML Document |
3 | language | depicts the valid language |
4 | Name | depicts Valid XML Name |
5 | NMTOKEN | used in Schema for depicting the NMTOKEN attribute in XML Document |
6 | normalizedstring | contains characters that does not supports line feeds, carriage returns, or tabs |
7 | string | contains characters that supports line feeds, carriage returns, or tabs |
8 | token | contains charatcter that does not supports line feeds, carriage returns, tabs, multiple spaces and leading / trailing spaces |
String Restrictions
XSD String data types applies the below given restrictions:
- Enumeration
- length
- minimum length
- maximum length
- pattern
- whitespace