A Processing Instruction (PI) is an
SGML
The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two postulates":
* Declarative: Markup should d ...
and
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
node type, which may occur anywhere in the document, intended to carry instructions to the application.
Processing instructions are exposed in the
Document Object Model
The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a docum ...
as
Node.PROCESSING_INSTRUCTION_NODE
, and they can be used in
XPath
XPath (XML Path Language) is an expression language designed to support the query or transformation of XML documents. It was defined by the World Wide Web Consortium (W3C) and can be used to compute values (e.g., strings, numbers, or Boolean v ...
and
XQuery with the 'processing-instruction()' command.
Syntax
An SGML processing instruction is enclosed within
and
>
.
An XML processing instruction is enclosed within
and
?>
, and contains a ''target'' and optionally some content, which is the node value, that cannot contain the sequence
?>
.
The
XML Declaration at the beginning of an XML document (shown below) is not a processing instruction, however its similar syntax has often resulted in it being referred to as a processing instruction.
Examples
The most common use of a processing instruction is to request the XML document be rendered using a
stylesheet using the 'xml-stylesheet' target, which was standardized in 1999. It can be used for both
XSLT
XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subse ...
and
CSS stylesheets.
The
DocBook
DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software, but it can be used for any other sort of documentation.
As a semantic languag ...
XSLT stylesheets understand a number of processing instructions to override the default behaviour.
A draft specification for
Robots exclusion standard
The robots exclusion standard, also known as the robots exclusion protocol or simply robots.txt, is a standard used by websites to indicate to visiting web crawlers and other web robots which portions of the site they are allowed to visit.
Th ...
rules inside XML documents uses processing instructions.
References
{{reflist
External links
XML specification section: Processing Instructions Dave Pawson
xslt:processing-instruction Mozilla
XML