A '''Processingprocessing Instructioninstruction''' ('''PI''') is an [[SGML]] and [[XML]] node type, which may occur anywhere in thea document, intended to carry instructions to the application.<ref>[{{Cite book |last=Stayton |first=Bob |title=DocBook XSL: The Complete Guide |chapter-url=http://www.sagehill.net/docbookxsl/ProcessingInstructions.html |publisher=Sagehill Enterprises |date=September 2007 |chapter=Chapter 9. Customization methods: §Processing instructions] |isbn=978-0974152134}}</ref><ref>[http://www.w3.org/TR/NOTE-sgml-xml-971215 Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997]</ref>
Processing instructions are exposed in the [[Document Object Model]] as <code>Node.PROCESSING_INSTRUCTION_NODE</code>, and they can be used in [[XPath]] and [[XQuery]] with the 'processing-instruction()' command.
== Syntax ==
An SGML processing instruction is enclosed within '<code><?</code> and '<code>></code>'.<ref>{{cite book |title= SGML and HTML Explained |last= Bryan |first= Martin |publisher= Addison Wesley Longman |year= 1997 |url= httphttps://wwwarchive.is-thought.co.ukorg/bookdetails/sgml-8.htm#PIsgmlhtmlexplaine0000brya |isbn= 0-201-40394-3 |access-date= 2010-08-18 |url-access= registration }}</ref>
An XML processing instruction is enclosed within '<code><?'</code> and '<code>?>'</code>, and contains a ''target'' and optionally some content, which is the node value, that cannot contain the sequence '<code>?>'</code>.<ref>{{cite book | title = The Internet encyclopedia, Volume 3 | url = https://archive.org/details/internetencyclop00bidg_359 | url-access = limited | author = Hossein Bidgoli | page = [https://archive.org/details/internetencyclop00bidg_359/page/n911 877] | publisher = John Wiley and Sons | year = 2004 | isbn = 0-471-22203-8}}</ref>
<sourcesyntaxhighlight lang="xml"><?PITarget PIContent?></sourcesyntaxhighlight>
The [[XHTML#XML_declarationXML declaration|XML Declaration]] at the beginning of an XML document (shown below) is notanother example of a processing instruction,<ref>{{Cite howeverweb its|title=XML similar1.0 syntax- hasslide often"Processing resultedInstructions in(PIs)" it|url=https://www.w3.org/Consortium/Offices/Presentations/XML1.0/slide30-0.htm being|access-date=2023-02-08 referred|website=www.w3.org}}</ref> tohowever asit amay processingnot instructiontechnically be considered one.<ref name="nutshell">{{cite book | title = XML in a nutshell | author = Elliotte Rusty Harold, W. Scott Means | year = 2004 | isbn = 978-0-596-00764-5 | page = 23 }}</ref>
<sourcesyntaxhighlight lang="xml"><?xml version="1.0" encoding="UTF-8" ?></sourcesyntaxhighlight>
== Examples ==
The most common use of a processing instruction is to request the XML document be rendered using a [[Extensible Stylesheet Language|stylesheet]] using the 'xml-stylesheet' target, which was standardized in 1999.<ref>[{{Cite web|url=http://www.w3.org/TR/xml-stylesheet/]|title=Associating Style Sheets with XML documents 1.0 (Second Edition)}}</ref> It can be used for both [[XSLT]] and [[Cascading Style Sheet|CSS]] stylesheets.
<sourcesyntaxhighlight lang="xml"><?xml-stylesheet type="text/xsl" href="style.xsl"?></sourcesyntaxhighlight>
<sourcesyntaxhighlight lang="xml"><?xml-stylesheet type="text/css" href="style.css"?></sourcesyntaxhighlight>
The [[DocBook]] XSLT stylesheets understand a number of processing instructions to override the default behaviour.<ref> [http{{Cite web|url=https://docbook.sourceforge.net/release/xsl/current/doc/pi/pi-fo.html ]|title = Part 2. FO Processing Instruction Reference}}</ref> ▼
Another use is the [[programming language]] [[PHP]], which can be embedded within an (X)[[HTML]] document as shown in the following example.<ref name="nutshell">{{cite book | title = XML in a nutshell | author = Elliotte Rusty Harold, W. Scott Means | page = 23 }}</ref>
<source lang="php"><?php echo $a; ?></source>
A draft specification for [[Robots exclusion standard]] rules inside XML documents uses processing instructions.<ref>{{cite web |url=http://www.atrus.org/writings/technical/robots_pi/ |title=Robots Processing Instruction Homepage |accessdate=2010-08-18 |url-status=dead|archiveurl=https://web.archive.org/web/20100921021126/http://www.atrus.org/writings/technical/robots_pi/ |archivedate=2010-09-21 }}</ref>
▲The [[DocBook]] XSLT stylesheets understand a number of processing instructions to override the default behaviour.<ref>[http://docbook.sourceforge.net/release/xsl/current/doc/pi/pi-fo.html]</ref>
A draft specification for [[Robots exclusion standard]] rules inside XML documents.<ref>[http://www.atrus.org/writings/technical/robots_pi/]</ref>
== References ==
== External links ==
* [http://www.w3.org/TR/REC-xml/#sec-pi XML specification section: Processing Instructions]
* [https://web.archive.org/web/20160303185749/http://www.dpawson.co.uk/xsl/sect2/N6145.html XSLT FAQ: Processing Instructions], Dave Pawson
* [https://developer.mozilla.org/en/XSLT/processing-instruction xslt:processing-instruction], Mozilla
[[Category:XML]]
{{comp-sci-stub}}
[[de:Verarbeitungsanweisung]]
|