Control Codes Supported in XML 1.1

This section provides a tutorial example showing that more control codes are supported in XML 1.1 as character references.

First, let's verify that XML 1.1 allows us to use control characters in #x01 to #x1F and #x7F to #x9F ranges as character references. Here is my example XML 1.0 file, control-codes-1-0.xml, with some control codes:

<?xml version="1.0"?>
<pre>
SOH: (#x01;)=(&#x01;)
STX: (#x02;)=(&#x02;)
ETX: (#x03;)=(&#x03;)
EOT: (#x04;)=(&#x04;)
ENQ: (#x05;)=(&#x05;)
ACK: (#x06;)=(&#x06;)
BEL: (#x07;)=(&#x07;)
BS: (#x08;)=(&#x08;)
HT: (#x09;)=(&#x09;)
LF: (#x0A;)=(&#x0A;)
VT: (#x0B;)=(&#x0B;)
FF: (#x0C;)=(&#x0C;)
CR: (#x0D;)=(&#x0D;)
SO: (#x0E;)=(&#x0E;)
SI: (#x0F;)=(&#x0F;)
</pre>

Try to parse it with DOMBrowser.java. You should some errors:

C:\herong\xml>java DOMBrowser control-codes-1-0.xml

[Fatal Error] control-codes-1-0.xml:3:26: Character reference "&#
org.xml.sax.SAXParseException; systemId: 
file:/C:/herong/xml/control-codes-1-0.xml; lineNumber: 3; columnNumber: 21; 
Character reference "&#

Okay. The output proves that XML 1.0 does not support some control codes listed in the XML file. If you read the error message carefully, you will that the first error occurred at line 3 and column 21, which is the control code STX (#x02). So the control code SOH (#x01) is supported in XML 1.0, but STX (#x02) is not.

Now let's put those control codes in an XML 1.1 file, control-codes-1-1.xml:

<?xml version="1.1"?>
<pre>
SOH: (#x01;)=(&#x01;)
STX: (#x02;)=(&#x02;)
ETX: (#x03;)=(&#x03;)
EOT: (#x04;)=(&#x04;)
ENQ: (#x05;)=(&#x05;)
ACK: (#x06;)=(&#x06;)
BEL: (#x07;)=(&#x07;)
BS: (#x08;)=(&#x08;)
HT: (#x09;)=(&#x09;)
LF: (#x0A;)=(&#x0A;)
VT: (#x0B;)=(&#x0B;)
FF: (#x0C;)=(&#x0C;)
CR: (#x0D;)=(&#x0D;)
SO: (#x0E;)=(&#x0E;)
SI: (#x0F;)=(&#x0F;)
</pre>

Run the same test with the XML 1.1 file:

C:\herong\xml>java DOMBrowser control-codes-1-0.xml
#document: 9, 1, -1, null
 pre: 1, 1, 0, null
  #text: 3, 0, -1, 02;H: (#x01;)=(?)
STX: (#x02;)=(?)
ETX: (#x03;)=(?)
EOT: (#x04;)=(?)
ENQ: (#x05;)=(?)
ACK: (#x06;)=(?)
BEL: (#x07;)=()
BS: (#x08;)=)
HT: (#x09;)=(   )
LF: (#x0A;)=(
)
VT: (#x0B;)=(?)
FF: (#x0C;)=(?)
)R: (#x0D;)=(
SO: (#x0E;)=(?)
SI: (#x0F;)=(?)

The test output proves that those control codes are supported in XML 1.1.

Last update: 2014.

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

XML 1.1 Changes and Parsing Examples

 Major Changes in XML 1.1

 Supporting XML 1.1 in Java 6 and Higher

Control Codes Supported in XML 1.1

 Unicode Characters Supported in XML 1.1 Names

 End-of-Line Characters Supported in XML 1.1

 Web Browsers Not Supporting XML 1.1

 Outdated Tutorials

 References

 PDF Printing Version