Processing Instruction Explained

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.[1] [2]

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 <? and >.[3]

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 ?>.[4]

The XML Declaration at the beginning of an XML document (shown below) is another example of a processing instruction,[5] however it may not technically be considered one.[6]

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.[7] It can be used for both XSLT and CSS stylesheets.

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

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

External links

Notes and References

  1. Book: Stayton, Bob . DocBook XSL: The Complete Guide . http://www.sagehill.net/docbookxsl/ProcessingInstructions.html . Sagehill Enterprises . September 2007 . Chapter 9. Customization methods §Processing instructions . 978-0974152134.
  2. http://www.w3.org/TR/NOTE-sgml-xml-971215 Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997
  3. Book: Bryan, Martin . SGML and HTML Explained . Addison Wesley Longman . 1997 . 0-201-40394-3 . 2010-08-18 . registration .
  4. Book: The Internet encyclopedia, Volume 3 . limited . Hossein Bidgoli . 877 . John Wiley and Sons . 2004 . 0-471-22203-8.
  5. Web site: XML 1.0 - slide "Processing Instructions (PIs)" . 2023-02-08 . www.w3.org.
  6. Book: XML in a nutshell . Elliotte Rusty Harold, W. Scott Means . 2004 . 978-0-596-00764-5 . 23 .
  7. Web site: Associating Style Sheets with XML documents 1.0 (Second Edition).
  8. Web site: Part 2. FO Processing Instruction Reference.
  9. Web site: Robots Processing Instruction Homepage . 2010-08-18 . dead. https://web.archive.org/web/20100921021126/http://www.atrus.org/writings/technical/robots_pi/ . 2010-09-21 .