You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
62<br />
Working with Whitespace Characters<br />
<strong>XML</strong> Demystifi ed<br />
Each character on your keyboard is assigned a unique number called an ASCII<br />
number. You don’t need to know these numbers, but if you’re curious, look up<br />
“ASCII table” in a search engine and you’ll see the ASCII numbers.<br />
Some characters are nonprintable characters, such as a space inserted when you<br />
press the spacebar or the tab when you press the TAB key. These are referred to as<br />
whitespace characters. You’ll find a list of these characters numbered from zero to<br />
33 on the ASCII table.<br />
Whitespace characters are inserted into a document to give instructions to the<br />
program that reads the document. You don’t see these on the screen, but a program,<br />
such as a parser, can see them.<br />
For example, a carriage return and linefeed whitespace characters are inserted<br />
into a document when you press the ENTER key. This gives the program instructions<br />
to move the cursor to the beginning of the next line.<br />
You can tell the parser how to handle whitespace characters that appear in an<br />
<strong>XML</strong> document by using the xs:whiteSpace tag in the <strong>XML</strong> schema. There are<br />
three things that you can do when you encounter a whitespace character in an <strong>XML</strong><br />
document: preserve, replace, or collapse.<br />
Preserve means that the parser does nothing special with the whitespace character.<br />
It simply passes the whitespace characters along with the rest of the <strong>XML</strong> document.<br />
Replace tells the parse to replace all whitespace characters with a space. Collapse<br />
tells the parser to replace all whitespace characters with spaces (similar to replace),<br />
then it collapses multiple occurrences of whitespaces to a single space. Furthermore,<br />
leading and trailing whitespaces are deleted.<br />
You specify preserve, replace, and collapse as the value of the value attribute of<br />
the xs:whiteSpace tag. Here is an example of preserve:<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Restricting the Length of a Field<br />
A seemingly endless number of characters can be used as the content of an element.<br />
However, other applications that use the data might restrict the number of characters<br />
they can receive from the <strong>XML</strong> document.