Processing Instruction


title: "Processing Instruction" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["xml"] topic_path: "general/xml" source: "https://en.wikipedia.org/wiki/Processing_Instruction" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

A processing instruction (PI) is an SGML and XML node type, which may occur anywhere in a document, intended to carry instructions to the application.

Processing instructions are exposed in the Document Object Model as Node.PROCESSING_INSTRUCTION_NODE, and they can be used in XPath and XQuery with the 'processing-instruction()' command.

Syntax

An SGML processing instruction is enclosed within ``.

An XML processing instruction is enclosed within ``, and contains a target and optionally some content, which is the node value, that cannot contain the sequence ?. ::code[lang=xml]

The [[XHTML#XML declaration|XML Declaration]] at the beginning of an XML document (shown below) is another example of a processing instruction,{{Cite web |title=XML 1.0 - slide "Processing Instructions (PIs)" |url=https://www.w3.org/Consortium/Offices/Presentations/XML1.0/slide30-0.htm |access-date=2023-02-08 |website=www.w3.org}} however it may not technically be considered one.{{cite book | title = XML in a nutshell | author = Elliotte Rusty Harold, W. Scott Means | year = 2004 | isbn = 978-0-596-00764-5 | page = 23 }} ::

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 and CSS stylesheets. ::code[lang=xml]

::

The DocBook XSLT stylesheets understand a number of processing instructions to override the default behaviour.

A draft specification for Robots exclusion standard rules inside XML documents uses processing instructions.

References

References

  1. Stayton, Bob. (September 2007). "DocBook XSL: The Complete Guide". Sagehill Enterprises.
  2. [http://www.w3.org/TR/NOTE-sgml-xml-971215 Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997]
  3. Bryan, Martin. (1997). "SGML and HTML Explained". Addison Wesley Longman.
  4. Hossein Bidgoli. (2004). "The Internet encyclopedia, Volume 3". John Wiley and Sons.
  5. "XML 1.0 - slide "Processing Instructions (PIs)"".
  6. Elliotte Rusty Harold, W. Scott Means. (2004). "XML in a nutshell".
  7. "Associating Style Sheets with XML documents 1.0 (Second Edition)".
  8. "Part 2. FO Processing Instruction Reference".
  9. "Robots Processing Instruction Homepage".

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

xml