XSD Tutorials - Herong's Tutorial Examples - v5.23, by Herong Yang
"normalizedString" Datatype Values and Representations
This section describes the first derived datatype of 'string': 'normalizedString'. Whitespace characters are replaced in 'normalizedString' lexical representations with ' ' characters to obtain their values.
Based on what we have learned on "string" datatype in the previous section, let's now look at its first derived datatype: normalizedString.
"normalizedString" is a datatype derived from "string" datatype by normalizing whitespace characters to space characters.
"normalizedString" value set is smaller than "string" value set. It contains only unique "string" values after whitespace characters: '\t', '\r' and '\n', are normalized (replaced) by the space character: ' '.
Note that '\t', '\r' and '\n' are still allowed in "normalizedString" lexical representations. But they are replaced by ' ' to obtain "normalizedString" values. For example, 3 XML elements below are all valid and represent the same "normalizedString" value:
<NormalizedString>Herong Yang</NormalizedString> <NormalizedString>Herong
Yang</NormalizedString> <NormalizedString>Herong Yang</NormalizedString>
I don't see any usage examples of "normalizedString" values in HTML documents.
Here is a sample XSD document that defines a sub element <NormalizedString> to use "normalizedString" values:
<?xml version="1.1"?> <!-- normalizedString_datatype_test.xsd - Copyright (c) 2002-2013 HerongYang.com. All Rights Reserved. --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="NormalizedString_Datatype_Test"> <xs:complexType> <xs:sequence> <xs:element name="NormalizedString" type="xs:normalizedString" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Here is a sample XML document that contains <NormalizedString> elements conforming with that definition:
<?xml version="1.1"?> <!-- normalizedString_datatype_test.xml - Copyright (c) 2002-2013 HerongYang.com. All Rights Reserved. --> <NormalizedString_Datatype_Test> <!-- 3 valid "normalizedString" elements represent the same value Assuming \r\n is the line break --> <NormalizedString>Herong Yang</NormalizedString> <NormalizedString>Herong
Yang</NormalizedString> <NormalizedString>Herong Yang</NormalizedString> <!-- 3 valid "normalizedString" elements represent different values --> <NormalizedString>Herong Yang</NormalizedString> <NormalizedString>Herong Yang</NormalizedString> <NormalizedString> Herong Yang</NormalizedString> </NormalizedString_Datatype_Test>
You can modify this example to try other "normalizedString" lexical representations and values.
Table of Contents
XML Editor and Schema Processor - XMLPad
Java API for XML Processing - JAXP
JAXP - XML Schema (XSD) Validation
Xerces2 Java Parser - Java API of XML Parsers
Introduction of XSD Built-in Datatypes
►"string" and Its Derived Datatypes
"string" Datatype Values and Representations
►"normalizedString" Datatype Values and Representations
"token" Datatype Values and Representations
"language" Datatype Values and Representations
"language" Datatype Values - Invalid Inputs
"Name" Datatype Values and Representations
"NMTOKEN" Datatype Values and Representations
"NCName" Datatype Values and Representations
"ENTITY" Datatype Values and Representations
"ID" Datatype Values and Representations
"IDREF" Datatype Values and Representations
"decimal" and Its Derived Datatypes
"dateTime" and Its Related Datatypes
Miscellaneous Built-in Datatypes
Facets, Constraining Facets and Restriction Datatypes
"simpleType" - Defining Your Own Simple Datatypes
Identity-Constraints: unique, key and keyref
Assertion as Custom Validation Rules
XML Schema Location and Namespace in XML Documents
Overriding Element Types in XML Documents