Processing Instructions

A processing instruction is a structure in an XML document that contains an instruction to an application.

Productions

[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

Examples

<?xml-stylesheet href="mine.css" type="text/css" ?>

<?mso-application progid="Excel.Sheet" ?>

Description

Processing instructions, or PIs, can appear anywhere an element can appear (although the XML stylesheet PI must appear at the beginning, or prolog, of an XML document). Any PI must appear after the XML declaration, if one is present. A PI is bounded by the characters <? and ?>. The term immediately following <? is called the target. A target identifies the purpose or the name of the PI.

The XML stylesheet processing instruction is just one example of a common PI. Other examples include PIs you might find being used in DocBook (e.g., <?hard-pagebreak?>), Microsoft Word (<?mso-application progid="Word.Document" ?>), or Microsoft Excel (<?mso-application progid="Excel.Sheet" ?>). The purpose of the XML stylesheet PI is to associate a stylesheet with an XML document. The semantics of the XML stylesheet PI are like those of the HTML or XHTML link element. The structures href and type are called pseudo-attributes. The PI actually has six pseudo-attributes, but, to be brief, we’ll only discuss href and type here (others are title, media, charset, and alternate). In the first example, href identifies a relative URI ...

Get XML Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.